Files processed with ReplaceTokens are still considered up-to-date if the value of one of the placeholder changes


(maillist.colin) #1

Hi,

given the following tasks:

task createProperty(type: Copy) {
  from "configuration"
  into "$buildDir/configuration"
  filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: project.ext.getProperties())

and given the following gradle.properties content in my project directory:

myProperty=aValue

and given the following content for a file located in configuration directory:

config.myProperty=@myProperty@

When I run for the first time the tasks, the content of the file generated will rightfully replace the placeholder by “aValue”.

But if afterward, I edit gradle.properties to change the value or use the -P command line options like -PmyProperty=anotherValue, gradle will go over the task saying that it is up-to-date and will not rewrite the value in the target configuration file.

The only workaround I have is to specified --rerun-tasks on the command line.

I am probably doing something wrong, but I cannot find what …

By the way I’m using gradle 1.9.


(Luke Daley) #2

This is a long standing issue: GRADLE-1646

The workaround is to explicitly register your inputs.

createProperty {
  inputs.properties project.ext.getProperties()
}

(maillist.colin) #3

Thanks it works perfectly.