View RSS Feed

Apache Ant

Sample build.xml file

Rate this Entry
by , 02-19-2012 at 08:27 AM (1714 Views)
A sample of“build.xml” file is given as following, for a java program. These four targets are defined by it.
• Clean
• Compile
• Clobber
• Jar

All these targets have an associated description.
XML Code:
<?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>

Submit "Sample build.xml file" to Facebook Submit "Sample build.xml file" to Digg Submit "Sample build.xml file" to del.icio.us Submit "Sample build.xml file" to StumbleUpon Submit "Sample build.xml file" to Google

Tags: build file Add / Edit Tags
Categories
Tasks

Comments