Caveat emperor: New to gradle. Did some RTFM and googled but can’t seem to find the answer wrt what I’m doing wrong. Part of a script to create a war and bundle it with a tomcat server. All seems to work except for deleting of a certain directory.
task dist(type: Zip, dependsOn: ‘extract’) {
description = “Build distribution ZIP”
setArchiveName("ourDistribution.zip")
from "${distsDir}/unpacked"
into ('.')
delete "${distsDir}/unpacked" // does NOT delete the unpacked directory
}
A workaround which does work in this case because delete is called last in the dist task.
task dist(type: Zip, dependsOn: ‘extract’) {
description = “Build distribution ZIP”
setArchiveName("ourDistriubion.zip")
from "${distsDir}/unpacked"
into ('.')
}
dist.doLast {
delete “${distsDir}/unpacked”
}
Note: I’ve also tried replacing delete with project.delete ("${distsDir}/unpacked") to no avail. Like delete it does not work in situation 1 but works with the .doLast.
I’m running it with gradlew dist (using 2.12 of the wrapper). I’m very interested in what I’m doing wrong and why the delete command does not do what I expected it to do in the first example and why it does work with the doLast.
Also setArchiveName sets the name of the distribution. The zip task/plugin does only have a archiveName property. The API documentation however mentions a setArchiveName method.Is this the correct way of setting the name of the zip file?