My environment: Grails v2.1.1
I need to run a small utility application during the war process. This application generates files that I want to include in my war file. I tried to put the code in BuildConfig.groovy grails.war.resources, but I do not see the errors or files that I expect to create.
Does anyone know how I can run this utility application so that its output is in my war?
This is the command executed inside the terminal instance:
sencha app build -e production -d $stagingDir/production
Here is my attempt to run it through grails.war.resourcesin BuildConfig.groovy:
grails.war.resources = { stagingDir ->
echo(message:'executing grails.war.resources')
def outputDir = new File("${stagingDir.getParentFile().getPath()}/target/ranForReal")
def command = """sencha app build -e testing -d ${outputDir.getPath()}"""
def executionDir = new File("${stagingDir.getParentFile().getPath()}/web-app")
def proc = command.execute(null,executionDir)
proc.waitFor()
def x = 1/0
println "return code: ${ proc.exitValue()}"
println "stderr: ${proc.err.text}"
println "stdout: ${proc.in.text}"
for (name in ['servlet']) {
delete {
fileset dir: "$stagingDir/WEB-INF/lib/",
includes: "$name*.jar"
}
}
}
Is there a grails.war.resourcestransition method?
Update
For posterity, here is my somewhat complicated example using the answer below.
from _Events.groovyfile
eventCreateWarStart = {warName, stagingDir ->
def senchaEnvironment = argsMap["sencha.env"] ?: 'testing'
println "running sencha optimizer code for $senchaEnvironment environment..."
ant.exec(outputproperty: "cmdOut", executable:'sencha',
dir:"$stagingDir",failOnError:true){
arg(value:'app')
arg(value:'build')
arg(value:"-e $senchaEnvironment" )
}
println "${ant.project.properties.cmdOut}"
println'completed sencha optimization process.'
}
source
share