0

Grails 2.4.5 here. Currently I use several Grails plugins with my Grails app, and doing a "full" local build requires me to run several Grails commands in a row:

// 1.
grails clean
grails refresh-dependencies

// 2. Codenarc
grails codenarc

// 3. Run unit tests
grails test-app -unit

// 4. If all pass, then build with lightweight deployer plugin
grails lightweight --artifactName=myapp

I would like to know if there's a way to (perhaps in BuildConfig) federate all of these separate invocations into a single buildAll command, and fail the build if any one of them throws BuildExceptions along the way (all of them do if there are problems).

Ideally it would be great if I could just do:

grails buildAll

And accomplish all of the 4 steps above each time.

Note: If you're all like "Dude, you shouldn't have to refresh-dependencies each time, brah" then I'm all like "Dude, there's some major bugs in 1+ of the plugins that I'm using, so yes I do, brah".

2
  • 2
    Why not create your own Gant script with create-script? That's typically what we do with multi-step builds in Grails. Commented Oct 12, 2015 at 14:20
  • Probably because I didn't know about it @JoshuaMoore (+1) ! So according to the docs I do grails create-script buildAll which creates src/main/srcipts/buildAll.groovy. But then how do I define those other Grails commands inside buildAll.groovy? Commented Oct 12, 2015 at 14:24

1 Answer 1

1

Open your grails installation folder (GRAILS_HOME/grails/scripts). Within the scripts folder you will find many scripts which internally are using each other. Something like below.

includeTargets << grailsScript("_GrailsInit")
includeTargets << grailsScript("_GrailsClasspath")
includeTargets << grailsScript("_GrailsRun")

You could also execute the scripts in similar way from your script.

For running tests look at some code snippet here.

This SO link here should also help.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks @Lalit Agarwal (+1) - but I'm still not seeing the connection between grails test-app -unit and includeTargets << grailsScript("_GrailsRun")...any ideas here?!? Thanks again!
Added a link to code snippet for running test using gant. github.com/jeffbrown/grailsnolib/blob/master/scripts/…
Thanks again - would _GrailsCodenarc and _GrailsLightweight work here as well?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.