I have the following Gradle task. I’m trying to put my multiplatform outputs into an unpacked WAR directory so I can run it in a Java servlet container in my dev environment. It fails because that last clause (2) puts its files not in $dest/static
but in static
. It also affects the (1) clause, so that it (1) puts its files in static/static
instead of $dest/static
. Anyone know how to write this copy?
task devWar(type: Copy) {
String wildflyHome = "/Dev/Wildfly/wildfly-servlet-18.0.0.Final"
String dest = "${wildflyHome}/standalone/deployments/app1.war"
dependsOn jvmMainClasses, jsMainClasses
from(kotlin.targets.jvm.compilations.main.output.allOutputs.files) {
into "WEB-INF/classes"
}
from(kotlin.targets.jvm.compilations.main.compileDependencyFiles) {
into "WEB-INF/lib"
}
// (1)
from(jsCompilations.main.output) {
exclude "*.scss"
into 'static'
}
// (2) This gets the js files like kotlinx-coroutines-core.js or
// kotlinx-serialization-runtime-js.js. They are in jar files like
// kotlinx-coroutines-core-js-1.2.1.jar
from(provider {
kotlin.targets.js.compilations.main.runtimeDependencyFiles.each {
from zipTree(it.absolutePath).matching {
include '*.js'
into "static"
}
exclude '*.jar'
}
})
from('src/webapp')
into dest
}