Reputation: 1081
I'm using the distribution plugin. When I run a gradle build, which depends on gradle assemble, both distTar
and distZip
are triggered, and I end up with both a tarball and a zip file of my distribution. I only need a tarball. running both is time and space consuming (the project distribution is very large).
What would be a clean way to exclude distZip
from a high level gradle build? I know I can use gradle build -x distZip
but I want to run plain gradle build
. I know dependencies can be excluded with build.dependsOn.remove(<name>)
but I saw it described as not-recommended.
Thanks.
Upvotes: 22
Views: 7108
Reputation: 14630
Recipe for build.gradle.kts:
tasks.distZip {
enabled = false
}
tasks.distTar {
enabled = false
}
It's ok if you don't need tar/zip at all, and all what you need is the install
folder to create docker container, for example. Because it's not possible to run this task anymore:
./gradlew distZip
...
> Task :distZip SKIPPED
Upvotes: 0
Reputation: 2123
If you have configured additional distributions like this
distributions {
mySpecialDistribution {
contents {
duplicatesStrategy = 'INCLUDE'
...
}
}
you have to disable the distribution specific task:
mySpecialDistributionDistZip.enabled = false
In order to disable the distZip for all distributions, you can do the following:
gradle.taskGraph.whenReady {
graph -> graph.allTasks.findAll { it.name ==~ /.*DistZip/ }*.enabled = false
}
Upvotes: 0
Reputation: 21
One of our gradle builds has starting failing due to this issue. As mentioned by TmTom above the full solution was
task deleteZip {
configurations.archives.artifacts.removeAll {it.file =~ 'zip'}
}
tasks.install.dependsOn(deleteZip)
If tars are also being troublesome add:
configurations.archives.artifacts.removeAll {it.file =~ 'tar'}
Upvotes: 2