<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="dist" name="EventBench">
	<!-- General Properties -->
	<property environment="env" />
	<property name="build.location" value="bin" />
	<property name="dist.location" value="dist" />
	<property name="javadoc.location" value="javadoc" />
	<property name="downloads.location" value="downloads" />
	<property name="debuglevel" value="source,lines,vars" />
	<property name="target" value="1.6" />
	<property name="source" value="1.6" />

	<!-- Distribution Properties -->
	<property name="dist.location.main" value="${dist.location}/console" />
	<property name="dist.location.jfcmonitor" value="${dist.location}/jfcmonitor" />
	<property name="dist.location.javadoc" value="${dist.location}/javadoc" />

	<!-- EventBenchConsole Properties -->
	<property name="build.location.eventbenchconsole" value="${build.location}/eventbenchconsole" />
	<property name="EventBenchConsole.jarname" value="eventbenchconsole.jar" />
	<property name="EventBenchConsole.location" value="../EventBenchConsole" />
	<path id="EventBenchConsole.classpath">
		<pathelement location="${build.location.eventbenchconsole}" />
		<pathelement location="lib/collections-generic-4.01.jar" />
		<pathelement location="lib/jdom.jar" />
		<pathelement location="lib/colt-1.2.0.jar" />
		<pathelement location="lib/concurrent-1.3.4.jar" />
		<pathelement location="lib/j3d-core-1.3.1.jar" />
		<pathelement location="lib/jung-3d-2.0.1.jar" />
		<pathelement location="lib/jung-3d-demos-2.0.1.jar" />
		<pathelement location="lib/jung-algorithms-2.0.1.jar" />
		<pathelement location="lib/jung-api-2.0.1.jar" />
		<pathelement location="lib/jung-graph-impl-2.0.1.jar" />
		<pathelement location="lib/jung-io-2.0.1.jar" />
		<pathelement location="lib/jung-jai-2.0.1.jar" />
		<pathelement location="lib/jung-jai-samples-2.0.1.jar" />
		<pathelement location="lib/jung-samples-2.0.1.jar" />
		<pathelement location="lib/jung-visualization-2.0.1.jar" />
		<pathelement location="lib/stax-api-1.0.1.jar" />
		<pathelement location="lib/vecmath-1.3.1.jar" />
		<pathelement location="lib/wstx-asl-3.2.6.jar" />
		<pathelement location="lib/commons-codec-1.5.jar" />
		<pathelement location="lib/org.eclipse.core.commands_3.6.0.I20110111-0800.jar" />
		<pathelement location="lib/org.eclipse.equinox.common_3.6.0.v20110523.jar" />
		<pathelement location="lib/org.eclipse.jface_3.7.0.I20110522-1430.jar" />
		<pathelement location="lib/org.eclipse.osgi_3.7.0.v20110613.jar" />
		<pathelement location="lib/org.eclipse.swt.win32.win32.x86_3.7.0.v3735b.jar" />
		<pathelement location="lib/org.eclipse.ui.forms_3.5.100.v20110425.jar" />
		<pathelement location="lib/org.eclipse.ui.workbench_3.7.0.I20110519-0100.jar" />
		<pathelement location="lib/gui-model-core.jar" />
		<pathelement location="lib/log4j-1.2.16.jar" />
		<pathelement location="lib/jopt-simple-3.3.jar" />
		<path refid="JavaHelperLib.classpath" />
		<path refid="EventBenchCore.classpath" />
	</path>

	<!-- EventBenchCore Properties -->
	<property name="build.location.eventbenchcore" value="${build.location}/eventbenchcore" />
	<property name="EventBenchCore.jarname" value="eventbenchcore.jar" />
	<property name="EventBenchCore.location" value="../EventBenchCore" />
	<path id="EventBenchCore.classpath">
		<pathelement location="${build.location.eventbenchcore}" />
		<pathelement location="lib/Jama-1.0.2.jar" />
		<pathelement location="lib/colt-1.2.0.jar" />
		<pathelement location="lib/concurrent-1.3.4.jar" />
		<pathelement location="lib/j3d-core-1.3.1.jar" />
		<pathelement location="lib/jung-3d-2.0.1.jar" />
		<pathelement location="lib/jung-3d-demos-2.0.1.jar" />
		<pathelement location="lib/jung-algorithms-2.0.1.jar" />
		<pathelement location="lib/jung-api-2.0.1.jar" />
		<pathelement location="lib/jung-graph-impl-2.0.1.jar" />
		<pathelement location="lib/jung-io-2.0.1.jar" />
		<pathelement location="lib/jung-jai-2.0.1.jar" />
		<pathelement location="lib/jung-jai-samples-2.0.1.jar" />
		<pathelement location="lib/jung-samples-2.0.1.jar" />
		<pathelement location="lib/jung-visualization-2.0.1.jar" />
		<pathelement location="lib/stax-api-1.0.1.jar" />
		<pathelement location="lib/vecmath-1.3.1.jar" />
		<pathelement location="lib/wstx-asl-3.2.6.jar" />
		<pathelement location="lib/commons-codec-1.5.jar" />
		<pathelement location="lib/collections-generic-4.01.jar" />
		<path refid="JavaHelperLib.classpath" />
	</path>

	<!-- JavaHelperLib Properties -->
	<property name="build.location.javahelperlib" value="${build.location}/javahelperlib" />
	<property name="JavaHelperLib.jarname" value="javahelperlib.jar" />
	<property name="JavaHelperLib.location" value="../JavaHelperLib" />
	<path id="JavaHelperLib.classpath">
		<pathelement location="${build.location.javahelperlib}" />
	</path>

	<!-- JFCMonitor Properties -->
	<property name="build.location.jfcmonitor" value="${build.location}/jfcmonitor" />
	<property name="JFCMonitor.jarname" value="jfcmonitor.jar" />
	<property name="JFCMonitor.location" value="../JFCMonitor" />
	<path id="JFCMonitor.classpath">
		<pathelement location="${build.location.jfcmonitor}" />
		<path refid="JavaHelperLib.classpath" />
	</path>

	<!-- Emma Configuration -->
	<property name="coverage.location" value="coverage" />
	<property name="coverage.instrumented" value="inst" />
	<property name="coverage.instrumented.javahelperlib" value="${coverage.instrumented}/javahelperlib" />
	<property name="coverage.instrumented.eventbenchcore" value="${coverage.instrumented}/eventbenchcore" />
	<path id="emma.classpath">
		<pathelement location="lib-test/emma.jar" />
		<pathelement location="lib-test/emma_ant.jar" />
	</path>

	<taskdef resource="emma_ant.properties" classpathref="emma.classpath" />

	<!-- JUnit Test General Properties -->
	<property name="test.location.results" value="test-results" />
	<property name="test.location.data" value="testdata" />
	<property name="test.location.output" value="testoutput" />
	<path id="JUnit.classpath">
		<pathelement location="lib-test/junit-4.10.jar" />
		<pathelement location="lib-test/junit-addons-1.4.jar" />
		<pathelement location="lib-test/cglib-nodep.jar" />
		<pathelement location="lib-test/objenesis.jar" />
		<pathelement location="lib-test/EqualsVerifier-1.0.2.jar" />
	</path>

	<!-- JUnit Test EventBenchCore Properties -->
	<property name="test.location.eventbenchcore" value="${build.location}/eventbenchcore-test" />
	<property name="EventBenchCoreTest.location" value="../EventBenchCoreTest" />
	<property name="test.eventbenchcore.main-class" value="de.ugoe.cs.eventbench.TestAll" />
	<property name="test.eventbenchcore.results" value="${test.location.results}/eventbenchcore" />
	<path id="EventBenchCoreJUnitCompile.classpath">
		<pathelement location="${test.location.eventbenchcore}" />
		<!--<pathelement location="${coverage.instrumented.eventbenchcore}" /> -->
		<path refid="EventBenchCore.classpath" />
		<path refid="JUnit.classpath" />
	</path>
	<path id="EventBenchCoreJUnitExecute.classpath">
		<pathelement location="${coverage.instrumented.eventbenchcore}" />
		<path refid="EventBenchCoreJUnitCompile.classpath" />
		<path refid="emma.classpath" />
	</path>

	<!-- JUnit Test JavaHelperLib Properties -->
	<property name="test.location.javahelperlib" value="${build.location}/javahelperlib-test" />
	<property name="JavaHelperLibTest.location" value="../JavaHelperLibTest" />
	<property name="test.javahelperlib.main-class" value="de.ugoe.cs.util.TestAll" />
	<property name="test.javahelperlib.results" value="${test.location.results}/javahelperlib" />
	<path id="JavaHelperLibJUnitCompile.classpath">
		<pathelement location="${test.location.javahelperlib}" />
		<path refid="JavaHelperLib.classpath" />
		<path refid="JUnit.classpath" />
	</path>
	<path id="JavaHelperLibJUnitExecute.classpath">
		<pathelement location="${coverage.instrumented.javahelperlib}" />
		<path refid="JavaHelperLibJUnitCompile.classpath" />
		<path refid="emma.classpath" />
	</path>

	<!-- FindBugs Properties -->
	<property name="findbugs.results.location" value="findbugs" />
	<path id="findbugs.classpath">
		<pathelement location="lib-test/findbugs-ant.jar" />
	</path>
	<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"
		classpathref="findbugs.classpath" />

	<!-- Initialization Targets -->
	<target name="init.build">
		<mkdir dir="${build.location}" />
	</target>
	<target name="init.dist">
		<mkdir dir="${dist.location}" />
		<mkdir dir="${dist.location.main}" />
		<mkdir dir="${dist.location.jfcmonitor}" />
	</target>
	<target name="init.downloads">
		<mkdir dir="${downloads.location}" />
	</target>
	<target name="init.javadoc">
		<mkdir dir="${javadoc.location}" />
	</target>
	<target depends="init.build" name="init.eventbenchconsole">
		<mkdir dir="${build.location.eventbenchconsole}" />
	</target>
	<target depends="init.build" name="init.eventbenchcore">
		<mkdir dir="${build.location.eventbenchcore}" />
	</target>
	<target depends="init.build" name="init.javahelperlib">
		<mkdir dir="${build.location.javahelperlib}" />
	</target>
	<target depends="init.build" name="init.jfcmonitor">
		<mkdir dir="${build.location.jfcmonitor}" />
	</target>
	<target depends="init.build" name="init.junit">
		<mkdir dir="${test.location.results}" />
		<mkdir dir="${test.location.data}" />
		<mkdir dir="${test.location.output}" />
	</target>
	<target depends="init.junit" name="init.eventbenchcore-test">
		<mkdir dir="${test.location.eventbenchcore}" />
	</target>
	<target depends="init.junit" name="init.javahelperlib-test">
		<mkdir dir="${test.location.javahelperlib}" />
		<copy includeemptydirs="true" todir="${test.location.data}">
			<fileset dir="${JavaHelperLibTest.location}/testdata" />
		</copy>
	</target>
	<target name="init.emma">
		<mkdir dir="${coverage.instrumented}" />
		<mkdir dir="${coverage.location}" />
	</target>
	<target name="init.findbugs">
		<mkdir dir="${findbugs.results.location}" />
	</target>

	<!-- Clean-up Targets -->
	<target name="clean.build">
		<delete dir="${build.location}" />
	</target>
	<target name="clean.dist">
		<delete dir="${dist.location}" />
	</target>
	<target name="clean.javadoc">
		<delete dir="${javadoc.location}" />
	</target>
	<target name="clean.junit">
		<delete dir="${test.location.results}" />
		<delete dir="${test.location.data}" />
		<delete dir="${test.location.output}" />
	</target>
	<target name="clean.emma">
		<delete dir="${coverage.instrumented}" />
	</target>
	<target name="clean.findbugs">
		<delete dir="${findbugs.results.location}" />
	</target>
	<target depends="clean.build,clean.dist,clean.javadoc,clean.junit,clean.emma,clean.findbugs"
		name="clean.all" />

	<!-- Build Targets -->
	<target
		depends="build.javahelperlib,build.eventbenchcore,build.eventbenchconsole,build.jfcmonitor"
		name="build" />
	<target depends="init.eventbenchconsole" name="build.eventbenchconsole">
		<javac debug="true" debuglevel="${debuglevel}"
			destdir="${build.location.eventbenchconsole}" source="${source}"
			target="${target}" includeantruntime="false">
			<src path="${EventBenchConsole.location}/src" />
			<classpath refid="EventBenchConsole.classpath" />
		</javac>
	</target>
	<target depends="init.eventbenchcore" name="build.eventbenchcore">
		<javac debug="true" debuglevel="${debuglevel}"
			destdir="${build.location.eventbenchcore}" source="${source}" target="${target}"
			includeantruntime="false">
			<src path="${EventBenchCore.location}/src" />
			<classpath refid="EventBenchCore.classpath" />
		</javac>
	</target>
	<target depends="init.javahelperlib" name="build.javahelperlib">
		<javac debug="true" debuglevel="${debuglevel}" destdir="${build.location.javahelperlib}"
			source="${source}" target="${target}" includeantruntime="false">
			<src path="${JavaHelperLib.location}/src" />
			<classpath refid="JavaHelperLib.classpath" />
		</javac>
	</target>
	<target depends="init.jfcmonitor" name="build.jfcmonitor">
		<javac debug="true" debuglevel="${debuglevel}" destdir="${build.location.jfcmonitor}"
			source="${source}" target="${target}" includeantruntime="false">
			<src path="${JFCMonitor.location}/src" />
			<classpath refid="JFCMonitor.classpath" />
		</javac>
	</target>

	<!-- Distribution Targets -->
	<target depends="build,init.dist,javadoc" name="dist">
		<!-- dist of main components, i.e., the console -->
		<pathconvert property="dist.libs" pathsep=" ">
			<mapper>
				<chainedmapper>
					<flattenmapper />
					<globmapper from="*" to="lib/*" />
				</chainedmapper>
			</mapper>
			<path>
				<fileset dir="lib">
					<include name="**/*.jar" />
				</fileset>
			</path>
		</pathconvert>
		<property name="dist.classpath"
			value="${dist.libs} ${JavaHelperLib.jarname} ${EventBenchCore.jarname}"></property>
		<jar destfile="${dist.location.main}/${EventBenchConsole.jarname}"
			basedir="${build.location.eventbenchconsole}">
			<manifest>
				<attribute name="Built-By" value="${user.name}" />
				<attribute name="Main-Class" value="de.ugoe.cs.eventbench.Runner" />
				<attribute name="Class-Path" value="${dist.classpath}" />
			</manifest>
		</jar>
		<jar destfile="${dist.location.main}/${EventBenchCore.jarname}"
			basedir="${build.location.eventbenchcore}">
			<manifest>
				<attribute name="Built-By" value="${user.name}" />
			</manifest>
		</jar>
		<jar destfile="${dist.location.main}/${JavaHelperLib.jarname}"
			basedir="${build.location.javahelperlib}">
			<manifest>
				<attribute name="Built-By" value="${user.name}" />
				<attribute name="Class-Path" value="${dist.classpath}" />
			</manifest>
		</jar>
		<copy includeemptydirs="false" todir="${dist.location.main}/lib">
			<fileset dir="lib" />
		</copy>
		<copy todir="${dist.location.main}/misc">
			<fileset dir="${EventBenchConsole.location}/misc" />
		</copy>
		<copy todir="${dist.location.main}/rules">
			<fileset dir="${EventBenchConsole.location}/rules" />
		</copy>

		<!-- dist of JFCMonitor -->
		<jar destfile="${dist.location.jfcmonitor}/${JFCMonitor.jarname}"
			basedir="${build.location.jfcmonitor}">
			<manifest>
				<attribute name="Built-By" value="${user.name}" />
				<attribute name="Main-Class" value="de.ugoe.cs.eventbench.jfcmonitor.Runner" />
				<attribute name="Class-Path" value="${JavaHelperLib.jarname}" />
			</manifest>
		</jar>
		<copy todir="${dist.location.jfcmonitor}">
			<fileset file="${dist.location.main}/${JavaHelperLib.jarname}"/>
		</copy>

		<!-- copy Javadoc to dist -->
		<copy includeemptydirs="false" todir="${dist.location.javadoc}">
			<fileset dir="${javadoc.location}" />
		</copy>
	</target>


	<target depends="init.downloads,dist" name="createDownloads">
		<zip destfile="${downloads.location}/eventbench-complete.zip">
			<fileset dir="${dist.location}" />
		</zip>
		<zip destfile="${downloads.location}/eventbench-console.zip">
			<fileset dir="${dist.location.main}" />
		</zip>
		<zip destfile="${downloads.location}/eventbench-jfcmonitor.zip">
			<fileset dir="${dist.location.jfcmonitor}" />
		</zip>
		<zip destfile="${downloads.location}/eventbench-javadoc.zip">
			<fileset dir="${dist.location.javadoc}" />
		</zip>
	</target>

	<!-- Javadoc Targets -->
	<target depends="init.javadoc" name="javadoc"
		description="o Create Javadocs (Requires Javadoc 1.4+)">
		<javadoc destdir="${javadoc.location}"
			additionalparam="-J-Dorg.apache.commons.attributes.javadoc.CATaglet.sources=${basedir}">
			<classpath refid="JavaHelperLib.classpath" />
			<classpath refid="EventBenchCore.classpath" />
			<classpath refid="EventBenchConsole.classpath" />
			<classpath refid="JFCMonitor.classpath" />
			<link href="http://download.oracle.com/javase/6/docs/api/" />
			<fileset dir="${JavaHelperLib.location}/src" includes="**/*.java" />
			<fileset dir="${EventBenchCore.location}/src" includes="**/*.java" />
			<fileset dir="${EventBenchConsole.location}/src" includes="**/*.java" />
			<fileset dir="${JFCMonitor.location}/src" includes="**/*.java" />
		</javadoc>
	</target>

	<!-- JUnit Targets -->
	<target depends="init.eventbenchcore-test, emma.instrument.eventbenchcore"
		name="build.eventbenchcore-test">
		<javac debug="true" debuglevel="${debuglevel}" destdir="${test.location.eventbenchcore}"
			source="${source}" target="${target}" includeantruntime="false">
			<src path="${EventBenchCoreTest.location}/src" />
			<classpath refid="EventBenchCoreJUnitCompile.classpath" />
		</javac>
	</target>
	<target depends="init.javahelperlib-test, emma.instrument.javahelperlib"
		name="build.javahelperlib-test">
		<javac debug="true" debuglevel="${debuglevel}" destdir="${test.location.javahelperlib}"
			source="${source}" target="${target}" includeantruntime="false">
			<src path="${JavaHelperLibTest.location}/src" />
			<classpath refid="JavaHelperLibJUnitCompile.classpath" />
		</javac>
	</target>

	<target depends="emma.instrument.eventbenchcore,build.eventbenchcore-test"
		name="junit.eventbenchcore">
		<junit fork="on" printsummary="yes" haltonfailure="no">
			<classpath refid="EventBenchCoreJUnitExecute.classpath" />
			<test name="${test.eventbenchcore.main-class}" haltonfailure="no"
				outfile="${test.eventbenchcore.results}">
				<formatter type="xml" />
			</test>
			<jvmarg
				value="-Demma.coverage.out.file=${coverage.location}/eventbenchcore.emma" />
			<jvmarg value="-Demma.coverage.out.merge=true" />
		</junit>
	</target>
	<target depends="emma.instrument.javahelperlib,build.javahelperlib-test"
		name="junit.javahelperlib">
		<junit fork="on" printsummary="yes" haltonfailure="no">
			<classpath refid="JavaHelperLibJUnitExecute.classpath" />
			<test name="${test.javahelperlib.main-class}" haltonfailure="no"
				outfile="${test.javahelperlib.results}">
				<formatter type="xml" />
			</test>
			<jvmarg
				value="-Demma.coverage.out.file=${coverage.location}/javahelperlib.emma" />
			<jvmarg value="-Demma.coverage.out.merge=true" />
		</junit>
	</target>

	<target depends="junit.javahelperlib,junit.eventbenchcore" name="junit" />

	<!-- Emma Targets -->
	<target depends="build.javahelperlib, init.emma" name="emma.instrument.javahelperlib">
		<emma enabled="true">
			<instr instrpath="${build.location.javahelperlib}" destdir="${coverage.instrumented.javahelperlib}"
				metadatafile="${coverage.location}/javahelperlib.emma" merge="true" />
		</emma>
	</target>
	<target depends="build.eventbenchcore, init.emma" name="emma.instrument.eventbenchcore">
		<emma enabled="true">
			<instr instrpath="${build.location.eventbenchcore}" destdir="${coverage.instrumented.eventbenchcore}"
				metadatafile="${coverage.location}/eventbenchcore.emma" merge="true" />
		</emma>
	</target>
	<target depends="junit" name="emma.report">
		<emma enabled="true">
			<report sourcepath="${JavaHelperLib.location}">
				<fileset dir="${coverage.location}">
					<include name="*.emma" />
				</fileset>
				<xml outfile="${coverage.location}/coverage.xml" depth="method" />
			</report>
		</emma>
	</target>

	<!-- FindBugs Targets -->
	<target depends="dist" name="findbugs.javahelperlib">
		<mkdir dir="${findbugs.results.location}" />
		<findbugs home="lib-test" output="xml"
			outputFile="${findbugs.results.location}/findbugs-javahelperlib.xml">
			<auxClasspath refid="JavaHelperLib.classpath" />
			<sourcePath path="${JavaHelperLib.location}" />
			<class location="${dist.location.main}/${JavaHelperLib.jarname}" />
		</findbugs>
	</target>
	<target depends="dist" name="findbugs.eventbenchcore">
		<mkdir dir="${findbugs.results.location}" />
		<findbugs home="lib-test" output="xml"
			outputFile="${findbugs.results.location}/findbugs-eventbenchcore.xml">
			<auxClasspath refid="EventBenchCore.classpath" />
			<sourcePath path="${EventBenchCore.location}" />
			<class location="${dist.location.main}/${EventBenchCore.jarname}" />
		</findbugs>
	</target>
	<target depends="dist" name="findbugs.eventbenchconsole">
		<mkdir dir="${findbugs.results.location}" />
		<findbugs home="lib-test" output="xml"
			outputFile="${findbugs.results.location}/findbugs-eventbenchconsole.xml">
			<auxClasspath refid="EventBenchConsole.classpath" />
			<sourcePath path="${EventBenchConsole.location}" />
			<class location="${dist.location.main}/${EventBenchConsole.jarname}" />
		</findbugs>
	</target>
	<target depends="dist" name="findbugs.jfcmonitor">
		<mkdir dir="${findbugs.results.location}" />
		<findbugs home="lib-test" output="xml"
			outputFile="${findbugs.results.location}/findbugs-jfcmonitor.xml">
			<auxClasspath refid="JFCMonitor.classpath" />
			<sourcePath path="${JFCMonitor.location}" />
			<class location="${dist.location.jfcmonitor}/${JFCMonitor.jarname}" />
		</findbugs>
	</target>
	<target depends="findbugs.javahelperlib,findbugs.eventbenchcore,findbugs.eventbenchconsole,findbugs.jfcmonitor" name="findbugs" />
</project>
