I'm trying to deploy war archive into Tomcat. Here is a build script I've written:
apply plugin : 'war'
task deploy (dependsOn: war){
copy {
from "build/libs"
into "E:/apache-tomcat-8.0.14/webapps"
include "*.war"
}
}
But it has no effect. There is no war
in the root of webapps
. Gradle output:
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:war
:deploy
What's wrong?
Please don't suggest me any tomcat-cargo plugin in order to do that. I just want to know how to fix that particular file-copying task.
The code inside your task runs during the configuration phase, instead of running during the execution phase. It thus runs before the war task has done anything. The task should look like
task deploy (dependsOn: war) << {
...
}
or
task deploy (dependsOn: war) {
doLast {
...
}
}
Or, even better, instead of defining a task which does a copy in an imperative way when executed, you should make your task a Copy task, and configure it:
task deploy (dependsOn: war, type: Copy) {
from "build/libs"
into "E:/apache-tomcat-8.0.14/webapps"
include "*.war"
}
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