I finally resolved this by replacing the file in place before doing the build
(building the war)
Something like this:
war.doFirst {
webInfEnvironment = 'default'
// check if configuration was set.
if (project.hasProperty('deployConfig')) {
processEnvFiles()
webInfEnvironment = targetEnvironment
}
processWebInfFiles(webInfEnvironment)
}
def processWebInfFiles(webInfEnvironment) {
def webInfDir = new
File("${projectDir}${File.separator}src${File.separator}main${File.separator}webapp${File.separator}WEB-INF")
webInfDir.listFiles().each {File file ->
replacementFile = new
File("${file}.${webInfEnvironment}")
if (replacementFile.exists() &&
replacementFile.isFile()) {
logger.debug(Logging.LIFECYCLE, "Overwriting:
${file.name} with
${replacementFile.name}" )
ant.copy(file : replacementFile,
tofile: file,
overwrite : true)
}
}
}
This far from ideal, since every file is evaluated for a possible
replacement and it's impossible to tell whether not having one should
trigger an error, so a missing file might leave an unexpected file in the
build.
A list of "to be replaced" files could be put somewhere to make this
behavior more predictable.
Also you need a .default version of every configured file, since the
original file gets replaced with every build.
Federico
--
View this message in context:
http://old.nabble.com/WAR---per-environment-configuration-tp27693855p27722429.html
Sent from the gradle-user mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email