Basic build.xml template

From Stack Overflow
Jump to: navigation, search
<project name="MyProject" default="help" basedir=".">

<property name="build.sysclasspath" value="last"/>

<target name="help">
    <echo message="Common build targets:" />
    <echo message="jar         - Builds testconsole.jar" />
    <echo message="build       - Same as clean+jar" />
    <echo message="compile     - Compiles TestConsole classes" />
    <echo message="clean       - Remove all *.class and testconsole.jar" />
</target>

<property file="build.properties"/>
<property name="buildDir" value="build" />

<path id="classpath">
    <pathelement path="." />
    <fileset dir="lib">
        <include name="*.jar" />
    </fileset>
    <pathelement location="." />
</path>

<target name="build" depends="clean,jar"/>

<target name="jar" depends="compile">
    <jar
        jarfile="lib/toolbox.jar">
        <fileset dir="classes"/>
    </jar>
</target>

<target name="compile">
    <mkdir dir="classes"/>
    <javac
        srcdir="src"
        destdir="classes"
        classpathref="classpath"/>
    <copy todir="classes">
        <fileset dir="src">
            <include name="**/*.xsl" />
            <include name="**/*.gif" />
            <include name="**/*.jpg" />
            <include name="**/*.properties" />
        </fileset>
    </copy>    
</target>

<target name="clean">
    <delete dir="classes"/>
</target>

</project>
Personal tools