I am trying to create a Zip task that would create a distribution package for my project that contains project jar files and war (and potentially other build artifacts produced by the assemble
task).
So I tried writing this simple script
task dist(dependsOn: 'assemble', type: Zip){
into('lib'){
from 'build/libs' //contains jar and war files
}
... //other stuff
}
Task dist
depends on assemble
because it conveniently includes the tasks that create jar and war files.
But if I try to execute that, gradle complains with this error message:
Circular dependency between tasks. Cycle includes [task ':assemble', task ':dist'].
I've checked out the specification for assemble
task, and it is clearly written that assemble
task automatically dependsOn
all archive tasks in the project, which obviously includes my dist
task. And there seems to be no way to get around it.
What would be the correct way of doing this in gradle? How can I make a zip task that depends on assemble
task? I could make dist
task explicitly depend on jar
and war
tasks, but I think that kind of violates encapsulation a bit.
I am using gradle-1.0-milestone-3.
Thanks in advance!
here is a complete example to depend your Zip on the jar and the war task:
task dist(type:Zip){
from jar.outputs.files
from war.outputs.files
}
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