-
Notifications
You must be signed in to change notification settings - Fork 540
Add Gradle configuration for package prefix #3587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
After some testing, it would be best to setup package prefix for every source folder, for example: sqldelight {
database("Database") {
packageName = "$group.database"
// OLD behaviour
sourceFolders = setOf("migrations", "queries")
// NEW behaviour
sourceFolders = mapOf(
"migrations" to "$group.database.migrations",
"queries" to "$group.database.queries",
)
deriveSchemaFromMigrations = true
dialect(libs.sqldelight.sqlite.dialect)
}
} Or can you came up with another, better solution? I can try to make a PR, but want to know what you authors think about this. |
The more I am thinking about it the more wierd the current behaviour without the configuration feels. For example, when I would expect importing those classes from package named something like The second is current behaviour is against Kotlin's own coding conventions about directory structure which suggest to omit common package prefix.
@AlecStrong can you please help me figure out the best way to tackle this and validate my feelings about the current strucure? I can then try to prepare a PR if we came to some conclusion. |
Another way to solve this in simpler and backward compatible way is to split migration and queries configuration like this: sqldelight {
database("Database") {
packageName = "$group.database"
sourceFolders = setOf("sqldelight")
sourcePackagePrefix = "$group.database.queries"
migrationFolders = setOf("migrations")
migrationPackagePrefix = "$group.database.tables"
deriveSchemaFromMigrations = true
dialect(libs.sqldelight.sqlite.dialect)
}
} Just throwing ideas here. |
so theres a few things here, none of which I really want to solve with extra configuration:
@hfhbd has also been talking about this and might have more takes on this but for now my plan is to better document the existing stuff, and then potentially iterate on how the schema is packaged if you're deriving from migrations. |
essentially better document the current behavior, which is (or should be if not currently): all files just go to the package for their relative folder structure to the source root (for derived migrations, it is the folder the |
@AlecStrong with the new compact display in IDE, I am okay with this, thank you :) |
Description
Sometimes it is overkill to add 6 folders to migrations and queries just to generate code into right package, like:
src/main/sqldelight/com/example/project/name/database/migrations
It would be cool to have configuration in Gradle to setup expected package like:
The text was updated successfully, but these errors were encountered: