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".

smeeb
  • 27,777
  • 57
  • 250
  • 447
  • 2
    Why not create your own Gant script with `create-script`? That's typically what we do with multi-step builds in Grails. – Joshua Moore Oct 12 '15 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`? – smeeb Oct 12 '15 at 14:24

1 Answers1

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.

Community
  • 1
  • 1
Lalit Agarwal
  • 2,354
  • 1
  • 14
  • 18
  • 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! – smeeb Oct 12 '15 at 15:08
  • Added a link to code snippet for running test using gant. https://github.com/jeffbrown/grailsnolib/blob/master/scripts/TestApp.groovy – Lalit Agarwal Oct 12 '15 at 15:34
  • Thanks again - would `_GrailsCodenarc` and `_GrailsLightweight` work here as well? – smeeb Oct 12 '15 at 16:21