jQuery in Action, 3rd edition
The moose likes Ant, Maven and Other Build Tools and the fly likes An Example of Ant use Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "An Example of Ant use" Watch "An Example of Ant use" New topic

An Example of Ant use

Jawahar Rajan
Ranch Hand

Joined: Feb 28, 2002
Posts: 38
I was recently trying to learn how to work with J2EE, using the demo/tutorila form the java.sun.com website. They had an example using the demo pet store,however they also asked to download the Ant files from the Apache website.
I did this and followed th einstructions on how toset up ANT to be used with the J2EE and or Tomcat server.
I am still a little confused as to the exact role of Ant.
1) does ant act like an extraction layer?
2) does Ant build XML files that read/write data?
Please could someone suggest some examples of Extreme Programming using J2EE and ANT
Curt Combar

Joined: Oct 11, 2000
Posts: 7
Ant is a tool, written in Java, that replicates and extends the functionality provided by the "make" tool on Unix. It is a tool for automating the build process for a Java project. The instructions for how to build a project are entered into an XML document (conventionally called "build.xml"). Ant reads this file and builds the project, checking dates of output files vs. their source files and only executing build steps for source files that have changed since the last build.
For example, say you have a J2EE project that includes several Java class files, dependant JAR files, web.xml, html/jsp files, EJBs and descriptor files. It is possible to build a single Ant build file in XML that tells Ant how to compile the Java, build the EJB Jar files and process them using a server-specific EJB tool to generate home and remote objects, package the html/jsp/image files into a WAR with the web.xml, and package the WAR and EJB jars into a single EAR file that can be deployed on your app server. The chief advantage of this is that you can change several source files and simply type "ant" to rebuild the entire EAR file. This saves a lot of time and mistakes!
There are several good FAQs, articles and examples in the Resources section at the Ant site: http://jakarta.apache.org/ant/resources.html

Curt Combar<br />Java geek<br />Freeport, ME
timothy zimmerman
Ranch Hand

Joined: Jun 26, 2001
Posts: 149
Curt pretty much summed it up. Ant is simply a build tool. It has many built in functions to execute tasks typically performed in the build process ( mkdir, copy, delete ) as well as functions specific to building java applications (javac, jar).
To use it you script theses tasks in an xml file and then ant parses and executes the tasks.
There is another topic here you might find useful:
Ant Tutorial:
timothy zimmerman
Ranch Hand

Joined: Jun 26, 2001
Posts: 149
The following link to an article on O'Reilly's site was posted in the Ant Tutorial thread by Matt Rasking
I just got the chance to read through it and it seems like it may be helpful.
I agree. Here's the link: http://aspose.com/file-tools
subject: An Example of Ant use
It's not a secret anymore!