This gradle tasks works correctly, I can see the f...
# gradle
j
This gradle tasks works correctly, I can see the file at the
into
location
Copy code
tasks.register<Copy>("copyIosTestResources") {
    from("src/commonTest/resources")
    into("build/bin/iosX64/debugTest/resources")
}

tasks.findByName("iosX64Test")!!.dependsOn("copyIosTestResources")
But if I try to do the same for my js target with this
Copy code
tasks.register<Copy>("copyJsTestResources") {
    from("src/commonTest/resources")
    into("build/js/test/resources")
}

tasks.findByName("jsTest")!!.dependsOn("copyJsTestResources")
I tried a bunch of different values for
into
but it doesn’t seem to work at all. Any idea why?
j
jsTest exists?
j
I have no idea hehe, first time targeting it. If I try “js2Test” I get an error saying
java.lang.NullPointerException
so I supposed “jsTest” was the correct name
I can run
./gradlew jsTest
so I suppose it does exists yes
v
If I interpret your code correctly, your tasks copy files into the output directory is another task. This is a big no-go anyway. Tasks should never have overlapping outputs.
j
I did this for android and ios target, it works well. I’m just trying to find a way to support js target too https://developer.squareup.com/blog/kotlin-multiplatform-shared-test-resources/
v
It might seem to work well, but it doesn't. Especially regarding up-to-date checks and if you use build output cache. You will end up with strange build behavior and hard to debug issues if tasks have overlapping outputs, as well as some more sophisticated Gradle features being disabled if Gradle detects it.
j
So what solution do you advocate to share test resources? Have them hardcoded in
commonTest
directly?
v
I'm not familiar with KMP builds, sorry.
But hardcoded sounds not good either, no
j
@vgonda you wrote the article I linked, do you have any recommendations?
v
Sorry, I don't 😞