Configuration advice for project using dynamic feature modules?
See original GitHub issueI have an Android project which consists of an app
module, a core
module, and multiple dynamic feature modules. Each feature module defines its own .sq
files.
The problem is that currently SQLDelight generates multiple Database
classes: one for each module independently. These classes only contain the queries for their own module.
Is it possible to make SQLDelight generate a single Database class only in the core module, and make sure that this class contains the queries defined in every feature module?
I want to define my DI components for the database in the core module, so that they can be shared by all feature modules.
Here’s what the current project structure looks like:
├── app
├── core
├── features
│ ├── feature1
│ │ └── src
│ │ └── main
│ │ ├── java
| │ └── sqldelight
│ │ └── com.example.myapp.feature1
│ │ └── feature1.sq
│ ├── feature2
│ │ └── src
│ │ └── main
│ │ ├── java
| │ └── sqldelight
│ │ └── com.example.myapp.feature2
│ │ └── feature2.sq
I have tried defining the following configuration in every feature module’s build.gradle
file, but to no avail:
sqldelight {
Database {
packageName = "com.example.myapp.core"
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Top GitHub Comments
@mhernand40 Happy to report that the method you suggested does work. Thanks for helping me out!
For people who might see this issue in the future, this is what my current project structure looks like:
The
app
module depends ondatabase
which in turn depends onfeature1
andfeature2
. Each module defines its own.sq
files. Thebuild.gradle
files look like this:The result is that SQLDelight generates a
MyDatabase
class in thedatabase
module inheriting fromMyDatabase0
andMyDatabase1
(auto-generated names for databases from the feature modules). The queries of both feature modules are therefore accessible from this class.One caveat I found here was that if the
database
module does not contain any.sq
files of its own then SQLDelight does not generate any code for it. I expected that it would contain an empty Database class inheriting from the ones defined in both feature modules.@AlecStrong @haroldadmin Was there ever a bug filed for not generating code in a module with no
.sq
files? Couldn’t find it searching but I’d like to follow it.