go to  ForumEasy.com   
JavaPro  
 
 
   Home  |  MyForum  |  FAQ  |  Archive    You are not logged in. [Login] or [Register]  
Forum Home » Java Deploying » Ant Biuld Tool
Email To Friend  |   Set Alert To This Topic Rewarding Points Availabe: 0 (What's this) New Topic  |   Post Reply
Author Topic: Ant Biuld Tool
ant
member
offline   
 
posts: 20
joined: 04/19/2010
from: San Jose, CA
  posted on: 04/19/2010 03:35:49 PM    Edit  |   Quote  |   Report 
Ant Biuld Tool
What's Ant?

Apache Ant is a Java-based build tool. It is kind of like make, without make's wrinkles.

Ant is to drive processes described in build files as targets and extension points dependent upon each other. The main known usage of Ant is the build of Java applications. Ant supplies a number of built-in tasks allowing to compile, assemble, test and run Java applications. Ant can also be used effectively to build non Java applications, for instance C or C++ applications. More generally, Ant can be used to pilot any type of process which can be described in terms of targets and tasks.

 Profile | Reply Points Earned: 0
ant
member
offline   
 
posts: 20
joined: 04/19/2010
from: San Jose, CA
  posted on: 04/19/2010 03:36:44 PM    Edit  |   Quote  |   Report 
Why another build tool?

Instead of a model where it is extended with shell-based commands, Ant is extended using Java classes. Instead of writing shell commands, the configuration files are XML-based, calling out a target tree where various tasks get executed. Each task is run by an object that implements a particular Task interface.

 Profile | Reply Points Earned: 0
ant
member
offline   
 
posts: 20
joined: 04/19/2010
from: San Jose, CA
  posted on: 04/19/2010 03:37:52 PM    Edit  |   Quote  |   Report 
System requirements

1) TDK 1.5 or later

2) To build and use Ant, you must have a JAXP-compliant XML parser installed and available on your classpath, such as Xerces. The binary distribution of Ant includes the latest version of the Apache Xerces2 XML parser. Please see http://java.sun.com/xml/ for more information about JAXP. If you wish to use a different JAXP-compliant parser, you should remove xercesImpl.jar and xml-apis.jar from Ant's lib directory.

 Profile | Reply Points Earned: 0
ant
member
offline   
 
posts: 20
joined: 04/19/2010
from: San Jose, CA
  posted on: 04/19/2010 03:40:54 PM    Edit  |   Quote  |   Report 
Environment setup

Before you can run Ant there is some additional set up you will need to do:

  • 1) PATH -- Add the bin directory to your path.
  • 2) ANT_HOME -- Set the ANT_HOME environment variable to the directory where you installed Ant.
  • 3) JAVA_HOME -- Optionally, set the JAVA_HOME environment variable to the directory where your JDK is installed.

    You can make the change statically via computer system administration or dynamically via command line settings which is good for the current CMD session:

    Windows and OS/2

    Assume Ant is installed in c:\ant\. The following sets up the environment:
    set ANT_HOME=c:\ant
    set JAVA_HOME=c:\jdk-1.5.0.05
    set PATH=%PATH%;%ANT_HOME%\bin
    


    Linux/Unix(bash)

    Assume Ant is installed in /usr/local/ant. The following sets up the environment:
    
    export ANT_HOME=/usr/local/ant
    export JAVA_HOME=/usr/local/jdk-1.5.0.05
    export PATH=${PATH}:${ANT_HOME}/bin
    


    Linux/Unix(csh)
    
    setenv ANT_HOME /usr/local/ant
    setenv JAVA_HOME /usr/local/jdk/jdk-1.5.0.05
    set path=( $path $ANT_HOME/bin )
    

  •  Profile | Reply Points Earned: 0
    ant
    member
    offline   
     
    posts: 20
    joined: 04/19/2010
    from: San Jose, CA
      posted on: 04/19/2010 03:42:16 PM    Edit  |   Quote  |   Report 
    Check Installation

    You can check the basic installation with opening a new shell and typing ant. You should get a message like this
    C:\ant
    Buildfile: build.xml does not exist!
    Build failed
    

    So Ant works. This message is there because you need to write an individual buildfile for your project. With a ant -version you should get an output like
    C:\ant -version
    Apache Ant version 1.8.0 compiled on February 1 2010
    


     Profile | Reply Points Earned: 0
    ant
    member
    offline   
     
    posts: 20
    joined: 04/19/2010
    from: San Jose, CA
      posted on: 04/19/2010 03:43:31 PM    Edit  |   Quote  |   Report 
    Simple Buildfile -- mkdir.xml
    <project name="MyProject" default="init" basedir="."> 
    
      <description>
    	simple example to create a directory
    	</description>
    
      <!-- set global properties -->
      <property name="dist"  location="newSubDir"/>
    
      <target name="init">
        <!-- Create the directory  -->
        <mkdir dir="${dist}"/>
      </target>
    
    </project>
    
    

     Profile | Reply Points Earned: 0
    ant
    member
    offline   
     
    posts: 20
    joined: 04/19/2010
    from: San Jose, CA
      posted on: 04/19/2010 03:45:01 PM    Edit  |   Quote  |   Report 
    How to use it?
    
    C:\temp\ant-sample>ant -f mkdir.xml
    Buildfile: C:\temp\ant-sample\mkdir.xml
    
    init:
        [mkdir] Created dir: C:\temp\ant-sample\newSubDir
    
    BUILD SUCCESSFUL
    Total time: 0 seconds
    
    


     Profile | Reply Points Earned: 0

     
    Powered by ForumEasy © 2003-2005, All Rights Reserved. | Privacy Policy | Terms of Use
     
    Get your own forum today. It's easy and free.