Ant or 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.
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
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
-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
-P,--classpath <path> Specify a path to search for jars and
-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
-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.)