Source

webwork / webapps / build.xml

<project name="webwork-webapps" default="help" basedir=".">
    <property file="../build.properties"/>

    <target name="help">
        <echo>
            To build a webapp, simply run:

            ant build -Dwebapp=XXX

            ... Where XXX is the name of the webapp you want to build.
            After the build is finished, the fully-built war file can
            be found in the dist directory. You may deploy this file
            to any servlet container.

            For example:

            ant build -Dwebapp=sandbox
        </echo>
    </target>

    <path id="cp">
        <fileset dir="../lib">
            <include name="**/*.jar"/>
        </fileset>
        <fileset dir="..">
            <include name="webwork-*.jar"/>
        </fileset>
        <!-- used for allowing WebWork developers to build wars w/o building the whole distribution -->
        <path path="../build/java"/>
    </path>

    <macrodef name="compile">
        <attribute name="srcdir"/>
        <attribute name="destdir"/>
        <attribute name="classpath" default=""/>
        <attribute name="classpathref" default="cp"/>
        <attribute name="excludes" default=""/>
        <attribute name="source" default="1.4"/>
        <attribute name="target" default="1.4"/>
        <sequential>
            <mkdir dir="@{destdir}"/>
            <javac srcdir="@{srcdir}" destdir="@{destdir}" classpath="@{classpath}" classpathref="@{classpathref}"
                   debug="on" source="@{source}" target="@{target}"/>
            <copy filtering="no" todir="@{destdir}">
                <fileset dir="@{srcdir}">
                    <exclude name="**/*.java"/>
                    <exclude name="**/package.html"/>
                </fileset>
            </copy>
        </sequential>
    </macrodef>

    <target name="build">
        <!-- prepare -->
        <delete dir="${basedir}/tmp"/>
        <mkdir dir="${basedir}/tmp"/>
        <mkdir dir="${basedir}/dist"/>

        <!-- copy over the webapp -->
        <copy todir="${basedir}/tmp">
            <fileset dir="${basedir}/${webapp}/src/webapp"/>
        </copy>

        <!-- compile the sources -->
        <mkdir dir="${basedir}/tmp/WEB-INF/classes"/>
        <compile srcdir="${basedir}/${webapp}/src/java" destdir="${basedir}/tmp/WEB-INF/classes"/>

        <!-- war up the app -->
        <war file="${basedir}/dist/${webapp}.war" webxml="tmp/WEB-INF/web.xml">
            <zipfileset dir="tmp" prefix=""/>

            <!-- only these configurations are needed for now. Also, these are probably more than
                 needed, but we're just picking a single set of jars that each webapp can use -->
            <zipfileset dir="${basedir}/../lib/ajax" prefix="WEB-INF/lib" includes="*.jar"/>
            <zipfileset dir="${basedir}/../lib/default" prefix="WEB-INF/lib" includes="*.jar"/>
            <zipfileset dir="${basedir}/../lib/fileupload" prefix="WEB-INF/lib" includes="*.jar"/>
            <zipfileset dir="${basedir}/../lib/freemarker" prefix="WEB-INF/lib" includes="*.jar"/>
            <zipfileset dir="${basedir}/../lib/sitemesh" prefix="WEB-INF/lib" includes="*.jar"/>
            <zipfileset dir="${basedir}/../lib/spring" prefix="WEB-INF/lib" includes="*.jar" excludes="commons-logging.jar"/>
            <zipfileset dir="${basedir}/../lib/velocity" prefix="WEB-INF/lib" includes="*.jar"/>
            <zipfileset dir="${basedir}/../lib/quickstart" prefix="WEB-INF/lib" includes="log4j.jar"/>
            <zipfileset dir="${basedir}/../lib/jfree" prefix="WEB-INF/lib" includes="*.jar"/>
            <zipfileset dir="${basedir}/.." prefix="WEB-INF/lib" includes="${name}-${version}.jar"/>
        </war>
    </target>
</project>