I'm getting the following error when trying to lau...
# gradle
e
I'm getting the following error when trying to launch Node.js tests for a test utilities module (multiplatform)
Copy code
FAILURE: 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
Copy code
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.
It seems tasks are indeed executed in the wrong order No it's the correct one
Copy code
> Task :test-utils:compileKotlinJs UP-TO-DATE
> Task :test-utils:jsTestProcessResources NO-SOURCE
> Task :test-utils:copyResourcesJs FAILED
I've solved it by using
dependsOn
in my convention plugin
Copy code
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