Sample Ant Build Example

A sample of“build.xml” file is given as following, for a java program. These four targets are defined by it.
  1. Clean
  2. Compile
  3. Clobber
  4. Jar

<?xml version="1.0"?>

<project name="Hello" default="compile">
    <target name="clean" description="remove intermediate files">
        <delete dir="classes"/>
    </target>
    <target name="clobber" depends="clean" description="remove all 
        artifact files">
        <delete file="hello.jar"/>
    </target>
    <target name="compile" description="compile the Java source 
                         code to class files">
        <mkdir dir="classes"/>
        <javac srcdir="." destdir="classes"/>
    </target>
    <target name="jar" depends="compile" description="create a Jar  
                file for the application">
        <jar destfile="hello.jar">
            <fileset dir="classes" includes="**/*.class"/>
            <manifest>
                <attribute name="Main-Class" value="HelloProgram"/>
            </manifest>
        </jar>
    </target>
</project>


Enter your email address to get our daily JOBS & INTERVIEW FAQ's Straight to your Inbox.

Make sure to activate your subscription by clicking on the activation link sent to your email