Ben Northrop


Decisions and software development


A quick look at Groovy builds with Gant


April 29th, 2008


I've been looking into Groovy lately, and I'm really impressed. The language is powerful but concise, the tool support and documentation seems good and getting better, and the community is growing. The problem is, in an enterprise environment, I have no idea where it actually fits in. I don't think it makes sense using it for any large-scale system, at least for now - weak typing scares me in team environments...and in general it's just too bleading edge. So what else?

Well...I recently read Groovy-powered automated builds with Gant, and I think the case here is strong. Groovy could make a lot of sense as a replacement or complement to Ant. After a few hours of playing around with Groovy, Gant, and AntBuilder, here's my humble assessment.

Advantages

Disadvantages

When to Use

When *not* to Use

Resources

Hello World - Ant vs. Gant


// Ant
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="E" default="compile" basedir="." >

<target name="compile" depends="init">
  <mkdir dir="classes/" />
  <javac srcdir="src/" destdir="classes/">
    <classpath>
      <pathelement location="lib/log4j.jar"/>
    </classpath>
  </javac>
  <copy todir="classes/" file="src/log4j.properties" />
</target>

<target name="jar" depends="init, compile" >
  <jar jarfile="lib/e.jar" basedir="classes/" includes="**/**" />
</target>

<target name="clean" depends="init" >
  <delete failonerror="true" dir="classes/"/>
</target>
</project>

// Gant
target (clean: "Clean") {
  Ant.delete(failonerror: false, dir: "classes/")
}

target (compile: "Compile") {
   Ant.mkdir(dir: "classes/")
   def javaCompileClasspath = Ant.path {
     pathelement(location: "lib/log4j.jar")
   }
   Ant.javac(destdir: "classes/", srcdir: "src/",
    classpath: javaCompileClasspath)
   Ant.copy (todir: "classes/",
      file: "src/log4j.properties" )
}

target (jar: "Jar") {
  depends(clean, compile);
  Ant.jar(jarfile: "lib/e.jar",
      basedir: "classes/", includes: "**/**")
} setDefaultTarget(compile)

I believe that software development is fundamentally about making decisions, and so this is what I write about (mostly). I've been building software for about 20 years now, as a developer, tech lead, and architect. I have two degrees from Carnegie Mellon University, most recently one in philosophy (thesis here). I live in Pittsburgh, PA with my wife, 3 energetic boys, and dog. Subscribe here or write me at ben dot northrop at gmail dot com.

Got a Comment?


Sign up to hear about the next post!

If you liked this article and want to hear about the next one, enter your email below. I don't spam - you'll only receive an email when there's a new post (which is about once a month, tops). It's all low-key, straight from me.

Comments ()

 None so far!