I have a hierarchical gradle 3.1 project, which looks like this:
root
- build.gradle
- settings.gradle
- server (Java + WAR plugin)
- build.gradle
- client (Node plugin)
- build.gradle
The settings.gradle
therefore looks like this:
include ':server', ':client'
What I would like to do now is to bundle the output of the :client:build
task in the *.war
file produced by the :server:war
task. To do so, I need a dependency from :server:war
to :client:build
in order to ensure that the output files of :client:build
are always present when I need to copy them in the :server:war
task.
The question is: how does this work?
What I want to achieve here: whenever :server:war
is executed, :client:build
gets executed first.
// in server/build.gradle
task war {
dependsOn ':client:build'
}
I also tried:
// in server/build.gradle
war.dependsOn = ':client:build'
... and also:
// in server/build.gradle
task war(dependsOn: ':client:build') {
}
None of the attempts above works. Any idea what I am doing wrong?
The subproject producer defines a task named buildInfo that generates a properties file containing build information e.g. the project version. You can then map the task provider to its output file and Gradle will automatically establish a task dependency. Example 2.
Please try just:
war.dependsOn ':client:build'
and:
task war {
dependsOn ':client:build'
}
defines a new task called war
and:
war.dependsOn = ':client:build'
theoretically calls this method but the argument has wrong type
and:
task war(dependsOn: ':client:build') {
}
here you define a new task as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With