Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
166 lines (149 sloc) 5.94 KB
<project name="sno" default="compile" basedir=".">
<description>
SNO - Super Nintendo Online
</description>
<!-- Settings -->
<property name="src" location="src" />
<property name="build" location="bin" />
<property name="reports" location="reports" />
<property name="docs" location="docs" />
<property name="lib" location="lib" />
<property name="test.romdir" location="roms" />
<!-- Emma Settings -->
<property name="emma.dir" location="emma" />
<property name="emma.instr" location="${emma.dir}/instr" />
<property name="emma.coverage" location="${emma.dir}/coverage" />
<!-- Profiler Settings -->
<property name="profile.properties" value="${lib}/sno.profile.properties" />
<property name="profile.jar" value="${lib}/profile.jar" />
<!-- Set up our classpaths for testing/regular builds -->
<path id="classpath.base">
<pathelement location="${build}" />
</path>
<path id="classpath.test">
<path refid="junit.lib" />
<path refid="classpath.base" />
</path>
<fileset id="test.rom" dir="${test.romdir}">
<include name="**/*.zip" />
<include name="**/*.smc" />
</fileset>
<!-- Junit definitions -->
<path id="junit.lib">
<pathelement path="${lib}/junit.jar" />
<pathelement path="${lib}/hamcrest.jar" />
</path>
<path id="ant-junit.lib">
<pathelement path="${lib}/ant-junit4.jar" />
<path refid="junit.lib" />
</path>
<taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask" classpathref="ant-junit.lib" />
<taskdef name="junitreport" classname="org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator" classpathref="ant-junit.lib" />
<!-- Emma definitions -->
<path id="emma.lib">
<pathelement path="${lib}/emma_ant.jar" />
<pathelement path="${lib}/emma.jar" />
</path>
<taskdef resource="emma_ant.properties" classpathref="emma.lib" />
<!-- Initialize some things -->
<target name="init">
<tstamp />
<mkdir dir="${build}" />
<mkdir dir="${emma.instr}" />
<mkdir dir="${reports}" />
</target>
<!-- Compile everything -->
<target name="compile" depends="init" description="compile the source ">
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}" debug="true" includeantruntime="false">
<classpath refid="classpath.test" />
</javac>
<copy todir="${build}" file="sno.properties" />
<jar destfile="${build}/sno.jar" basedir="${build}" excludes="**/test/** *.jar *.zip" update="true" duplicate="fail">
<manifest>
<attribute name="Build-Date" value="${TODAY}" />
</manifest>
</jar>
<!-- keytool -genkey -keystore sno.jks -alias sno -storepass snoapplet -validity 3650 -keysize 2048 -keyalg RSA -->
<signjar alias="sno" jar="${build}/sno.jar" keystore="${lib}/sno.jks" storepass="snoapplet" />
</target>
<!-- Junit test/Emma code coverage task-->
<target name="test" depends="compile" description="Run the Unit Tests">
<mkdir dir="${reports}" />
<emma>
<instr instrpathref="classpath.base" destdir="${emma.instr}" metadatafile="${emma.coverage}/metadata.emma" merge="true" />
</emma>
<!-- Run any file ending in Test.class as a junit test -->
<junit fork="yes" forkmode="once" dir=".">
<jvmarg value="-Demma.coverage.out.file=${emma.coverage}/coverage.emma" />
<jvmarg value="-Demma.coverage.out.merge=true" />
<classpath>
<pathelement location="${emma.instr}" />
<path refid="classpath.test" />
<path refid="emma.lib" />
</classpath>
<formatter type="xml" />
<batchtest todir="${reports}">
<fileset dir="${emma.instr}" includes="**/*Test.class" />
</batchtest>
</junit>
<!-- Generate an html report of all of the tests -->
<junitreport todir="${reports}">
<fileset dir="${reports}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${reports}/html" />
</junitreport>
<!-- Emma report -->
<emma verbosity="verbose">
<report sourcepath="${src}">
<fileset dir="${emma.coverage}">
<include name="*.emma" />
</fileset>
<!--<txt outfile="${emma.coverage}/coverage.txt" />-->
<html outfile="${emma.coverage}/coverage.html" />
</report>
</emma>
</target>
<!-- Findbugs Task -->
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="${lib}/findbugs-ant.jar" />
<taskdef name="convertXmlToText" classname="edu.umd.cs.findbugs.anttask.ConvertXmlToTextTask" classpath="${lib}/findbugs-ant.jar" />
<property name="findbugs.home" value="${lib}/findbugs/" />
<target name="findbugs" description="Run findbugs and generate a report" depends="compile">
<mkdir dir="${reports}" />
<findbugs home="${findbugs.home}" output="xml" outputFile="${reports}/findbugs.xml">
<sourcePath path="${src}" />
<class location="${build}" />
<auxClasspath path="${lib}/junit.jar" />
<auxClasspath path="${lib}/hamcrest.jar" />
</findbugs>
<convertXmlToText home="${findbugs.home}" input="${reports}/findbugs.xml" output="${reports}/findbugs.html" />
</target>
<!-- Javadoc Task -->
<target name="javadoc" description="Create javadocs">
<javadoc sourcepath="${src}" destdir="${docs}/" classpathref="classpath.test" useexternalfile="yes" linksource="true"/>
</target>
<!-- Java Profiler Task -->
<target name="profile" depends="compile">
<java classpathref="classpath.base" classname="edu.fit.cs.sno.snes.Core" fork="yes">
<jvmarg value="-Dprofile.properties=${profile.properties}" />
<jvmarg value="-javaagent:${profile.jar}" />
<arg value="${test.romdir}/${toString:test.rom}" />
</java>
</target>
<!-- Run the program -->
<target name="run" depends="compile">
<java classpathref="classpath.base" classname="edu.fit.cs.sno.snes.Core" fork="yes">
<arg value="${test.romdir}/${toString:test.rom}" />
</java>
</target>
<!-- Clean task -->
<target name="clean" description="Clean">
<delete dir="${build}" />
<delete dir="${docs}" />
<delete dir="${reports}" />
<delete dir="${emma.instr}" />
<delete dir="${emma.coverage}" />
<delete dir="${emma.dir}" />
</target>
</project>