Ant or Gant?
What's Gant?
Gant is a build tool that uses both Groovy and Ant. With Gant, you describe your build process using Groovy scripts. Stated simply, Gant allows you to specify the build logic using Groovy instead of XML. The next thing you may ask is " Is Gant a competitor to Ant?". Let me quote from the Gant web site to make thing more clear here :
Whilst it might be seen as a competitor to Ant, Gant uses Ant tasks for many of the actions, so Gant is really an alternative way of doing builds using Ant, but using a programming language rather than XML to specify the build rules.
Download and Install Gant.
In order for Gant to work, you should have Groovy installed. You can download and follow the installation instructions for Groovy here.
As I said earlier also, in order to use Gant, you should have knowledge of Groovy as well. If you have never written Groovy code before, there are many interesting books on Groovy like:
You can also read the getting started guide on the Groovy web site, which should give you a good starting point.
Download the latest version of Gant from here. Gant is currently at version 1.4.0. Unzip it to a folder. If you already have your GROOVY_HOME set, that's all you need to use Gant.
Getting Started. Open a console, and type gant. You should see a message as shown below:
meera-subbaraos-macbook-9:~ meerasubbarao$ gant
Cannot open file build.gant
meera-subbaraos-macbook-9:~ meerasubbarao$
You are all set at this point to use Gant in your projects.
Help Information: Open a console, and type gant -h. This will provide you with all the necessary help information you need as shown below:
meera-subbaraos-macbook-9:CodeMetricsProject meerasubbarao$ gant -h
usage: gant [option]* [target]*
-c,--usecache Whether to cache the generated class and
perform modified checks on the file before re-compilation.
-n,--dry-run Do not actually action any tasks.
-C,--cachedir <cache-file> The directory where to cache generated
classes to.
-D <name>=<value> Define <name> to have value <value>.
Creates a variable named <name> for use in the scripts and a property
named <name> for the Ant tasks.
-L,--lib <path> Add a directory to search for jars and
classes.
-P,--classpath <path> Specify a path to search for jars and
classes.
-T,--targets Print out a list of the possible targets.
-V,--version Print the version number and exit.
-d,--debug Print debug levels of information.
-f,--file <build-file> Use the named build file instead of the
default, build.gant.
-h,--help Print out this message.
-l,--gantlib <library> A directory that contains classes to be used
as extra Gant modules,
-p,--projecthelp Print out a list of the possible targets.
-q,--quiet Do not print out much when executing.
-s,--silent Print out nothing when executing.
-v,--verbose Print lots of extra information.
Create a new file called build.gant at the root of your project.
Did a similarity between Ant and Gant strike you here? Ant build files are usually called build.xml, and they are created as a common practice within the root of your project folder as well.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)





Comments
Mike P(Okidoky) replied on Mon, 2008/09/29 - 10:54pm
in response to:
phil swenson
I want to be able to write (or use someone else's) template scripts, and use it to create buildable projects from it. I want to be able to open a text editor, type in the name of the project, the names of the java files, jar library files, and the name of the script that it needs to process it.
That way, I can keep upgrading the scripts without having to touch each project.
Serge Bureau replied on Tue, 2008/09/30 - 7:13am
in response to:
Mike P(Okidoky)
I want to be able to write (or use someone else's) template scripts, and use it to create buildable projects from it. I want to be able to open a text editor, type in the name of the project, the names of the java files, jar library files, and the name of the script that it needs to process it.
That way, I can keep upgrading the scripts without having to touch each project.
[/quote]
Why should I need any XML/XSL for that ?
phil swenson replied on Tue, 2008/09/30 - 9:03am
in response to:
Serge Bureau
"Why should I need any XML/XSL for that ?"
You don't. That's what is so great about using a real language, you can make the build do whatever you want.
Kenneth Wheeler replied on Fri, 2009/11/20 - 6:12am