distZip always UP-TO-DATE with exclude

I am trying to assemble a simple ZIP for distribution for myprog with two customizations: (1) I want myprog.jar in bin, not lib; and (2) I do not want the bin/myprog and bin/myprog.bat (I have my own script).

Whenever I add

exclude {

to distributions or distZip, I’m told :distZip is UP-TO-DATE, even with the --rerun-tasks flag, and even after I’ve run clean. My targets won’t run if exclude{} is included.

As for putting myprog.jar in bin, I’m still trying to figure that out, too. Again, the UP-TO-DATE stuff foils me, even after clean.

I’m using Gradle 2.14.1. I’ve not seen a need the constant stream of new features for my other apps, nor have time to keep up with them (and saw too many things break between 2.0 and 2.14).

This seems to imply that after the excludes are taken into account there’s no longer any files to zip. If you remove the excludes is the distZip task still up to date? If not, what files are in the generated zip?

No. If I remove the excludes, the target zip is created. The zip includes more than the two generated scripts. The zip includes the JAR I built, the dozen or so JARs that my program depends on, items I requested with

from('src/site') {
  into "bin"

and other files. But with exclude, nothing is built, even when myprog.zip has been deleted with gradle clean and I use the --rerun-tasks flag. How can a target be UP-TO-DATE when its result does not exist? It seems that excluding these script files excludes everything.

I just tested this problem with Gradle 4.4.1 with the same result: If exclude is used in distributions or distZip, build/distributions is not created.

Any thoughts or ideas on this issue?

I have created a repo that demonstrates the problem: https://github.com/johnthad/gradle-bug

(But in the meanwhile, I’ve written a Maven pom.xml for my app.)

You probably wish to utilize one of the other exclude methods such as:
exclude ‘/bin/gradle-bug’, '/bin/gradle-bug.bat’
exclude [’/bin/gradle-bug’, '/bin/gradle-bug.bat’]

CopySpec.exclude(Closure) is the one you are currently utilizing, and it has completely different behavior from most of the other exclude methods – especially the ant-based pattern methods that you likely wish to be using.

That exclude method evaluates the closure where the return value is being checked for true or false for every filename being passed in for exclusion purposes, and ‘**/bin/gradle-bug.bat’ will get coerced into true every time. This is why it believes that it is always up-to-date and thinks there is nothing to do.


1 Like


exclude 'gradle-bug', 'gradle-bug.bat'

works. Thank you.