I am trying to set up a multi-project build for a Grails project and want to
use Cargo (cargo-gradle-plugin) to deploy my application to a tomcat
container.

I have made it work by including the following into my main build.gradle
file:

war {
exec {
executable = getGrailsExecutable()
args = ['war']
workingDir = project(':application').projectDir
}
from
zipTree(project(':application').file("target/${applicationName}-${version}.war"))
}

which executes the grails war command in the application sub-project and
then uses the war file to generate a new war file when the war task is
called.

When I run the command cargoRedeployRemote this setup generates a war file
and deploys it to the configured container as expected. However, the war
task is executed upon all other task calls as well.
For example if I run the ./gradlew test gradle will execute my grails war
command before running the tests.

If I change to the following structure the war task is only called when I
specifically call the ./gradlew war task, but this section is never called
when I execute the ./gradlew cargoRedeployRemote task.

war << {
...
}

So my questions are:
1. How do I make my war task to not execute when other tasks (that do not
include the war task in the taskGraph) are called?
2. How can I make my war task to be simpler. I think it is unnecessary that
grails first creates a war file, and then gradle will unpack the war file
and generate a new one.

Thanks

Mathias

Reply via email to