[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
Related to GRADLE-1298 Change in filtered resource not picke... Resolved

 Description   

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
:processResources
:classes
:jar UP-TO-DATE


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

build.gradle:

apply plugin: 'java'
version = '2.0.0'
processResources

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

I attached the zipped sample project.



 Comments   
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'

processResources

{ 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']
:compileJava
Skipping task ':compileJava' as it is up-to-date.
Skipping task ':compileJava' as it is up-to-date
:compileJava UP-TO-DATE
:processResources
Executing task ':processResources' due to:
Value of input property 'test-attribute' has changed for task ':processResources'
:classes
Skipping task ':classes' as it has no actions.
:jar
Skipping task ':jar' as it is up-to-date.
Skipping task ':jar' as it is up-to-date
:jar UP-TO-DATE

BUILD SUCCESSFUL

Total time: 5.46 secs


HTH

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.