Discussion:
war plugin: Manipulate web.xml on the fly?
Björn Harmen Gerth
2012-01-17 14:39:59 UTC
Permalink
Hello,

my script defines

war {
webXml = file("$rootDir/templates/web.xml")
}

Is it possible to directly manipulate the target web.xml of this copy
process? In my case, I'd like to exchange some placeholders with the
project name. I have tried

eachFile {
...
}

but that does not include web.xml.

Thanks,
Björn
razu
2012-07-06 13:31:15 UTC
Permalink
Hi Björn,

I'm sure you've already resolved your problem, but I had the similar
requirement and I've resolved it in that way:


def webXmlTemplateName = 'WEB-INF/web.xml.template'
def webXmlTemplate = file("$webAppDir/$webXmlTemplateName")
def generatedWebXmlFile = file("$buildDir/web.xml")

processResources << {
def engine = new groovy.text.SimpleTemplateEngine()
generatedWebXmlFile.withWriter { w ->
w <<
engine.createTemplate(webXmlTemplate).make(System.getProperties()).toString()
}
}

war {
excludes = [webXmlTemplateName]
webXml = generatedWebXmlFile
}


in this case properties to resolve are provided from JVM properties.


--
View this message in context: http://gradle.1045684.n5.nabble.com/war-plugin-Manipulate-web-xml-on-the-fly-tp5151767p5709928.html
Sent from the gradle-user mailing list archive at Nabble.com.

Loading...