Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8595719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:30:20+00:00 2026-06-12T00:30:20+00:00

My environment: Grails v2.1.1 I need to run a small utility app during the

  • 0

My environment: Grails v2.1.1

I need to run a small utility app during the war process. This app generates files that I want included in my war file. I’ve tried putting code in BuildConfig.groovy’s grails.war.resources, but I’m not seeing an error, or the files I am expecting to be created.

Does anyone know how I can execute this utility app so that its output is in my war?

This is the command as run inside a terminal instance:

sencha app build -e production -d $stagingDir/production

Here’s my attempt to run it via grails.war.resources in BuildConfig.groovy:

grails.war.resources = { stagingDir ->

//calling echo() does nothing.  I don't see the comment in the build output
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()

//my desperate attempt to see if anything is happening.  I'd expect an error here
def x = 1/0

// Obtain status and output
println "return code: ${ proc.exitValue()}"
println "stderr: ${proc.err.text}"
println "stdout: ${proc.in.text}" // *out* from the external program is *in* for groovy

//this for loop does work and does remove servlet jars, so I know this closure is called.
for (name in ['servlet']) {
    delete {
        fileset dir: "$stagingDir/WEB-INF/lib/",
                includes: "$name*.jar"
    }
}

}

Is grails.war.resources the way to go?

Update

For posterity, here is my somewhat complex example, using the answer below.

from _Events.groovy file

/**
 * Generate an optimized version of the sencha app.
 */
eventCreateWarStart = {warName, stagingDir ->
    //argsMap contains params from command line, e.g 'war --sencha.env=production'
def senchaEnvironment = argsMap["sencha.env"] ?: 'testing'

    //println is the only way I've found to write to the console.
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.'

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:30:22+00:00Added an answer on June 12, 2026 at 12:30 am

    You can put an eventCreateWarStart in your scripts/_Events.groovy. This event receives two parameters, the name of the WAR and the stagingDir

    eventCreateWarStart = { warName, stagingDir ->
      // ..
    }
    

    You have access to the ant variable giving you an AntBuilder so you can do stuff like

    ant.exec(executable:'sencha') {
      arg(value:'app')
      arg(value:'build')
      // ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I generate the war in my grails app via right-click / run grails
In a unix environment, I want the .grails folder to go somewhere other than
Every time that I start up my grails application, using the production environment on
Environment Grails 2.0.4 OC4j 10.1.3 Problem I cannot deploy an grails war file when
I have a grails app that I am trying to deploy onto Tomcat. I
In my Config.groovy I consolidate properties files in the following way: grails.config.locations << file:${userHome}/environment.properties
When I copy my app to a different machine and do 'grails run-app' grails
Can I run a Grails war under Tomcat in a machine without JDK (Only
I love how grails has environment dependent checking available so I can run certain
ENVIRONMENT: C# I have a table of equivalent values, like this: CHEVR = CHEVROLET

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.