We're using a gradle file to build a Java WAR file. I know very little about gradle. At the top of build.gradle:
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'war'
We run the gradle with gradle clean install
. I'm not sure where these tasks are defined but I assume they're in one of the plugins (I'd guess war
).
When I run gradle clean install
it seems to print the tasks that it are run:
:clean
:compileJava
:processResources
:classes
:war
:install
Correct me if I'm wrong, but it seems that the task install
dependsOn compileJava
, processResources
, classes
, and war
.
I need a task I've written to run sometime after clean
but sometime before war
. Preferably without modifying the plugin.
I've tried indicating that my task mustRunAfter processResources
but it doesn't work that way.
How can I inject my task as a dependency on install
before the dependency war
?
You can declare task dependencies explicitly.
Add following code to your build.gradle
file
tasks.war.dependsOn("yourTaskNameHere")
tasks["yourTaskNameHere"].dependsOn("clean")
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