Project: Marauroa
Code Location: git://arianne.git.sourceforge.net/gitroot/arianne/marauroa.gitperception_json
Browse
/
Download File
build.xml
<?xml version='1.0'?>
<project name="marauroa" default="dist" basedir="." xmlns:jacoco="antlib:org.jacoco.ant">
	<property file="build.ant.properties"/>

	<property name="jarname" value="marauroa-${version}.jar"/>
	<property name="jarname_client" value="marauroa-client-only-${version}.jar"/>

	<path id="compile-classpath">
		<pathelement path="${log4j_jar}"/>
		<pathelement path="${junit_jar}"/>
		<pathelement path="${jnlp_jar}"/>
		<pathelement path="${jython_jar}"/>
		  <fileset dir="${libdir}">
		    <include name="jetty*.jar"/>
		    <include name="servlet*.jar"/>
		  	<include name="socketio*.jar" />
		  </fileset>
	</path>
	
	<path id="compile-tests-classpath">
		<path refid="compile-classpath" />
		<path location="${build-classes}" />
	</path>
	
	<path id="run-tests-classpath">
		<path refid="compile-tests-classpath" />
		<pathelement location="${h2_jar}"/>
		<pathelement path="${build-tests}" />
		<pathelement path="."/>
	</path>
	
	<!-- Clears the instalation -->
	<target name="clean">
		<delete dir="${build}"/>
		<delete dir="${docs}"/>
		<delete dir="${build-archive}"/>
		<delete dir="${dist}"/>
	</target>

	<!-- Create the initial folders for the build -->
	<target name="init">
		<mkdir dir="${build-archive}" />
		<mkdir dir="${build}" />
		<mkdir dir="${build-classes}" />
		<mkdir dir="${build-tests}" />
		<mkdir dir="${build-tests-report}" />
		<mkdir dir="${build-coverage}" />
		<mkdir dir="${dist}" />
		<mkdir dir="${docs}" />
	</target>

	<!-- Compiles the project -->
	<target name="compile" depends="init">
		<!-- Exclude python support if jython.jar is not present -->
		<condition property="exclude.python" value="**/python/*.*">
			<not>
				<available file="${jython_jar}"/>
			</not>
		</condition>

		<!-- Exclude junit support if junit is not present -->
		<condition property="exclude.junit" value="**/*tests/*.*">
			<not>
				<available file="${junit_jar}"/>
			</not>
		</condition>

		<!-- exclude.web -->
		<condition property="exclude.web" value="**/web/*.*">
			<or>
				<not>
					<available file="${servletapi_jar}"/>
				</not>
				<not>
					<available file="${socketio_jar}"/>
				</not>
			</or>
		</condition>
		
		<!-- Update version number. -->
		<replaceregexp file="${src}/marauroa/server/marauroad.java"
                   match="private static final String VERSION = &quot;.*&quot;;"
                   replace="private static final String VERSION = &quot;${version}&quot;;"
                   byline="true"/>

		<!-- Compile it -->
		<javac srcdir="${src}" source="1.5" target="1.5" destdir="${build-classes}" debug="true" debuglevel="source,lines" includes="**/marauroa/**" excludes="${exclude.python};${exclude.junit};${exclude.web}" includeantruntime="false">
			<compilerarg line="-encoding utf-8"/>
			<classpath refid="compile-classpath" />
		</javac>

		<copy todir="${build-classes}/marauroa/server/">
			<fileset dir="${src}/marauroa/server">
				<include name="*.sql"/>
				<include name="*.properties"/>
			</fileset>
		</copy>
	</target>


	<!-- Compiles the project -->
	<target name="compile-client">
		<delete dir="${build-client}" quiet="true" />
		<mkdir dir="${build-client}"/>
		
		<!-- Compile it -->
		<javac srcdir="${src}" source="1.5" target="1.5" destdir="${build-client}" debug="true" debuglevel="source,lines" includeantruntime="false">
			<compilerarg line="-encoding utf-8"/>
			<include name="marauroa/client/**"/>
			<include name="marauroa/common/**"/>
			<classpath>
				<pathelement path="${log4j_jar}"/>
				<pathelement path="${jnlp_jar}"/>
			</classpath>
		</javac>
	</target>


	<!-- Generate Java docs -->
	<target name="docs" depends="compile">
		<javadoc packagenames="marauroa.*"
           defaultexcludes="yes"
           destdir="${docs}"
           author="true"
           version="true"
           use="true"
           windowtitle="Marauroa API Documentation Version: ${version}">
			<classpath refid="compile-classpath" />
			<packageset dir="src" defaultexcludes="yes" />
		</javadoc>
	</target>

	<!-- Create jar file for Marauroa -->
	<target name="jar-all" depends="compile">
		<jar jarfile="${build-archive}/${jarname}" basedir="${build-classes}/">
			<manifest>
				<attribute name="Main-Class" value="marauroa.server.marauroad"/>
			</manifest>
		</jar>
		<copy tofile="${build-archive}/marauroa.jar" file="${build-archive}/${jarname}"/>
	</target>

	<!-- Create jar file for Marauroa -->
	<target name="jar-client" depends="compile-client">
		<jar jarfile="${build-archive}/${jarname_client}" basedir="${build-client}/" />
	</target>

	<target name="jar" depends="jar-all, jar-client" />

	<!-- Prepare the tarball for releases -->
	<target name="dist_binary" depends="jar">
		<replaceregexp file="${extras}/marauroad.bat"
                   match="set LOCALCLASSPATH=.*"
                   replace="set LOCALCLASSPATH=.;marauroa-${version}.jar;${jython_jar};${h2_jar};${connectorJ_jar};${log4j_jar};${servlet_jar};${socketio_jar};${jetty_client_jar};${jetty_continuation_jar};${jetty_http_jar};${jetty_io_jar};${jetty_security_jar};${jetty_server_jar};${jetty_servlet_jar};${jetty_util_jar};${jetty_webapp_jar};${jetty_websocket_jar};${jetty_xml_jar}"
                   byline="true"/>
		<replaceregexp file="${extras}/marauroad"
	    	       match="export LOCALCLASSPATH=.*"
    	    	   replace="export LOCALCLASSPATH=.:libs/marauroa-${version}.jar:${jython_jar}:${h2_jar}:${connectorJ_jar}:${log4j_jar}:${servlet_jar}:${socketio_jar}:${jetty_client_jar}:${jetty_continuation_jar}:${jetty_http_jar}:${jetty_io_jar}:${jetty_security_jar}:${jetty_server_jar}:${jetty_servlet_jar}:${jetty_util_jar}:${jetty_webapp_jar}:${jetty_websocket_jar}:${jetty_xml_jar}"
                   byline="true"/>

		<mkdir dir="marauroa-${version}"/>
		<mkdir dir="marauroa-${version}/libs"/>
		<copy todir="marauroa-${version}" file="${extras}/marauroad.bat"/>
		<copy todir="marauroa-${version}" file="${extras}/marauroad"/>
		<copy todir="marauroa-${version}" file="${build-archive}/${jarname}"/>
		<copy todir="marauroa-${version}" file="${build-archive}/${jarname_client}"/>
		<copy todir="marauroa-${version}/libs">
			<fileset dir="${libdir}">
				<exclude name="jnlp.jar" />
				<exclude name="junit-4.4jar" />
			</fileset>
		</copy>
		<copy todir="marauroa-${version}" file="AUTHORS.txt"/>
		<copy todir="marauroa-${version}" file="CHANGES.txt"/>
		<copy todir="marauroa-${version}" file="LICENSE.txt"/>
		<copy todir="marauroa-${version}" file="README.txt"/>
		<zip destfile="${dist}/marauroa-${version}.zip" basedir="marauroa-${version}"/>
		<delete dir="marauroa-${version}"/>
	</target>

	<target name="dist_docs" depends="docs">
		<mkdir dir="marauroa-${version}"/>
		<copy todir="marauroa-${version}/${docs}">
			<fileset dir="${docs}"/>
		</copy>
		<copy todir="marauroa-${version}" file="AUTHORS.txt"/>
		<copy todir="marauroa-${version}" file="CHANGES.txt"/>
		<copy todir="marauroa-${version}" file="LICENSE.txt"/>
		<copy todir="marauroa-${version}" file="README.txt"/>
		<zip destfile="${dist}/marauroa-${version}-docs.zip" basedir="marauroa-${version}"/>
		<delete dir="marauroa-${version}"/>
	</target>


	<target name="dist_source" depends="docs">
		<mkdir dir="marauroa-${version}"/>
		<copy todir="marauroa-${version}/src">
			<fileset dir="src"/>
		</copy>
		<copy todir="marauroa-${version}/tests">
			<fileset dir="tests"/>
		</copy>
			<copy todir="marauroa-${version}/functional_tests">
				<fileset dir="functional_tests"/>
			</copy>
		<copy todir="marauroa-${version}/extras">
			<fileset dir="extras"/>
		</copy>
		<copy todir="marauroa-${version}/libs">
			<fileset dir="libs"/>
		</copy>
		<copy todir="marauroa-${version}" file="build.xml"/>
		<copy todir="marauroa-${version}" file="build.ant.properties"/>
		<copy todir="marauroa-${version}" file="AUTHORS.txt"/>
		<copy todir="marauroa-${version}" file="CHANGES.txt"/>
		<copy todir="marauroa-${version}" file="LICENSE.txt"/>
		<copy todir="marauroa-${version}" file="README.txt"/>

		<tar destfile="${dist}/marauroa-${version}-src.tar.gz" compression="gzip">
			<tarfileset dir="marauroa-${version}" prefix="marauroa-${version}">
				<exclude name="**/CVS/**"/>
			</tarfileset>
		</tar>

		<delete dir="marauroa-${version}"/>
	</target>

	<!-- builds the whole project for releasing -->
	<target name="dist" depends="dist_binary, dist_docs, dist_source"/>
	
	<!-- testing targets -->
	<target name="compile-tests" depends="compile">
		<javac srcdir="${src-test}" source="1.5" target="1.5" destdir="${build-tests}" debug="true" debuglevel="source,lines" includes="**/marauroa/**" excludes="${exclude.python};${exclude.junit}" includeantruntime="false">
			<compilerarg line="-encoding utf-8"/>
			<classpath refid="compile-tests-classpath" />
		</javac>
		<copy todir="${build-tests}">
			<fileset dir="${src-test}">
				<include name="**/*.*" />
				<exclude name="**/*.java" />
				<exclude name="**/*.ini" />
			</fileset>
		</copy>
		<copy file="${test-server-ini}" tofile="./server.ini" />
	</target>
	
	<target name="run-tests" depends="compile-tests">
		<junit printsummary="yes" fork="yes">
			<jvmarg value="-Djava.awt.headless=true"/>
			<classpath refid="run-tests-classpath" />
			<formatter type="plain" usefile="false"/>
			<formatter type="xml"/>
			<batchtest todir="${build-tests-report}">
				<fileset dir="${src-test}">
					<include name="**/*Test.java"/>
					<include name="**/Test*.java"/>
				</fileset>
			</batchtest>
		</junit>
		<delete file="./server.ini" />
	</target>

	<target name="coverage" depends="compile-tests">
		<jacoco:coverage>
			<junit printsummary="yes" fork="yes">
				<jvmarg value="-Djava.awt.headless=true"/>
				<classpath refid="run-tests-classpath" />
				<formatter type="plain" usefile="false"/>
				<formatter type="xml"/>
				<batchtest todir="${build-tests-report}">
					<fileset dir="${src-test}">
						<include name="**/*Test.java"/>
						<include name="**/Test*.java"/>
					</fileset>
				</batchtest>
			</junit>
		</jacoco:coverage>
		<delete file="./server.ini" />
	</target>
	
	<target name="coverage-report" depends="coverage">
	    <jacoco:report>
	        <executiondata>
	            <file file="jacoco.exec" />
	        </executiondata>
	        <structure name="${ant.project.name}">
	            <classfiles>
	                <fileset dir="${build-classes}" />
	            </classfiles>
	            <sourcefiles encoding="UTF-8">
	                <fileset dir="${src}" />
	            </sourcefiles>
	        </structure>
	        <html destdir="${build-coverage}" />
	    	<xml destfile="${build-coverage}/jacoco.xml" />
	    </jacoco:report>
	</target>
	
</project>