Zip Task Claims to be Up-to-Date On come Systems

I have the following basic zip task:

project.tasks.create(name:'zipBuildArtifacts', type:Zip) {
            outputs.upToDateWhen { false }
            dependsOn 'build'
            from project.files((new File("${project.buildDir}/temp/jboss/foo/deployments/folder1/folder2/jarFolder").listFiles().findAll{"")}))

On several systems, this works perfectly. It finds the file and always creates the zip. On other systems it always claims to be up-to-date. I added the following listener to make sure the data was there on the system before the call to execute the task

void beforeExecute(Task task) {
                if( == 'zipBuildArtifacts'){
                    println "beforeExecute of $task"
                    def list = []
                    def results = new File("${project.buildDir}/temp/jboss/foo/deployments/folder1/folder2/jarFolder").listFiles().findAll{"")}
                                                      println 'list'
                    println results
                    println 'end list'
                                          println 'inputs:'
                    task.inputs.getFiles().each{println it}
                    println "end of beforeExecute of $task"

On the system that fails I get the following:

beforeExecute of task ':zipBuildArtifacts'
[D:\Builds\build\components\compoennt1\temp\jboss\foo\deployments\folder1\folder2\jarFolder\, D:\Builds\build\components\compoennt1\temp\jboss\foo\deployments\folder1\folder2\jarFolder\, D:\Builds\build\components\compoennt1\temp\jboss\foo\deployments\folder1\folder2\jarFolder\
end list
end of beforeExecute of task ':zipBuildArtifacts'

So the files are there, and it clearly finds the files before it tried to execute the task but it is telling me:

Skipping task ':zipBuildArtifacts' as it has no source files.

Any idea why this would be system dependent? Both systems are windows. The working system runs from command line while the failing system is run through Jenkins, but both systems are using the wrapper.

For one thing, the code is scanning the filesystem for files to be copied in the configuration phase (i.e. before any task has run), which is probably not what you want. Instead, the ‘from’ should only name the top-level source directory for the copy operation, and an ‘include’ filter should be added. Also, the task should depend on the tasks creating the artifacts, not on ‘build’.

In an attempt to simplify the code for the form I renamed some tasks. 'Build" was not the best name. To clarify, that does represent the task which generates the artifacts. I’ve converted the task to use includes which is much simpler.

Still curious why the previous solution worked on one system but not another. Thanks for the help and fast response.

The task was configured in such a way that it would base the decision which files to copy on the results of a previous build. Hence it wouldn’t have worked on systems that didn’t have any artifacts from previous builds in that directory. The ‘printlns’ were misleading because they were executing at a later time, when the ‘build’ task had already run.