# Gradle up-to-date false positive with clean + zipTree

**URL:** <https://discuss.gradle.org/t/gradle-up-to-date-false-positive-with-clean-ziptree/20929>\
**Category:** Help/Discuss\
**Created:** [December 23, 2016, 3:42pm UTC](https://discuss.gradle.org/t/gradle-up-to-date-false-positive-with-clean-ziptree/20929 "2016-12-23T15:42:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_R](https://avatars.discourse-cdn.com/v4/letter/m/8e8cbc/32.png) [@Mark\_R](https://discuss.gradle.org/u/Mark_R)\
**Post date:** [December 23, 2016, 3:42pm UTC](https://discuss.gradle.org/t/gradle-up-to-date-false-positive-with-clean-ziptree/20929/1 "2016-12-23T15:42:46Z")

</div>

I am hitting a strange bug with gradle 2.12. My task is being considered up to date when it has input files and I explicitly disabled the up-to-date checking. Given the setup below, running

`gradle doCopy`

works as expected. Running

`gradle clean doCopy`

results in the task always being up-to-date and thus the task is skipped. It appears that [SkipEmptySourceFilesTaskExecuter](https://github.com/gradle/gradle/blob/REL_2.12/subprojects/core/src/main/groovy/org/gradle/api/internal/tasks/execution/SkipEmptySourceFilesTaskExecuter.java) thinks the source files are empty when they are not.

This could be related to [Zip task ignores output when checking if up to date](https://discuss.gradle.org/t/zip-task-ignores-output-when-checking-if-up-to-date/12003) and [GRADLE-2579](https://issues.gradle.org/browse/GRADLE-2579?_ga=1.209989461.1301568040.1473356102)

To reproduce:  
build.gradle:

apply plugin: ‘java’

```
configurations {
	cfg
}

dependencies {
	cfg files("$projectDir/replaceme.zip")
}

task doCopy(type: Copy) {

	outputs.upToDateWhen { false }
	def templates = zipTree(configurations.cfg.singleFile).matching({ "folder/*" }).files;
	println "TEMPLATES: " + templates;
	
	from(templates) {
		include '**/replaceme.json'
		expand([bar: "BBB"])
			
	}
	
	into "$buildDir"
}

```

replaceme.zip/folder/replaceme.json:

```
{
	"foo": ${bar}
}
```

---

<div class="post-metadata">

**Author:** ![Mark\_R](https://avatars.discourse-cdn.com/v4/letter/m/8e8cbc/32.png) [@Mark\_R](https://discuss.gradle.org/u/Mark_R)\
**Post date:** [December 23, 2016, 4:11pm UTC](https://discuss.gradle.org/t/gradle-up-to-date-false-positive-with-clean-ziptree/20929/2 "2016-12-23T16:11:44Z")

</div>

Submitted issue here: [https://github.com/gradle/gradle/issues/1062](https://github.com/gradle/gradle/issues/1062)

---

<div class="post-metadata">

**Author:** ![Lance](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/lance/32/787_2.png) [@Lance](https://discuss.gradle.org/u/Lance)\
**Post date:** [December 23, 2016, 6:28pm UTC](https://discuss.gradle.org/t/gradle-up-to-date-false-positive-with-clean-ziptree/20929/3 "2016-12-23T18:28:54Z")

</div>

I personally think it’s poor form for tasks to write directly to `$buildDir` (for instance [automatic clean tasks](http://mrhaki.blogspot.co.uk/2010/10/gradle-goodness-automatic-clean-tasks.html?m=1) won’t work and up-to-date checks might have issues or do extra work).

Instead each task should use a subfolder under `$buildDir`. Perhaps the problem magically goes away when you do this?

---

<div class="post-metadata">

**Author:** ![st\_oehme](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/st_oehme/32/5249_2.png) [@st\_oehme](https://discuss.gradle.org/u/st_oehme)\
**Post date:** [December 23, 2016, 6:31pm UTC](https://discuss.gradle.org/t/gradle-up-to-date-false-positive-with-clean-ziptree/20929/4 "2016-12-23T18:31:47Z")

</div>

I responded on the Github issue.
