Files
nenya/build.xml
T
Michael Bayne 3cc46b73f6 Finished wired up Maven build. Still no LWJGL, but we'll sort that out later.
git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@1069 ed5b42cb-e716-0410-a449-f6a68f950b19
2010-11-18 04:24:03 +00:00

399 lines
18 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>
<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.1"/>
</artifact:dependencies>
<taskdef resource="com/threerings/presents/tools.properties" classpathref="tools.classpath"/>
</target>
<target name="clean" description="Deletes most build artifacts.">
<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>
<target name="distclean" description="Deletes all build artifacts.">
<delete dir="${deploy.dir}"/>
</target>
<target name="compile" depends="-check-available" description="Compiles source files.">
<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>
<target name="procstream" depends="-preptools"
description="Instruments Streamable classes for use in sandbox environments.">
<instream outdir="${classes.dir}">
<path refid="built.classpath"/>
<fileset dir="${classes.dir}" includes="**/data/*.class"/>
<fileset dir="${classes.dir}" includes="**/util/*.class"/>
</instream>
</target>
<target name="-checkaslib">
<condition property="no_build_aslib">
<not><available file="${flexsdk.dir}/lib/compc.jar"/></not>
</condition>
<condition property="no_rebuild_aslib"><or>
<isset property="no_build_aslib"/>
<uptodate targetfile="${deploy.dir}/${lib.name}lib.swc">
<srcfiles dir="src/as" includes="**/*.as"/>
</uptodate>
</or></condition>
</target>
<target name="aslib" unless="no_rebuild_aslib" depends="-checkaslib"
description="Builds ActionScript library.">
<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>
<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" description="Builds javadocs.">
<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"/>
<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" depends="-prepare">
<copy todir="${tclasses.dir}">
<fileset dir="src/test/resources" includes="**"/>
</copy>
<property name="testrsrc.dir" value="${tclasses.dir}/rsrc"/>
</target>
<!-- these can't depend on the compile target otherwise things break when we -->
<!-- call into -test-rsrcs from Maven, alas -->
<target name="test-colorpos" depends="-prep-test-rsrcs"
description="Builds the test colorpository data.">
<taskdef name="confcomp" classpathref="test.classpath"
classname="com.threerings.tools.CompiledConfigTask"/>
<confcomp parser="com.threerings.media.image.tools.xml.ColorPositoryParser"
configdef="${testrsrc.dir}/config/media/colordefs.xml"
target="${testrsrc.dir}/config/media/colordefs.dat"/>
</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="-test-rsrcs" depends="test-colorpos,test-tsbundles,test-cbundles"/>
<target name="tests" depends="compile,-test-rsrcs"
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>
<target name="all" depends="clean,-prepare,compile,-ninstall,tests,javadoc,dist"
description="Cleans and rebuilds everything, including javadocs."/>
<target name="dist" depends="-prepare,compile,procstream,-ninstall,aslib"
description="Compiles everything and build distribution jar files.">
<!-- 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>
<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>
<target name="retro" depends="dist"
description="Converts our 1.5 code to a 1.4 compatible format">
<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>
<target name="genascript" depends="-preptools"
description="Generates ActionScript versions of our Streamable classes.">
<genascript header="lib/SOURCE_HEADER" asroot="src/as">
<fileset dir="${src.dir}" includes="**/data/*.java"/>
</genascript>
</target>
<property name="scene" value="idyll"/>
<target name="miso-viewer" depends="compile,test-colorpos,test-tsbundles,test-cbundles"
description="Runs the Miso scene viewer.">
<java classname="com.threerings.miso.viewer.ViewerApp"
fork="true" classpathref="test.classpath">
<sysproperty key="resource_dir" value="${testrsrc.dir}"/>
<sysproperty key="no_unpack_resources" value="true"/>
<arg value="${testrsrc.dir}/scenes/${scene}.xml"/>
</java>
</target>
</project>