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

**URL:** <https://discuss.gradle.org/t/zip-task-claims-to-be-up-to-date-on-come-systems/5787>\
**Category:** Old Forum Archive\
**Created:** [May 29, 2014, 6:34pm UTC](https://discuss.gradle.org/t/zip-task-claims-to-be-up-to-date-on-come-systems/5787 "2014-05-29T18:34:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin\_O\_Neal](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/kevin_o_neal/32/917_2.png) [@Kevin\_O\_Neal](https://discuss.gradle.org/u/Kevin_O_Neal)\
**Post date:** [May 29, 2014, 6:34pm UTC](https://discuss.gradle.org/t/zip-task-claims-to-be-up-to-date-on-come-systems/5787/1 "2014-05-29T18:34:00Z")

</div>

I have the following basic zip task:

```gradle
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{it.name.startsWith("com.company.product")}))
        }

```

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

```gradle
void beforeExecute(Task task) {
                if(task.name == 'zipBuildArtifacts'){
                    println "beforeExecute of $task"
                    def list = []
                    def results = new File("${project.buildDir}/temp/jboss/foo/deployments/folder1/folder2/jarFolder").listFiles().findAll{it.name.startsWith("com.company.product")}
                                                      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:

```gradle
:zipBuildArtifacts
beforeExecute of task ':zipBuildArtifacts'
list
[D:\Builds\build\components\compoennt1\temp\jboss\foo\deployments\folder1\folder2\jarFolder\com.company.product.feature1.jar, D:\Builds\build\components\compoennt1\temp\jboss\foo\deployments\folder1\folder2\jarFolder\com.company.product.feature2.jar, D:\Builds\build\components\compoennt1\temp\jboss\foo\deployments\folder1\folder2\jarFolder\com.company.product.feature3.jar
...]
end list
inputs:
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:

```gradle
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.

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [May 29, 2014, 6:46pm UTC](https://discuss.gradle.org/t/zip-task-claims-to-be-up-to-date-on-come-systems/5787/2 "2014-05-29T18:46:00Z")

</div>

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’.

---

<div class="post-metadata">

**Author:** ![Kevin\_O\_Neal](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/kevin_o_neal/32/917_2.png) [@Kevin\_O\_Neal](https://discuss.gradle.org/u/Kevin_O_Neal)\
**Post date:** [May 29, 2014, 9:02pm UTC](https://discuss.gradle.org/t/zip-task-claims-to-be-up-to-date-on-come-systems/5787/3 "2014-05-29T21:02:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [May 29, 2014, 9:10pm UTC](https://discuss.gradle.org/t/zip-task-claims-to-be-up-to-date-on-come-systems/5787/4 "2014-05-29T21:10:00Z")

</div>

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.
