JavaExec isn't up-to-date when it should be

issue-resolved
gradle-3528

(Ethan Hall) #1

It looks like when I have a JavaExec task, the task is never up-to-date. I tried doing what was suggested in https://issues.gradle.org/browse/GRADLE-35281 but it doesn’t seem to be working.

I have a gist with the example that I’m running into https://gist.github.com/ethankhall/4c62e880efab24bd6a522f068be0501d.

I expect the generateExample task to be up to date after the first run.

When on Gradle 3.0 I get Value of input property 'environment' has changed for task ':generateExample' which lead me to GRADLE-35281.

If I add task.environment = [:] I get a different message: Output property '$1' file /Users/ethall/temp/output.txt has changed.

If I move back to 2.14.1 I get Output file /Users/ethall/temp/output.txt has changed.


(Chris Doré) #2

There’s a bug in your example which is causing the output file to always be “modified”. This line:

def output = new FileOutputStream(outputFile)

causes the output file’s content to be cleared during configuration of the task. So Gradle is always seeing it as a different file than what was hashed after the previous task execution.