Files
nenya/build.xml
T
Michael Bayne 906f69a392 Making tests work again. Next up will be fixing test failures. (Actually next
up will be making the tests actually test something, and then fixing that when
they break.)


git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@1050 ed5b42cb-e716-0410-a449-f6a68f950b19
2010-11-08 19:44:11 +00:00

432 lines
19 KiB
XML

<?xml version="1.0" standalone="yes"?>
<project name="nenya" default="compile" basedir="." xmlns:artifact="urn:maven-artifact-ant">
<property name="lib.name" value="nenya"/>
<property name="src.dir" value="src/main/java"/>
<property name="tsrc.dir" value="src/test/java"/>
<property name="deploy.dir" value="dist"/>
<property name="classes.dir" value="${deploy.dir}/classes"/>
<property name="tclasses.dir" value="${deploy.dir}/test-classes"/>
<!-- TEMP: this can go away when all of our depends come from Maven -->
<property name="libs.dir" value="lib"/>
<fileset dir="${libs.dir}" id="nenya.libs">
<!-- these LWJGL (for OpenAL) and codec libraries are optional -->
<include name="lwjgl.jar"/>
<include name="lwjgl_util.jar"/>
<include name="jogg-0.0.7.jar"/>
<include name="jorbis-0.0.15.jar"/>
<include name="jl1.0.jar"/>
<!-- ActionScript dependencies -->
<include name="as3isolib-fp9.swc"/>
<include name="aspirin.swc"/>
<include name="flexlib.swc"/>
<include name="naryalib.swc"/>
</fileset>
<!-- end TEMP -->
<property name="maven-ant.vers" value="2.1.1"/>
<property name="maven-ant.dir" value="${user.home}/.m2/ant-support"/>
<property name="maven-ant.jar" value="${maven-ant.dir}/maven-ant-tasks-${maven-ant.vers}.jar"/>
<property name="maven-ant.url"
value="http://mirrors.ibiblio.org/pub/mirrors/apache/maven/binaries"/>
<condition property="maven-ant.exists"><available file="${maven-ant.jar}"/></condition>
<target name="-download-maven-ant" unless="maven-ant.exists">
<mkdir dir="${maven-ant.dir}"/>
<get src="${maven-ant.url}/maven-ant-tasks-${maven-ant.vers}.jar"
dest="${maven-ant.jar}" usetimestamp="true"/>
</target>
<target name="-init-maven-ant" depends="-download-maven-ant">
<taskdef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="urn:maven-artifact-ant" classpath="${maven-ant.jar}"/>
<artifact:pom id="pom" file="pom.xml"/>
<artifact:dependencies pathId="complibs.classpath" pomRefId="pom" useScope="compile"/>
<artifact:dependencies pathId="testlibs.classpath" pomRefId="pom" useScope="test"/>
</target>
<target name="-prepare" depends="-init-maven-ant">
<mkdir dir="${deploy.dir}"/>
<!-- TEMP: this can go away when all of our depends come from Maven -->
<mkdir dir="${deploy.dir}/lib"/>
<copy todir="${deploy.dir}/lib" flatten="true">
<fileset refid="${lib.name}.libs"/>
</copy>
<!-- end TEMP -->
<path id="compile.classpath">
<path refid="complibs.classpath"/>
<fileset dir="${deploy.dir}/lib" includes="**/*.jar"/>
</path>
<path id="built.classpath">
<path refid="compile.classpath"/>
<pathelement location="${classes.dir}"/>
</path>
<path id="test.classpath">
<path refid="testlibs.classpath"/>
<pathelement location="${classes.dir}"/>
<pathelement location="${tclasses.dir}"/>
</path>
</target>
<target name="-check-available" depends="-prepare">
<available property="lwjgl.present"
classname="org.lwjgl.LWJGLException" classpathref="compile.classpath"/>
<echo level="info" message="Have LWJGL: ${lwjgl.present}"/>
<available property="jorbis.present"
classname="com.jcraft.jorbis.Info" classpathref="compile.classpath"/>
<echo level="info" message="Have JOrbis: ${jorbis.present}"/>
<available property="jl.present"
classname="javazoom.jl.decoder.Decoder" classpathref="compile.classpath"/>
<echo level="info" message="Have JL: ${jl.present}"/>
<condition property="build.openal">
<and>
<isset property="lwjgl.present"/>
<isset property="jorbis.present"/>
<isset property="jl.present"/>
</and>
</condition>
</target>
<!-- makes sure our tools are compiled and defines the ant tasks -->
<target name="-preptools" depends="-prepare">
<artifact:dependencies pathId="tools.classpath">
<!-- TODO: we should publish a narya-tools "artifact" which has the
javassist dependency listed as non-optional -->
<dependency groupId="javassist" artifactId="javassist" version="3.8.0.GA"/>
<dependency groupId="com.threerings" artifactId="narya" version="1.0"/>
</artifact:dependencies>
<taskdef resource="com/threerings/presents/tools.properties" classpathref="tools.classpath"/>
</target>
<!-- cleans out the intermediate build files -->
<target name="clean">
<delete dir="${classes.dir}"/>
<delete dir="${tclasses.dir}"/>
<delete dir="${deploy.dir}/docs"/>
<delete failonerror="false"><fileset dir="${deploy.dir}" includes="*.jar"/></delete>
<delete failonerror="false"><fileset dir="${deploy.dir}" includes="*.swc"/></delete>
</target>
<!-- wipes the entire build directory clean -->
<target name="distclean">
<delete dir="${deploy.dir}"/>
</target>
<!-- build the java class files -->
<target name="compile" depends="-check-available">
<mkdir dir="${classes.dir}"/>
<javac srcdir="${src.dir}" destdir="${classes.dir}" includeAntRuntime="false"
debug="on" optimize="${build.optimize}" deprecation="on" source="1.5" target="1.5">
<classpath refid="compile.classpath"/>
<exclude name="com/threerings/openal/**" unless="build.openal"/>
<exclude name="**/OggPlayer.java"/>
<exclude name="**/ModPlayer.java"/>
<exclude name="**/MidiPlayer.java"/>
<exclude name="**/Mp3Player.java"/>
<compilerarg value="-Xlint"/>
<compilerarg value="-Xlint:-serial"/>
<compilerarg value="-Xlint:-unchecked"/> <!-- TODO: fix -->
</javac>
<mkdir dir="${tclasses.dir}"/>
<javac srcdir="${tsrc.dir}" destdir="${tclasses.dir}" includeAntRuntime="false"
debug="on" optimize="off" deprecation="off">
<classpath refid="test.classpath"/>
<exclude name="com/threerings/openal/**" unless="build.openal"/>
<compilerarg value="-Xlint"/>
<compilerarg value="-Xlint:-serial"/>
</javac>
</target>
<!-- adds readField and writeField methods to Stremable classes -->
<target name="procstream" depends="-preptools">
<instream outdir="${classes.dir}">
<path refid="built.classpath"/>
<fileset dir="${classes.dir}" includes="**/data/*.class"/>
<fileset dir="${classes.dir}" includes="**/util/*.class"/>
</instream>
</target>
<!-- checks whether our Flash library needs building -->
<target name="-checkaslib">
<condition property="no_build_aslib"><or>
<not><available file="${flexsdk.dir}/lib/compc.jar"/></not>
<uptodate targetfile="${deploy.dir}/${lib.name}lib.swc">
<srcfiles dir="src/as" includes="**/*.as"/>
</uptodate>
</or></condition>
</target>
<!-- builds our Flash library -->
<target name="aslib" unless="no_build_aslib" depends="-checkaslib">
<copy file="etc/aslib-config.xml.in" tofile="${deploy.dir}/aslib-config.xml">
<filterset>
<filter token="flex_sdk_dir" value="${flexsdk.dir}"/>
<filter token="lib_name" value="${lib.name}"/>
</filterset>
</copy>
<java jar="${flexsdk.dir}/lib/compc.jar" fork="true" failonerror="true">
<arg value="-load-config"/>
<arg value="${deploy.dir}/aslib-config.xml"/>
<arg value="-compiler.optimize"/>
<arg value="-compiler.source-path=src/as/"/>
<arg value="-include-sources=src/as/"/>
<arg value="-output"/>
<arg value="${deploy.dir}/${lib.name}lib.swc"/>
</java>
<delete file="${deploy.dir}/aslib-config.xml"/>
</target>
<!-- installs the pre-built native libraries -->
<condition property="isunix"><os family="unix"/></condition>
<target name="ninstall" depends="-prepare" if="isunix">
<exec os="Linux" dir="${src.dir}/com/threerings/util/keybd/Linux" executable="make">
<arg line="install"/>
</exec>
<echo level="info" message="Installing native libraries for ${os.name}..."/>
<exec dir="${src.dir}/com/threerings/util/unsafe/${os.name}" executable="make">
<arg line="install"/>
</exec>
</target>
<!-- build the javadoc documentation -->
<target name="javadoc" depends="-prepare">
<mkdir dir="${deploy.dir}/docs"/>
<javadoc sourcepath="${src.dir}" packagenames="com.threerings.*"
destdir="${deploy.dir}/docs" stylesheetfile="docs/stylesheet.css"
additionalparam="-breakiterator"
link="http://www.threerings.net/code/nenya/docs/api">
<classpath refid="compile.classpath"/>
<link href="http://java.sun.com/j2se/1.5/docs/api/"/>
<!-- ant documentation is not available online, sorry kids -->
<link href="file:///usr/share/doc/ant-doc/javadocs"/>
<link href="http://samskivert.com/code/samskivert/samskivert/docs/api"/>
<link href="http://www.threerings.net/code/narya/docs/api"/>
<link href="http://www.jmonkeyengine.com/doc"/>
</javadoc>
<copy todir="${deploy.dir}/docs">
<fileset dir="${src.dir}" includes="**/*.png"/>
</copy>
</target>
<!-- builds the ActionScript documention -->
<target name="asdoc" unless="no_build_aslib" depends="-checkaslib">
<mkdir dir="${deploy.dir}/asdocs"/>
<java classpath="${flexsdk.dir}/lib/asdoc.jar" classname="flex2.tools.ASDoc" fork="true">
<jvmarg value="-Xmx1024m"/>
<jvmarg value="-Dsun.io.useCanonCashes=false"/>
<jvmarg value="-Xbootclasspath/p:${flexsdk.dir}/asdoc/lib/xalan.jar"/>
<arg value="+flexlib=${flexsdk.dir}/frameworks"/>
<arg line="-library-path ${flexsdk.dir}/frameworks/libs"/>
<arg line="-library-path ${deploy.dir}/lib/naryalib-0.0-SNAPSHOT.swc"/>
<arg line="-templates-path ${flexsdk.dir}/asdoc/templates"/>
<arg line="-doc-sources src/as"/>
<arg line="-output ${deploy.dir}/asdocs"/>
</java>
</target>
<target name="-prep-test-rsrcs">
<copy todir="${tclasses.dir}">
<fileset dir="src/test/resources" includes="**"/>
</copy>
<property name="testrsrc.dir" value="${tclasses.dir}/rsrc"/>
</target>
<target name="test-tsbundles" depends="-prep-test-rsrcs"
description="Build test tileset bundles.">
<taskdef name="tilebundle" classpathref="test.classpath"
classname="com.threerings.media.tile.bundle.tools.TileSetBundlerTask"/>
<taskdef name="conffringe" classpathref="test.classpath"
classname="com.threerings.miso.tile.tools.CompileFringeConfigurationTask"/>
<property name="tbundle.dir" value="${testrsrc.dir}/bundles/tiles"/>
<!-- blow away the tilesetid map file so that we get a consistent mapping every time -->
<delete file="${tbundle.dir}/tilesets.map"/>
<tilebundle config="${tbundle.dir}/bundler-config.xml" mapfile="${tbundle.dir}/tilesets.map">
<fileset dir="${tbundle.dir}/ground" includes="**/*.xml"/>
</tilebundle>
<tilebundle config="${tbundle.dir}/bundler-config.xml" mapfile="${tbundle.dir}/tilesets.map">
<fileset dir="${tbundle.dir}/objects" includes="**/*.xml"/>
</tilebundle>
<conffringe tilesetmap="${tbundle.dir}/tilesets.map"
fringedef="${testrsrc.dir}/config/miso/tile/fringeconf.xml"
target="${testrsrc.dir}/config/miso/tile/fringeconf.dat"/>
</target>
<target name="test-cbundles" depends="-prep-test-rsrcs"
description="Builds test component bundles.">
<taskdef name="metabundle" classpathref="test.classpath"
classname="com.threerings.cast.bundle.tools.MetadataBundlerTask"/>
<taskdef name="cbundle" classpathref="test.classpath"
classname="com.threerings.cast.bundle.tools.ComponentBundlerTask"/>
<property name="cbundle.dir" value="${testrsrc.dir}/bundles/components"/>
<metabundle actiondef="${cbundle.dir}/actions.xml" classdef="${cbundle.dir}/classes.xml"
target="${cbundle.dir}/metadata.jar"/>
<!-- blow away the components map file so that we get a consistent mapping every time -->
<delete file="${cbundle.dir}/components.map"/>
<cbundle actiondef="${cbundle.dir}/actions.xml" target="${cbundle.dir}/pirate/components.jar"
mapfile="${cbundle.dir}/components.map" root="${cbundle.dir}/pirate">
<fileset dir="${cbundle.dir}/pirate" includes="**/*.png" excludes="components/**"/>
</cbundle>
<cbundle actiondef="${cbundle.dir}/actions.xml" target="${cbundle.dir}/vessel/components.jar"
mapfile="${cbundle.dir}/components.map" root="${cbundle.dir}/vessel">
<fileset dir="${cbundle.dir}/vessel" includes="**/*.png" excludes="components/**"/>
</cbundle>
</target>
<property name="test" value=""/>
<target name="tests" depends="compile,test-tsbundles,test-cbundles"
description="Runs unit tests. Use -Dtest=Foo to run only FooTest.">
<taskdef name="unit" classpathref="test.classpath"
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>
<unit printsummary="off" haltonfailure="yes">
<classpath refid="test.classpath"/>
<sysproperty key="test_dir" value="${tclasses.dir}"/>
<sysproperty key="resource_dir" value="${testrsrc.dir}"/>
<sysproperty key="no_unpack_resources" value="true"/>
<formatter type="brief" usefile="false"/>
<batchtest>
<fileset dir="${tsrc.dir}" includes="**/*${test}*Test.java"/>
</batchtest>
</unit>
</target>
<!-- a target for rebuilding everything -->
<target name="all" depends="clean,-prepare,compile,ninstall,tests,javadoc,dist"/>
<!-- builds our distribution files (war and jar) -->
<target name="dist" depends="-prepare,compile,procstream,ninstall,aslib">
<!-- build our various jar files -->
<jar destfile="${deploy.dir}/${lib.name}-rsrc.jar">
<fileset dir="${classes.dir}" includes="com/threerings/resource/**"/>
</jar>
<jar destfile="${deploy.dir}/${lib.name}-media.jar">
<fileset dir="${classes.dir}" includes="com/threerings/geom/**"/>
<fileset dir="${classes.dir}" includes="com/threerings/media/**"/>
<fileset dir="${classes.dir}" includes="com/threerings/tools/**"/>
<fileset dir="${classes.dir}" includes="com/threerings/util/**"
excludes="**/*.c,**/Makefile,**/*.h"/>
<fileset dir="${classes.dir}" includes="com/threerings/NenyaLog*"/>
</jar>
<jar destfile="${deploy.dir}/${lib.name}-miso.jar">
<fileset dir="${classes.dir}" includes="com/threerings/miso/**"/>
<fileset dir="${classes.dir}" includes="rsrc/**/miso/**"/>
</jar>
<jar destfile="${deploy.dir}/${lib.name}-cast.jar">
<fileset dir="${classes.dir}" includes="com/threerings/cast/**"/>
<fileset dir="${classes.dir}" includes="rsrc/**/cast/**"/>
</jar>
<jar destfile="${deploy.dir}/${lib.name}-chat.jar">
<fileset dir="${classes.dir}" includes="com/threerings/chat/**"/>
</jar>
<jar destfile="${deploy.dir}/${lib.name}-openal.jar">
<fileset dir="${classes.dir}" includes="com/threerings/openal/**"/>
</jar>
</target>
<!-- a helper task for 'retro' -->
<target name="vweave">
<!-- various bits used by the retroweaver tasks -->
<taskdef name="weave" classpathref="built.classpath"
classname="com.rc.retroweaver.ant.RetroWeaverTask"/>
<property name="inpre" value="${deploy.dir}/${lib.name}"/>
<property name="outpre" value="${deploy.dir}/retro/${lib.name}"/>
<path id="retrocp">
<pathelement location="/usr/local/jdk1.4/jre/lib/rt.jar"/>
<fileset dir="lib" includes="**/*.jar"/>
<fileset dir="${deploy.dir}/retro" includes="*.jar"/>
</path>
<weave inputjar="${inpre}-${which}.jar" outputjar="${outpre}-${which}.jar"
failonerror="true">
<classpath refid="retrocp"/>
</weave>
</target>
<!-- converts our 1.5 code to a 1.4 compatible format -->
<target name="retro" depends="dist">
<mkdir dir="${deploy.dir}/retro"/>
<!-- we weave everything a first time without verification so that -->
<!-- interdependencies will resolve the second time -->
<weave inputjar="${inpre}-cast.jar" outputjar="${outpre}-cast.jar"/>
<weave inputjar="${inpre}-micasa.jar" outputjar="${outpre}-micasa.jar"/>
<weave inputjar="${inpre}-miso.jar" outputjar="${outpre}-miso.jar"/>
<weave inputjar="${inpre}-media.jar" outputjar="${outpre}-media.jar"/>
<weave inputjar="${inpre}-rsrc.jar" outputjar="${outpre}-rsrc.jar"/>
<!-- now weave again with the verifier to check for unweavable 1.5isms -->
<antcall target="vweave"><param name="which" value="cast"/></antcall>
<antcall target="vweave"><param name="which" value="micasa"/></antcall>
<antcall target="vweave"><param name="which" value="miso"/></antcall>
<antcall target="vweave"><param name="which" value="media"/></antcall>
<antcall target="vweave"><param name="which" value="rsrc"/></antcall>
</target>
<!-- generates ActionScript versions of our Streamable classes -->
<target name="genascript" depends="-preptools">
<genascript header="lib/SOURCE_HEADER" asroot="src/as">
<fileset dir="${src.dir}" includes="**/data/*.java"/>
</genascript>
</target>
<!-- creates a tarball and zipfile for source distribution -->
<target name="distrib">
<echo message="You may want to stop and run 'ant savedoc' first."/>
<echo message="Building tar.gz distribution..."/>
<tar destfile="../nenya-snapshot.tar.gz" compression="gzip">
<tarfileset dir=".." mode="0775" dirmode="0775">
<include name="nenya/bin/**"/>
<exclude name="**/.svn"/>
</tarfileset>
<tarfileset dir=".." mode="0664" dirmode="0775">
<include name="nenya/**"/>
<exclude name="**/.svn"/>
<exclude name="nenya/dist/**"/>
<exclude name="nenya/code/**"/>
<exclude name="nenya/nenya-*.*"/>
</tarfileset>
</tar>
<echo message="Building zip distribution..."/>
<zip destfile="../nenya-snapshot.zip">
<fileset dir="..">
<include name="nenya/**"/>
<exclude name="**/.svn"/>
<exclude name="nenya/dist/**"/>
<exclude name="nenya/code/**"/>
<exclude name="nenya/nenya-*.*"/>
</fileset>
</zip>
</target>
<!-- creates a zipfile with our source distribution -->
<target name="snapshot">
<echo message="You may want to stop and run 'ant savedoc' first."/>
<delete file="${deploy.dir}/${lib.name}-snapshot.zip"/>
<mkdir dir="${deploy.dir}/snapshot/${lib.name}"/>
<copy todir="${deploy.dir}/snapshot/${lib.name}">
<fileset dir=".">
<include name="**"/>
<exclude name="dist/**"/>
<exclude name="${lib.name}-*.zip"/>
</fileset>
</copy>
<copy todir="${deploy.dir}/snapshot/${lib.name}/lib">
<fileset dir="${deploy.dir}/lib" includes="*.jar"/>
</copy>
<copy todir="${deploy.dir}/snapshot/${lib.name}/docs/api">
<fileset dir="${deploy.dir}/docs" includes="**"/>
</copy>
<zip destfile="${deploy.dir}/${lib.name}-snapshot.zip" basedir="${deploy.dir}/snapshot"/>
<delete dir="${deploy.dir}/snapshot"/>
</target>
</project>