Edoardo Luppi
08/15/2023, 10:22 AMFAILURE: Build failed with an exception.
* What went wrong:
A problem was found with the configuration of task ':test-utils:copyResourcesJs' (type 'Copy').
- Gradle detected a problem with the following location: 'C:\Users\edoardo.luppi\IdeaProjects\...\modules\test-utils'.
Reason: Task ':test-utils:copyResourcesJs' uses this output of task ':test-utils:compileKotlinJs' 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 ':test-utils:compileKotlinJs' as an input of ':test-utils:copyResourcesJs'.
2. Declare an explicit dependency on ':test-utils:compileKotlinJs' from ':test-utils:copyResourcesJs' using Task#dependsOn.
3. Declare an explicit dependency on ':test-utils:compileKotlinJs' from ':test-utils:copyResourcesJs' using Task#mustRunAfter.
The test-utils
module setup is really straightforward
kotlin {
jvmToolchain(11)
sourceSets {
getByName("commonMain") {
dependencies {
implementation(kotlin("test"))
implementation(libs.kotlinx.coroutines.test)
implementation(libs.kotlinx.resources)
implementation(libs.kotlinx.io.core)
implementation(project(":proto"))
}
}
}
}
Other modules do not have this issue, that's the strange part.Edoardo Luppi
08/15/2023, 10:28 AM> Task :test-utils:compileKotlinJs UP-TO-DATE
> Task :test-utils:jsTestProcessResources NO-SOURCE
> Task :test-utils:copyResourcesJs FAILED
Edoardo Luppi
08/15/2023, 11:40 AMdependsOn
in my convention plugin
class MyModulePlugin : Plugin<Project> {
override fun apply(project: Project) {
// Workaround for task ordering
project.tasks.configureEach {
if (name == "copyResourcesJs") {
dependsOn("compileKotlinJs", "jsProcessResources")
}
}
...
Although there might be a more elegant way to do it that I'm not aware of