On Sat, Feb 27, 2010 at 03:57, Nacho Coloma <[email protected]> wrote:
> Hi Federico,
>
> ${File.separator} is not needed, java.io.File will handle '/' no matter the
> OS.
>
> On the other hand, I would think again if there are not better
> alternatives to this. I used to prepare war files like you are doing,
> and it's a headache. There are better alternatives, like using -D to
> specify the environment you are interested in at runtime.
>
> Just a suggestion.
>
> On Fri, Feb 26, 2010 at 8:30 PM, Federico Schroder <[email protected]>
> wrote:
>>
>> 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
>> --
If you're using Gradle 0.9 the archive tasks use the same API as the
copy tasks, so you could do an in-place filter as you build the war
--
Jason Porter
Real Programmers think better when playing Adventure or Rogue.
PGP key id: 926CCFF5
PGP fingerprint: 64C2 C078 13A9 5B23 7738 F7E5 1046 C39B 926C CFF5
PGP key available at: keyserver.net, pgp.mit.edu
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email