task deployDataSource(type: Copy) {
println "testenv is ${testEnv}"
outputs.upToDateWhen {
println "Is this even being called?"
false
}
from project(':Library').files("build/install/${testEnv}/my-ds.xml")
into "${jbossHome}/server/default/deploy/my-ds.xml"
}
Here’s what happens when I run the task
% gradle -deployDataSource
Note: the Gradle build daemon is an experimental feature.
As such, you may experience unexpected build failures. You may need to occasionally stop the daemon.
testenv is 'qa'
:webapp:MyApp:deployDataSource UP-TO-DATE
I added outputs.upToDateWhen closure in order to try to force the Copy task to run, because the task was thinking it was up-to-date when it wasn’t (IE, the target file does not exist), but it appears my closure is not being run because I don’t see my println statement logged in the log output.
Yes, as it turns out, I was doing something brain-dead stupid and just needed to take a break and come back again with a fresh pair of eyes.
The issu was that I was incorrectly setting a project property in my gradle.properties file:
testEnv=‘qa’
I didn’t need the quotes. This property was used to build up the path to the from setting in my copy task. Because the path was wrong, there was nothing to copy, which is why it was always getting marked as UP-TO-DATE. And, there was no need to call my upToDateWhen closure. When I removed the quotes, everything was working again.
Ran into this as well. And “Skipped” is not good enough for us, we need our build to fail if the files that need copying are not copied because our input path is wrong.
I am also being bit in the buns by this. I have an environment specific config file that I need to add to a JAR file. I have been trying to get this to work:
However, when the ‘config’ file above does not exist the copy task thinks it’s ‘UP-TO-DATE’ and I end up with no properties files in my JAR. This is pretty frustrating. Any work around?