Any ideas how to convert this Groovy snippet to Gr...
# gradle
d
Any ideas how to convert this Groovy snippet to Gradle 8.5 Kotlin DSL, for a WAR project ?
Copy code
task explodedWar(type: Sync) {
    into "${buildDir}/libs/exploded/yourWar.war"
    with war
}

// my efforts get to
tasks.register<Sync>("explodedWar") {
    into("${layout.buildDirectory}/libs/exploded/yourWar.war")
    with(war)
    //   ^^^ --- red error markers
}

// can't find anything with the correct type on content assist
It wants a
CopySpec
which I assume needs to be all the standard outputs in the WAR tree format There is an implicit configuration called
archives
that produces the non-exploded WAR file. So this must clear have configuration with all the data in some format necessary (input file -> output file, mappings) Without the
with()
part, nothing appears to happen, I also don't get the default configuration action for
archives
anymore, when really I would like it to always emit the standard output artifacts, but in addition produce an exploded.
s
v
The
war
you marked is in Groovy DSL simply a reference to the task called
war
that in itself is also a
CopySpec
. So what you are after should be
with(tasks.war.get())
d
That is the one, all I could find in research are many-many versions using Groovy, For anyone following I have it working as:
Copy code
tasks.register<Copy>("explodedWar") {
    into(layout.buildDirectory.dir("libs/exploded"))
    with(tasks.war.get())
}
Thanks for the replies.
v
-
Copy
+`Sync`
You seldomly want a
Copy
task you practically always want
Sync
d
Ah thanks for that tip as well. Now I have the recipe to get output, just battling with the exact layout I am after in final EAR/WAR/etc.. for development deployment on the specific app-server from IDEA. Was going to circle back (after it is working) to understand Copy/Sync better. But currently reading up on 'configurations' and 'artifacts' as trying to exclude the exploded from the configuration="artifacts", and only have contents appear for configuration="exploded". In Ear using
deploy(path=":war", configuration="exploded")
and want to allow switching there as well. Expecting "artifacts" to be the standard single file *.war, while "exploded" to be the entire contents of the libs/exploded directory. Then a toplevel gradle.properties to globally disable for CI.