[GRADLE-2096] jar Task of the Java Plugin has incorrect up-to-date check Created: 10/Feb/12  Updated: 04/Jan/13  Resolved: 02/Mar/12

Status: Resolved
Project: Gradle
Affects Version/s: 1.0-milestone-7
Fix Version/s: 1.0-rc-1

Type: Bug
Reporter: Stefan Sieber Assignee: Unassigned
Resolution: Fixed Votes: 0

Attachments: Zip Archive jarBugTest-v2.zip    
Issue Links:
Related to GRADLE-1298 Change in filtered resource not picke... Resolved


When changing filtered Resources, the Jar task's up-to-date check doesn't always work. When the version variable changes in the example below, processResources is executed correctly (content of the file in build/resources changes), but the jar - task says it's up-to-date:

$ gradle jar
:compileJava UP-TO-DATE

The up-to-date doesn't always fail, but after trying it a few times, it should


apply plugin: 'java'
version = '2.0.0'

{ inputs.property('version', project.version) filter (org.apache.tools.ant.filters.ReplaceTokens, tokens: ['project.version': project.version]) }

I attached the zipped sample project.

Comment by Peter Niederwieser [ 11/Feb/12 ]

Works fine for me; I never see the Jar task up-to-date after changing the version. Can you attach the output of gradle -v and gradle -i jar?

Comment by Stefan Sieber [ 13/Feb/12 ]

Sorry I just noticed that the first example works, because the version number is in the file name. I tried it by switching the version number back and forth. The check failed whenever I used a version number that already existed.

I changed the example (jarBugTest-v2.zip) to use another attribute than the version number (bar):

apply plugin: 'java'

version = '2.0.5'

bar = '5'


{ inputs.property('test-attribute', bar) filter (org.apache.tools.ant.filters.ReplaceTokens, tokens: ['bar': bar]) }

The first time the build runs, the jar is generated correctly (with foo.properties having the filter applied). After changing the value of bar, the jar task says that the jar is up to date. Here are my log outputs:

C:\Temp\jarBugTest>gradle -v

Gradle 1.0-milestone-7

Gradle build time: Donnerstag, 5. Januar 2012 10:24 Uhr UTC
Groovy: 1.8.4
Ant: Apache Ant(TM) version 1.8.2 compiled on December 20 2010
Ivy: 2.2.0
JVM: 1.6.0_22 (Sun Microsystems Inc. 17.1-b03)
OS: Windows 7 6.1 amd64

C:\Temp\jarBugTest>gradle jar -i
Starting Build
Settings evaluated using empty settings file.
Projects loaded. Root project using build file 'C:\Temp\jarBugTest\build.gradle'.
Included projects: [root project 'jarBugTest']
Evaluating root project 'jarBugTest' using build file 'C:\Temp\jarBugTest\build.gradle'.
Compiling build file 'C:\Temp\jarBugTest\build.gradle' using BuildScriptClasspathScriptTransformer.
Compiling build file 'C:\Temp\jarBugTest\build.gradle' using BuildScriptTransformer.
All projects evaluated.
Selected primary task 'jar'
Tasks to be executed: [task ':compileJava', task ':processResources', task ':classes', task ':jar']
Skipping task ':compileJava' as it is up-to-date.
Skipping task ':compileJava' as it is up-to-date
:compileJava UP-TO-DATE
Executing task ':processResources' due to:
Value of input property 'test-attribute' has changed for task ':processResources'
Skipping task ':classes' as it has no actions.
Skipping task ':jar' as it is up-to-date.
Skipping task ':jar' as it is up-to-date


Total time: 5.46 secs


Comment by René Gröschke (Inactive) [ 23/Feb/12 ]

I've digged a bit into this problem. It seems that our state caching for files has problems when the lastModified attribute and the size of the file itself hasn't changed. Though I would have expected to see a different timestamp for the modified file.

Generated at Wed Jun 30 12:12:42 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.