View RSS Feed

Apache Ant

Sample build.xml file

Rate this Entry
by , 02-19-2012 at 09:27 AM (1948 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 name="clobber" depends="clean" description="remove all artifact files">
        <delete file="hello.jar"/>
    <target name="compile" description="compile the Java source code to class files">
        <mkdir dir="classes"/>
        <javac srcdir="." destdir="classes"/>
    <target name="jar" depends="compile" description="create a Jar file for the application">
        <jar destfile="hello.jar">
            <fileset dir="classes" includes="**/*.class"/>
                <attribute name="Main-Class" value="HelloProgram"/>

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

Tags: build file Add / Edit Tags