Source

xwork / build.xml

<project default="jar" basedir=".">
    <path id="cp">
        <fileset dir="lib">
            <include name="**/*.jar"/>
        </fileset>
    </path>

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

    <property file="build.properties"/>

    <property name="lib" value="lib"/>
    <property name="lib.core" value="${lib}/core"/>
    <property name="lib.build" value="${lib}/build"/>
    <property name="lib.optional" value="${lib}/optional"/>

    <property name="src" value="src"/>
    <property name="src.java" value="${src}/java"/>
    <property name="src.test" value="${src}/test"/>
    <property name="src.etc" value="${src}/etc"/>

    <property name="build" value="build"/>
    <property name="build.test" value="${build}/test"/>
    <property name="build.java-test" value="${build}/java-test"/>
    <property name="build.java" value="${build}/java"/>
    <property name="build.clover" value="${build}/clover"/>
    <property name="build.dist" value="${build}/dist"/>

    <property name="clover.initstring" value="${build.clover}/coverage.db"/>

    <property name="docs" value="docs"/>

    <target name="clean">
        <delete dir="${build}"/>
    </target>

    <target name="java">
        <mkdir dir="${build.java}"/>
        <javac srcdir="${src.java}" destdir="${build.java}" classpathref="cp" debug="on"/>
        <copy filtering="no" todir="${build.java}">
            <fileset dir="${src.java}">
                <exclude name="**/*.java"/>
                <exclude name="**/package.html"/>
            </fileset>
        </copy>
    </target>

    <target name="test" depends="format, java">
        <taskdef resource="clovertasks"/>
        <taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>

        <mkdir dir="${build.clover}"/>

        <mkdir dir="${build.test}"/>
        <javac srcdir="${src.test}" destdir="${build.test}" classpath="${build.java}" classpathref="cp" debug="on"/>
        <copy filtering="no" todir="${build.test}">
            <fileset dir="${src.test}">
                <exclude name="**/*.java"/>
                <exclude name="**/package.html"/>
            </fileset>
        </copy>

        <mkdir dir="${build.java-test}"/>
        <javac srcdir="${src.java}" destdir="${build.java-test}" classpathref="cp" debug="on" compiler="org.apache.tools.ant.taskdefs.CloverCompilerAdapter"/>
        <copy filtering="no" todir="${build.java-test}">
            <fileset dir="${src.java}">
                <exclude name="**/*.java"/>
                <exclude name="**/package.html"/>
            </fileset>
        </copy>

        <mkdir dir="${build.dist}/docs/junit"/>
        <junit printsummary="yes" haltonfailure="yes" haltonerror="yes" fork="yes">
            <classpath>
                <pathelement location="${build.test}"/>
                <pathelement location="${build.java-test}"/>
                <pathelement location="${src.etc}/test"/>
                <pathelement location="${src.etc}"/>
                <path refid="cp"/>
            </classpath>

            <formatter type="xml"/>
            <formatter type="brief" usefile="false"/>

            <batchtest todir="${build.dist}/docs/junit">
                <fileset dir="${src.test}">
                    <include name="**/*Test.java"/>
                </fileset>
            </batchtest>
        </junit>
    </target>

    <target name="format">
        <taskdef name="jalopy" classname="de.hunsicker.jalopy.plugin.ant.AntPlugin">
            <classpath refid="jalopy.classpath"/>
        </taskdef>

        <jalopy fileformat="unix"
            convention="${basedir}/src/etc/jalopy.xml"
            history="file"
            historymethod="adler32"
            loglevel="error"
            threads="2"
            classpathref="cp">
            <fileset dir="${src.java}">
                <include name="**/*.java"/>
            </fileset>
            <fileset dir="${src.test}">
                <include name="**/*.java"/>
            </fileset>
        </jalopy>
    </target>

    <target name="jar" depends="java">
        <mkdir dir="${build}"/>

        <copy todir="${build.java}" file="${src.etc}/xwork-1.0.dtd"/>
        <copy todir="${build.java}" file="${src.etc}/xwork-validator-1.0.dtd"/>

        <jar basedir="${build.java}" jarfile="${build}/${name}-${version}.jar"/>
    </target>

    <target name="javadocs">
        <mkdir dir="${build.dist}/docs/api"/>
        <javadoc sourcepath="${src.java}"
            destdir="${build.dist}/docs/api"
            packagenames="com.opensymphony.*"
            classpathref="cp"
            author="true"
            version="true"
            windowTitle="${name} ${version} API"
            doctitle="${name}"
            footer="See &lt;a href=&quot;http://www.opensymphony.com&quot;&gt;www.opensymphony.com&lt;/a&gt; for more information."
            use="true"
            verbose="false"/>
        <!-- <copy overwrite="yes" file="${docs}/main.css" tofile="${docs}/api/stylesheet.css"/> -->
    </target>

    <target name="clover.report" depends="test">
        <clover-report>
            <current outfile="${build.dist}/docs/clover">
                <format type="html"/>
            </current>
        </clover-report>
    </target>

    <target name="clover.historical" depends="clover.report">
        <clover-historypoint historyDir="${build.clover}"/>

        <clover-report>
            <historical outfile="${build.dist}/docs/clover" historyDir="${build.clover}">
                <format type="html"/>
            </historical>
        </clover-report>
    </target>

    <target name="junit.report" depends="test">
        <junitreport todir="${build.dist}/docs/junit">
            <fileset dir="${build.dist}/docs/junit">
                <include name="TEST-*.xml"/>
            </fileset>
            <report format="frames" todir="${build.dist}/docs/junit"/>
        </junitreport>
    </target>

    <target name="docs" depends="javadocs, clover.report, junit.report">
        <copy todir="${build.dist}/docs">
            <fileset dir="${docs}"/>
        </copy>
    </target>

    <target name="dist" depends="jar, docs">
        <copy file="${build}/${name}-${version}.jar" todir="${build.dist}"/>
        <zip zipfile="${build}/${name}-${version}.zip" basedir="${build.dist}"/>
    </target>

    <!--
      - A happy target to allow anthill to kick off a maven build.  As this does a site:deploy, you'll need to specify
      - the user who should be doing the deploy
      -
      - ant -Dmaven.username=build site:deploy
      -->
    <target name="site:deploy">
        <exec executable="maven" failonerror="true">
            <arg line="-Dmaven.username=${maven.username} site:deploy"/>
        </exec>
    </target>

</project>