I have one task (copyFiles) that copies files and replaces tokens in them. I know how to use the ReplaceTokens filter in a copy task. However, in my case, I have another task (computeValues) that computes the values to use for replacing the tokens and stores them in local variables or project properties. This does not work since the expression in my filter definition is evaluated during the configuration phase and at that time the variables/project properties are not set yet as computeValues has not been executed yet.
Something like this:
def tokenValue
task computeValues << {
tokenValue = ... whatever computation
}
task copyFiles(type: Copy, dependsOn: [computeValues]) {
from("template"){
include "*.sh"
// does not work as tokenValue is still null when this is evaluated
filter(ReplaceTokens, tokens: [myToken: tokenValue])
}
}
Is there a way to achieve what I want?