GAnt vs. Ant (comparison, advantages and drawbacks GAnt)

By neokrates, written on June 4, 2010

article

  • Join date: 11-30-99
  • Posts: 224
View Counter:
  • 129 views
Rate it
Ad
Poll
  • What are your favorite build tools?

    View Results

    Loading ... Loading ...
Feeds:
  • bodytext bodytext bodytext

Ant or Gant comparison

Ant is great and stable tool and yet it has many issues and limitations.
GAnt is a newer and yet-not-mature alternative which has no limits. So, is it a time to port your Ant scripts to GAnt?

❓ What is GAnt?

GAnt is an Ant and Groovy based build automation tool.

GAnt is Ant based:

It uses Ant Library directly, so all what is available in Ant is also available in GAnt.

GAnt is Groovy based:

GAnt build scripts are written in Groovy.

👉 Why GAnt?

There are several advantages GAnt has over Ant

1

No xml

XML can make complex things simple or simple things complex, like here:

<if>
    <equals arg1="${name}" arg2="Putin" />
  <then>
    <echo message="hello Mr President" />
  </then>
</if>

2

Minimal code, simple code

The mission of Groovy is to have the simplest code possible to do what you need.

Ant:

<?xml version="1.0"?>
<project name="Just hello" default="default">
  <target name="default" description="Just hello">
      <echo>hello</echo>
  </target>
</project>

 
Gant:

target ( default: 'Just hello'  ) {
  ant.echo ('hello')
}

3

Freedom

Logic and flow Control are easy, short, readable

With Ant you need AntContib, GAnt already has it.

Ant:

<?xml version="1.0"?>
<project name="Just hello" default="default">

  <taskdef resource="net/sf/antcontrib/antcontrib.properties"
           classpath="${basedir}/lib/ant-contrib-1.0b3.jar" />

  <target name="default" description="Just hello">
    <echo>hello</echo>
      <property name="name" value="Bush"/>

      <if>
       <equals arg1="${name}" arg2="Bush" />
       <then>
         <echo message="hello Mr President" />
       </then>
      </if>

  </target>
</project>                                                   

 
GAnt:

target ( default: 'Just hello'  ) {

  def name='Clinton'

  if (name=='Clinton')
    print 'hello Mr President'

}
Power of Java and Groovy
All Java and Groovy Libraries
Advanced language features like closures and dynamic code

Closure

def welcome = { name ->

if (name=='Bush')
    print 'hello Mr President'
}


target ( default: 'Just hello'  ) {

    welcome 'Bush'
}

 
Dynamics

def otherPresident = 'Obama'
def welcome2 = """
if (name=='$otherPresident')
    print 'hello Mr President'

"""

target ( default: 'Just hello'  ) {

    new GroovyShell(new Binding(name:'Bush')).evaluate (welcome2)
}

👉 Why not GAnt?

1

Integration with Ant problems

Threading

      // That may go boom
      Thread.start {
            ant.waitfor(maxwait    : '45' , maxwaitunit    : 'second' ,
                checkevery : '5'  , checkeveryunit : 'second') {
                ant.http(url : "http://$myurl/myapp")
            }
      }

 
Custom target parameters

target('stop-the-server' : 'Stop my server') {

}

 
// Oh wait, can I have a custom parameters? Well yes, no, perhaps, it depends …


In version of GAnt prior to 1.5.0, various tricks could be played using the implicit parameter to GAnt targets —
targets were not nullary functions but single parameter functions. This facility has been withdrawn as of GAant 1.5.0,
targets are nullary functions. So prior to GAnt 1.5.0, you might have seen things like:
target ( example : ) { println ( it ) }target ( callit : ) { example ( 'fred' ) }
or even:
target ( example : ) { parameter -> println ( parameter ) }target ( callit : ) { example ( 'fred' ) }
but these no longer do what they used to. As of Gant 1.5.0 any parameters to the call of a target is ignored:
the parameter to the target always refers to the map containing information about the target.

– ( http://gant.codehaus.org/Targets%2Band%2BParameters )

2

Vertical compatibility not always there

3

GAnt is new:

✔ Not much learn material (for now)
http://www.amazon.de/s/ref=nb_sb_noss?__mk_de_DE=%C5M%C5Z%D5%D1&url=search-alias%3Daps&field-keywords=gant+build&x=0&y=0  (Zarro Boocks found)

✔ Community is not that large.

✔ Is GAnt for long?


And yes, a Gradle build of GAant is under development to replace the Ant (and Gant!) builds.

– ( http://gant.codehaus.org/ )

4

No IDE Support

5

Ant -> GAnt migration

Will cost time. No automatic way (there is a prototype script though)

Conclusion

GAnt solves most known build scripting problems and has no limits.

But it also has issues, which may overweight the advantages depending on what you want to do with it.

That’s it, have fun :-)

Be Sociable, Share!
 

LEARN MORE (amazon bookstore)

TAGS

SOCIAL
Be Sociable, Share!


Leave a Reply