sqldelight: Gradle task not found
Component: sqldelight-gradle-plugin Version: both 1.1.0-SNAPSHOT and 1.2.0-SNAPSHOT
Configuration: build.gradle.kts (common)
plugins {
kotlin("multiplatform")
id("com.squareup.sqldelight")
}
apply(from = File("sqldelight.gradle"))
// ...
sqldelight.gradle (common)
sqldelight {
TodoSqlDelightDatabase {
packageName = "com.sample.todo.data.sqldelight"
sourceFolders = ["sqldelight"]
schemaOutputDirectory = file("src/main/sqldelight/migrations")
}
}
Step to reproduce:
gradlew common:tasks
// ...
Sqldelight tasks
----------------
generateAndroidMainTodoSqlDelightDatabaseInterface - Generate androidMain Kotlin interface for TodoSqlDelightDatabase
generateAndroidMainTodoSqlDelightDatabaseSchema - Generate a .db file containing the current TodoSqlDelightDatabase schema for androidMain.
generateMetadataMainTodoSqlDelightDatabaseInterface - Generate metadataMain Kotlin interface for TodoSqlDelightDatabase
generateMetadataMainTodoSqlDelightDatabaseSchema - Generate a .db file containing the current TodoSqlDelightDatabase schema for metadataMain.
verifyAndroidMainTodoSqlDelightDatabaseMigration - Verify androidMain TodoSqlDelightDatabase migrations and CREATE statements match.
verifyMetadataMainTodoSqlDelightDatabaseMigration - Verify metadataMain TodoSqlDelightDatabase migrations and CREATE statements match.
// ...
gradlew common:generateMetadataMainTodoSqlDelightDatabaseInterface
Configuration on demand is an incubating feature.
> Configure project :common
Kotlin Multiplatform Projects are an experimental feature.
Configuring compileKotlinAndroid in project common...
Configuring compileTestKotlinAndroid in project common...
FAILURE: Build failed with an exception.
* What went wrong:
Task 'generateMetadataMainTodoSqlDelightDatabaseInterface' not found in project ':common'.
* Try:
Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to g
et full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 30 (2 by maintainers)
Commits related to this issue
- Commit for https://github.com/square/sqldelight/issues/1243 — committed to nlgtuankiet/todo-sample by nlgtuankiet 5 years ago
turns out this is actually preventing us from upgrading the sample to 1.1.3 because we use configure on demand for CI, so this is pretty high priority
I’m going to need to rethink the sqldelight gradle lifecycle more. It’s too late to rework things right now but here’s what I think needs to be done:
Right now we rely on
projectsEvaluated
to add the sqldelight tasks and dependencies to the task graph, this doesnt work for configuration on demand. It’s not super clear why, I’m assuming the time which that callback gets invoked is different with COD and its too late to set task dependencies.That’s pretty hacky regardless, so probably what we need to do is use task creation callbacks instead of project evaluation callbacks. The original problem was that kotlin multiplatform adds the android compilation tasks late in gradles lifecycle, and
projectsEvaluated
always invoked after that. Instead we should probably usetasks.whenTaskAdded
to add sqldelight task dependencies when the kotlin compilation tasks are added.There’s also some implications for multi-module here, since module properties are initialized during
afterEvaluate
blocks, we were assuming they’re set up when creating tasks inprojectsEvaluated
, but if we switch to task creation that probably won’t hold, so we’ll also need to make sure the downstream sqldelight module is configured, which probably requires more understanding of how gradle implements configure on demand.I believe this is due to enabling configure on demand in Gradle which somehow breaks the SQLDelight plugin.
@AlecStrong was this fixed? I’m having a similar issue in my project (although I’m not using SqlDelight), can you let me know how you fixed this? Cheers.
yup i see it too. Very weird bug. The only thing I can think of is that it still has to do with the gradle kotlin dsl since the root project uses it. We’ll have to setup a test case in repo for the kotlin dsl to make sure it works