Files
2017-08-19 07:55:25 -07:00

298 lines
14 KiB
XML

<?xml version="1.0" standalone="yes"?>
<project name="nenya" default="compile" basedir="." xmlns:artifact="urn:maven-artifact-ant">
<property name="deploy.dir" location="dist"/>
<property name="src.dir" location="core/src/main/java"/>
<property name="classes.dir" location="${deploy.dir}/classes"/>
<property name="asrc.dir" location="aslib/src/main/as"/>
<property name="tools-src.dir" location="tools/src/main/java"/>
<property name="tools-classes.dir" location="${deploy.dir}/tools-classes"/>
<property name="test-classes.dir" location="${deploy.dir}/test-classes"/>
<property name="ooo-build.vers" value="2.9"/>
<ant antfile="etc/bootstrap.xml"/>
<import file="${user.home}/.m2/ooo-build/${ooo-build.vers}/ooo-build.xml"/>
<target name="-prepare" depends="-init-ooo">
<mkdir dir="${deploy.dir}"/>
<mavendep pom="core/pom.xml" id="core" pathProp="core.path"/>
<path id="built.classpath">
<path refid="core.path"/>
<pathelement location="${classes.dir}"/>
</path>
<!-- we can't just use the tools/pom.xml here because it references core/pom.xml -->
<!-- Maven Ant Tasks are retarded when it comes to multi-module POMs -->
<!-- so we have to repeat what's in the tools/pom.xml here, yay! -->
<mavendep id="tools" pathProp="tools.path">
<dependency groupId="commons-digester" artifactId="commons-digester" version="1.8"/>
<dependency groupId="com.megginson.sax" artifactId="xml-writer" version="0.2"/>
<dependency groupId="com.googlecode.playn" artifactId="playn-core" version="1.5.1"/>
</mavendep>
<path id="tools.classpath">
<path refid="core.path"/>
<path refid="tools.path"/>
<pathelement location="${classes.dir}"/>
<pathelement location="${tools-classes.dir}"/>
</path>
<mavendep pom="core/pom.xml" id="test" scope="test"/>
<path id="test.classpath">
<path refid="test.path"/>
<path refid="tools.classpath"/>
<pathelement location="${test-classes.dir}"/>
</path>
<!-- we can't use <mavendep> here because we need to exclude our pom depends -->
<artifact:dependencies filesetId="aslib.fileset" cacheDependencyRefs="true" type="swc"
dependencyRefsBuildFile="${deploy.dir}/aslib-pom.dependencies">
<pom file="aslib/pom.xml"/>
</artifact:dependencies>
<pathconvert pathsep="," property="aslib.path" refid="aslib.fileset"/>
</target>
<target name="-prepare-as" depends="-prepare">
<maventaskdef groupId="com.threerings.ant" artifactId="actionscript" version="1.4"/>
<checkflex/> <!-- if flexsdk.dir is not already set, tries to infer it -->
<if><not><isset property="flexsdk.dir"/></not><then>
<echo>***</echo>
<echo>Not compiling Nenya ActionScript library. Set flexsdk.dir to enable.</echo>
<echo>***</echo>
</then></if>
</target>
<target name="-preptools" depends="-prepare">
<artifact:dependencies pathId="ntools.classpath">
<dependency groupId="com.threerings" artifactId="narya-tools" version="1.14"/>
</artifact:dependencies>
<taskdef resource="com/threerings/presents/tools.properties" classpathref="ntools.classpath"/>
</target>
<target name="clean" depends="-init-ooo" description="Deletes most build artifacts.">
<delete dir="${classes.dir}"/>
<delete dir="${test-classes.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>
<cleanmavendepcache pom="core/pom.xml"/>
<cleanmavendepcache pom="aslib/pom.xml"/>
<cleanmavendepcache id="test"/>
</target>
<target name="distclean" description="Deletes all build artifacts.">
<delete dir="${deploy.dir}"/>
</target>
<target name="compile" depends="-prepare" description="Compiles source files.">
<mkdir dir="${classes.dir}"/>
<ooojavac version="1.5" srcdir="${src.dir}" destdir="${classes.dir}" classpathref="core.path">
<exclude name="**/OggPlayer.java"/>
<exclude name="**/ModPlayer.java"/>
<exclude name="**/MidiPlayer.java"/>
<exclude name="**/Mp3Player.java"/>
</ooojavac>
<mkdir dir="${tools-classes.dir}"/>
<ooojavac version="1.5" srcdir="${tools-src.dir}" destdir="${tools-classes.dir}"
classpathref="tools.classpath"/>
<mkdir dir="${test-classes.dir}"/>
<ooojavac srcdir="core/src/test/java" destdir="${test-classes.dir}" version="1.5"
classpathref="test.classpath"/>
<ooojavac srcdir="tools/src/test/java" destdir="${test-classes.dir}" version="1.5"
classpathref="test.classpath"/>
</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="aslib" depends="-prepare-as" if="flexsdk.dir"
description="Builds ActionScript library.">
<compc srcdir="${asrc.dir}" libpath="${aslib.path}"
dest="${deploy.dir}/${ant.project.name}lib.swc"/>
</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>
<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"
link="http://www.threerings.net/code/nenya/docs/api"
additionalparam="-breakiterator" classpathref="built.classpath">
<link href="http://download.oracle.com/javase/6/docs/api/"/>
<link href="http://docs.guava-libraries.googlecode.com/git/javadoc/"/>
<link href="http://samskivert.googlecode.com/svn/apidocs"/>
<link href="http://threerings.googlecode.com/narya/apidocs"/>
<link href="http://www.jajakarta.org/ant/ant-1.6.1/docs/ja/manual/api/"/>
</javadoc>
</target>
<target name="asdoc" depends="-prepare" description="Builds ActionScript docs.">
<maventaskdef groupId="com.threerings.ant" artifactId="actionscript" version="1.4"/>
<mkdir dir="${deploy.dir}/asdocs"/>
<asdoc srcdir="${asrc.dir}" libpath="${aslib.path}" destdir="${deploy.dir}/asdocs"/>
</target>
<target name="-prep-test-rsrcs" depends="compile">
<copy todir="${test-classes.dir}">
<fileset dir="core/src/test/resources" includes="**"/>
<fileset dir="tools/src/test/resources" includes="**"/>
</copy>
<property name="test-rsrc.dir" value="${test-classes.dir}/rsrc"/>
</target>
<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="${test-rsrc.dir}/config/media/colordefs.xml"
target="${test-rsrc.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="${test-rsrc.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="${test-rsrc.dir}/config/miso/tile/fringeconf.xml"
target="${test-rsrc.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="${test-rsrc.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-units" depends="compile"
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"/>
<mkdir dir="${deploy.dir}/test-reports"/>
<unit printsummary="off" haltonfailure="yes">
<classpath refid="test.classpath"/>
<sysproperty key="test_dir" value="${test-classes.dir}"/>
<sysproperty key="resource_dir" value="${test-rsrc.dir}"/>
<sysproperty key="no_unpack_resources" value="true"/>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
<batchtest todir="${deploy.dir}/test-reports">
<fileset dir="core/src/test/java" includes="**/*${test}*Test.java"/>
<fileset dir="tools/src/test/java" includes="**/*${test}*Test.java"/>
</batchtest>
</unit>
</target>
<target name="tests" depends="dist,test-colorpos,test-tsbundles,test-cbundles,test-units"
description="Runs all tests."/>
<target name="all" depends="clean,-prepare,compile,-ninstall,tests,javadoc,dist,aslib"
description="Cleans and rebuilds everything, including javadocs."/>
<target name="dist" depends="-prepare,compile,procstream,-ninstall"
description="Compiles everything and builds distribution jar file.">
<jar destfile="${deploy.dir}/${ant.project.name}.jar" basedir="${classes.dir}"/>
<jar destfile="${deploy.dir}/${ant.project.name}-tools.jar" basedir="${tools-classes.dir}"/>
</target>
<target name="genascript" depends="-preptools"
description="Generates ActionScript versions of our Streamable classes.">
<genascript header="etc/SOURCE_HEADER" asroot="${asrc.dir}">
<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="${test-rsrc.dir}"/>
<sysproperty key="no_unpack_resources" value="true"/>
<arg value="${test-rsrc.dir}/scenes/${scene}.xml"/>
</java>
</target>
<target name="char-sprite-viz" depends="compile,test-colorpos,test-tsbundles,test-cbundles"
description="Runs the character sprite viewer.">
<java classname="com.threerings.cast.CharSpriteViz"
fork="true" classpathref="test.classpath">
<sysproperty key="resource_dir" value="${test-rsrc.dir}"/>
<sysproperty key="no_unpack_resources" value="true"/>
<arg value="navsail"/>
<arg value="smsloop"/>
<arg value="sailing"/>
</java>
</target>
<target name="-as-install" depends="aslib" if="flexsdk.dir">
<maveninstall file="${deploy.dir}/${ant.project.name}lib.swc" pom="aslib/pom.xml"/>
</target>
<target name="install" depends="dist,-as-install"
description="Deploys build artifacts to local Maven repository.">
<maveninstall file="pom.xml" pom="pom.xml"/>
<maveninstall file="${deploy.dir}/${ant.project.name}.jar" pom="core/pom.xml"/>
<maveninstall file="${deploy.dir}/${ant.project.name}-tools.jar" pom="tools/pom.xml"/>
</target>
<target name="-as-deploy" depends="aslib" if="flexsdk.dir">
<mavendeploy file="${deploy.dir}/${ant.project.name}lib.swc" pom="aslib/pom.xml"/>
</target>
<target name="deploy" depends="dist,-as-deploy,tests,javadoc"
description="Deploys our build artifacts to a Maven repository.">
<mavendeploy file="pom.xml" pom="pom.xml"/>
<mavendeploy file="${deploy.dir}/${ant.project.name}.jar" pom="core/pom.xml"
srcdir="${src.dir}" docdir="${deploy.dir}/docs"/>
<mavendeploy file="${deploy.dir}/${ant.project.name}-tools.jar" pom="tools/pom.xml"/>
</target>
</project>