Showing posts with label gant. Show all posts
Showing posts with label gant. Show all posts

Friday, 20 June 2008

Refactoring GANT

Its quite easy to build complicated GANT scripts - and not much has been written about how to refactor them.

Its not so obvious that you can call other targets directly, and with a bit of care you can re-use some of the built in grails targets like testApp.

The first step is to include anohter script like this:

includeTargets << new File("${basedir}/scripts/OtherScript.groovy")

Note: this does have implications in that you can overwrite variables and targets by including (and it does this silently without warning).

You can then reference another target from your target like this:

target(runMigration: "Run the Migration Tests") {
testMigration()
testApp()
}

There are some caveats however - one being that the useful "testApp" target (provided by grails) has a built in System.exit which causes your entire script to fail. You can get around this by hooking the exit event and storing the error code instead of exiting like this:

target('exit':"override exit") { code ->
// Save the exit code.
testAppExitCode = code
}


While all this does help - there is still a slight "whiff" to gant programming, however some of these tricks can help keep your gant scripts tidier.

Tim

Thursday, 24 April 2008

... and for a possible alternative to Gant

I'm list whoring again... from the groovy-user list, just announced

http://www.gradle.org

Gradle is a build system which provides:
  • Flexible general purpose build tool like Ant.
  • Switchable, build-by-convention frameworks a la Maven. But without lock in
  • Support for multi-project builds.
  • Powerful dependency management (based on Apache Ivy).
  • Full support for your existing Maven or Ivy repository infrastructure
  • Optional support for transitive dependency management without the need for remote repositories and pom.xml or ivy.xml files.
  • Ant tasks as first class citizens.
  • A wrapper to run Gradle builds on machines where Gradle is not installed (e.g. continuous integration server)
  • Groovy build scripts.
Has the usual userguide and docs for this new v2.0 release.

The obvious question.. how does it compare to Gant, is visited here