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
do the generateAndroidMain... tasks work fine?
Just tried out all 6 tasks listed, all report task not found
thats....really confusing. Maybe related to kotlin gradle script stuff. Have you tried running the task from IDE instead of command line? Curious if that says anything different
Tasks are all listed in the Gradle panel (Android Studio)
Run tasks from IDE produce the same issue,
I suspect the same thing.
Since I do not know how to configure this through Gradle Kotlin DSL so I just apply from a regular one. The fact that tasks name contain my database class name prove that the sqldelight.gradle applied successful
yea and their appearance in the list should mean the tasks are actually working...
what version of gradle are you using?
Just migrated backed to a groovy script, same issue
build.gradle (:common)
plugins {
id 'org.jetbrains.kotlin.multiplatform'
id 'com.squareup.sqldelight'
}
sqldelight {
TodoSqlDelightDatabase {
packageName = "com.sample.todo.data.sqldelight"
sourceFolders = ["sqldelight"]
schemaOutputDirectory = file("src/main/sqldelight/migrations")
}
}
kotlin {
sourceSets {
commonMain {
dependencies {
implementation("com.squareup.sqldelight:runtime")
implementation("org.jetbrains.kotlin:kotlin-stdlib")
}
}
commonTest {
dependencies {
implementation("org.jetbrains.kotlin:kotlin-test-common")
implementation("org.jetbrains.kotlin:kotlin-test-annotations-common")
}
}
jvm("android").compilations["main"].defaultSourceSet {
dependencies {
api("com.squareup.sqldelight:runtime")
}
}
jvm("android").compilations["test"].defaultSourceSet {
dependencies {
implementation("org.jetbrains.kotlin:kotlin-test")
implementation("org.jetbrains.kotlin:kotlin-test-junit")
}
}
}
}
My gradle version is 5.2.1
it might be a gradle compatibility issue. I'll try upgrading our test suite to 5.2.1 and see what happens
I'll try to downgrade to 4.10.2, good luck
^
Done
Gradle 4.10.2 + Android Gradle Plugin 3.3.0 + normal Groovy script produce the same issue
Here is the stack trace in case it help
gradlew common:generateMetadataMainTodoSqlDelightDatabaseInterface --stacktrace
Parallel execution is an incubating feature.
Parallel execution with 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 --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.execution.TaskSelectionException: Task 'generateMetadataMainTodoSqlDelightDatabaseInterface' not found in project ':common'.
at org.gradle.execution.TaskSelector.getSelection(TaskSelector.java:116)
at org.gradle.execution.TaskSelector.getSelection(TaskSelector.java:81)
at org.gradle.execution.commandline.CommandLineTaskParser.parseTasks(CommandLineTaskParser.java:42)
at org.gradle.execution.TaskNameResolvingBuildConfigurationAction.configure(TaskNameResolvingBuildConfigurationAction.java:44)
at org.gradle.execution.DefaultBuildConfigurationActionExecuter.configure(DefaultBuildConfigurationActionExecuter.java:48)
at org.gradle.execution.DefaultBuildConfigurationActionExecuter.access$000(DefaultBuildConfigurationActionExecuter.java:25)
at org.gradle.execution.DefaultBuildConfigurationActionExecuter$1.proceed(DefaultBuildConfigurationActionExecuter.java:54)
at org.gradle.execution.DefaultTasksBuildExecutionAction.configure(DefaultTasksBuildExecutionAction.java:44)
at org.gradle.execution.DefaultBuildConfigurationActionExecuter.configure(DefaultBuildConfigurationActionExecuter.java:48)
at org.gradle.execution.DefaultBuildConfigurationActionExecuter.access$000(DefaultBuildConfigurationActionExecuter.java:25)
at org.gradle.execution.DefaultBuildConfigurationActionExecuter$1.proceed(DefaultBuildConfigurationActionExecuter.java:54)
at org.gradle.execution.ExcludedTaskFilteringBuildConfigurationAction.configure(ExcludedTaskFilteringBuildConfigurationAction.java:47)
at org.gradle.execution.DefaultBuildConfigurationActionExecuter.configure(DefaultBuildConfigurationActionExecuter.java:48)
at org.gradle.execution.DefaultBuildConfigurationActionExecuter.select(DefaultBuildConfigurationActionExecuter.java:36)
at org.gradle.initialization.DefaultGradleLauncher$CalculateTaskGraph.run(DefaultGradleLauncher.java:305)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
at org.gradle.initialization.DefaultGradleLauncher.constructTaskGraph(DefaultGradleLauncher.java:190)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:145)
at org.gradle.initialization.DefaultGradleLauncher.executeTasks(DefaultGradleLauncher.java:124)
at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:77)
at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:74)
at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:154)
at org.gradle.internal.work.StopShieldingWorkerLeaseService.withLocks(StopShieldingWorkerLeaseService.java:38)
at org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:96)
at org.gradle.internal.invocation.GradleBuildController.run(GradleBuildController.java:74)
at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)
at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$3.run(RunAsBuildOperationBuildActionRunner.java:50)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:45)
at org.gradle.tooling.internal.provider.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:51)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$1.transform(InProcessBuildActionExecuter.java:47)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$1.transform(InProcessBuildActionExecuter.java:44)
at org.gradle.composite.internal.DefaultRootBuildState.run(DefaultRootBuildState.java:79)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:44)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:30)
at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:39)
at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:25)
at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:80)
at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:53)
at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:62)
at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:34)
at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36)
at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25)
at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:43)
at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:29)
at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:59)
at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:31)
at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:59)
at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:44)
at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:46)
at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:30)
at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
at org.gradle.util.Swapper.swap(Swapper.java:38)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:62)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:81)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:295)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
In case you need the current project that produces this issue, I thought it would be helpful
https://github.com/nlgtuankiet/todo-sample
My local development has more few commits ahead with the master branch, but you can pretty much start from there.
thanks for linking the project, will be easier to debug from that
do you mind pushing a branch with everything in groovy/gradle4.10.2? will be a bit easier from my end
Done, haven't thought of that, thank for the suggestion
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
Same issue here, reverted to 1.0.3 fttb.
I believe this is due to enabling configure on demand in Gradle which somehow breaks the SQLDelight plugin.
@ansman did the latest release fix this?
Hi,
info on when this issue will be fixed?
Thanks
its caused by enabling configure on demand
did you mean this?
org.gradle.configureondemand=false
Any known solutions?
org.gradle.configureondemand=false doesn't work, tried in terminal and in gradle.properties
@ATizik make sure you don’t have it in ~/.gradle/gradle.properties. It counter intuitively overrides whatever you have in your project config.
Perhaps SQLDelight should throw an error when CoD is detected until it’s been fixed.
@ansman
Tried on OSX and Linux: explicitly added org.gradle.configureondemand=false to ~/.gradle/gradle.properties, still the same missing task
Basically adding sqldelight 1.1.3 to https://github.com/JetBrains/kotlin-mpp-example breaks it.
1.0.3 works fine
@ATizik Just had the same problem. I was trying to run the gradleTask via IntelliJ. I had to go into the IntelliJ Preferences -> Build, Execution, Deployment -> Gradle-Android Compiler and disable Configure On Demand.
@kgonyon
There is no such option in Intellij 2019.1 or Appcode 2019.1, and executing from terminal gives the same missing task
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 use tasks.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 in projectsEvaluated, 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.
Hi all,
Are there good news?
Thanks
org.gradle.configureondemand=false wfm
@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.
It's fixed on master, but theres a bug I'm trying to work through before
doing a release. You can try using the snapshot version
On Sat., Jul. 6, 2019, 5:18 a.m. Franco Sabadini, notifications@github.com
wrote:
@AlecStrong https://github.com/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.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/square/sqldelight/issues/1243?email_source=notifications&email_token=AAMZBQACZYDW67FOGKFNFQDP6BPNTA5CNFSM4G2W5W3KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZKV2EY#issuecomment-508910867,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAMZBQFSDLAHOD54WR5SXSDP6BPNTANCNFSM4G2W5W3A
.
The fix was to not rely on the gradle.projectsEvaluated api
On Sat., Jul. 6, 2019, 9:06 a.m. Alec Strong, anstrong22@gmail.com wrote:
It's fixed on master, but theres a bug I'm trying to work through before
doing a release. You can try using the snapshot versionOn Sat., Jul. 6, 2019, 5:18 a.m. Franco Sabadini, <
[email protected]> wrote:@AlecStrong https://github.com/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.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/square/sqldelight/issues/1243?email_source=notifications&email_token=AAMZBQACZYDW67FOGKFNFQDP6BPNTA5CNFSM4G2W5W3KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZKV2EY#issuecomment-508910867,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAMZBQFSDLAHOD54WR5SXSDP6BPNTANCNFSM4G2W5W3A
.
Most helpful comment
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
projectsEvaluatedto 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
projectsEvaluatedalways invoked after that. Instead we should probably usetasks.whenTaskAddedto 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
afterEvaluateblocks, 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.