libres
libres copied to clipboard
Libres issues "explicit or implicit dependency error" when used with KSP2
(Apologies for lack of repro project, as I'm reporting this bug on behalf of one of my users. I'm the author of https://github.com/varabyte/kobweb, which recently updated to using Google KSP2.)
Error message:
Reason: Task ':app:web:site:kspKotlinJs' uses this output of task ':app:web:site:libresGenerateImages' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
Possible solutions:
1. Declare task ':app:web:site:libresGenerateImages' as an input of ':app:web:site:kspKotlinJs'.
2. Declare an explicit dependency on ':app:web:site:libresGenerateImages' from ':app:web:site:kspKotlinJs' using Task#dependsOn.
3. Declare an explicit dependency on ':app:web:site:libresGenerateImages' from ':app:web:site:kspKotlinJs' using Task#mustRunAfter.
After looking into libres code, we believe the issue is related to this line of code and this block of code
My peer, who is way more Gradle savvy than me, says your approach sets things up in a way that Gradle fails to keep track of the task dependency.
They said, instead of writing code like this:
val outputPath = File(...)
kotlin.srcDir(outputPath)
val resourcesTask = tasks.register(...) { this.output = outputPath }
kotlinCompile.configure { dependsOn(resourcesTask) }
it is better to write code like this:
val outputPath = File(...)
val resourcesTask = tasks.register(...) { this.output = outputPath }
kotlin.srcDir(resourcesTask) // or `kotlin.srcDir(resourcesTask.map { it.srcOutput })`