Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "An Example of Ant use" Watch "An Example of Ant use" New topic
Author

An Example of Ant use

Jawahar Rajan
Ranch Hand

Joined: Feb 28, 2002
Posts: 38
All,
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
Thanks
Jawahar
Curt Combar
Greenhorn

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


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:
http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=58&t=000043
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
http://www.onjava.com/pub/a/onjava/2001/02/22/open_source.html
I just got the chance to read through it and it seems like it may be helpful.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: An Example of Ant use
 
Similar Threads
Ant, J2EE with JSPs using Tag Files
Compilling example Page 30?
How do you deploy .ear files with ant?
Ant in Sun One: problem
package javax.xml.soap does not exist