<?xml version="1.0"?>
<!--
  $Header: /home/harald/repos/remotetea.sf.net/remotetea/build.xml,v 1.7 2008/01/05 17:21:45 haraldalbrecht Exp $
  
  build.xml - contains the ANT rules for building Remote Tea
  
  -->

<project name="Remote Tea" default="jar" basedir=".">

	<!-- -->
	<property name="buildDir" value="classes" />
	<property name="srcDir" value="src/main/java" />
	<property name="testSrcDir" value="src/test/java" />
	<property name="javadocDir" value="javadoc" />
	<property name="distDir" value="dist" />
	<property name="infoDir" value="information/src/main/resources/META-INF" />
	
	<property name="distVersion" value="1.1.6" />
	
	<!-- Preset the javac task -->
	<presetdef name="javac">
		<javac destdir="${buildDir}" includeantruntime="false"
			source="1.8" target="1.8" debug="true" deprecation="true" optimize="true"/>
	</presetdef>
	
	<target name="clean" description="cleans up all build artifacts">
		<delete dir="${distDir}"/>
		<delete dir="${javadocDir}"/>
		<delete dir="${buildDir}"/>
	</target>
	
	<!-- Provide the build directory -->
	<target name="provide.builddir" description="Provide the build directory">
		<mkdir dir="${buildDir}"/>
	</target>
	
	<!-- -->
	<!-- ** SF patch #943219: add compile target ** -->
	<!-- Compile classes -->
	<target name="oncrpc.compile" depends="provide.builddir" description="compile classes of jrpcgen">
		<javac>
			<src path="oncrpc/${srcDir}" />
		</javac>
	</target>
	
	<target name="jrpcgen.compile" depends="oncrpc.compile" description="compile classes of jrpcgen">
		<javac includeantruntime="true">
			<src path="jrpcgen/${srcDir}" />
		</javac>
	</target>

	<target name="jportmap.compile" depends="oncrpc.compile" description="compile classes of jrpcgen">
		<javac>
			<src path="jportmap/${srcDir}" />
		</javac>
	</target>

	<target name="compile" depends="oncrpc.compile, jrpcgen.compile, jportmap.compile" description="compile classes" />

	<!-- Generate JAR files:
	     * oncrpc.jar contains the ONC/RPC client and server functionality,
	     * jrpcgen.jar contains the x-file protocol compiler,
	     * jportmap.jar contains an ONC/RPC portmapper including base libraries
	       (so older JREs have no problems executing it standalone).
	  -->
	<!-- ** SF patch #943219: add compile target / compile dependency ** -->
	<target name="jar" description="generate jar files" depends="compile">
		<delete file="${buildDir}/oncrpc.jar"/>
		<jar 
				jarfile="${buildDir}/oncrpc.jar"
				basedir="${buildDir}"
				includes="org/acplt/oncrpc/*.class,org/acplt/oncrpc/server/*.class">
			<manifest>
				<attribute name="Extension-Name" value="ONC/RPC"/>
				<attribute name="Specification-Title" value="Open Network Computing Remote Procedure Call (core)"/> 
				<attribute name="Specification-Version" value="2.0"/> 
				<attribute name="Specification-Vendor" value="Sun Microsystems, Inc"/> 
				<attribute name="Implementation-Title" value="Open Network Computing Remote Procedure Call (core)"/> 
				<attribute name="Implementation-Version" value="${distVersion}"/>  
				<attribute name="Implementation-Vendor" value="RemoteTea SF Project"/> 
			</manifest>
		</jar>
		<delete file="${buildDir}/jrpcgen.jar"/>
		<!-- ** SF patch #943215: include Ant task with jrpcgen.jar ** -->
		<jar
				jarfile="${buildDir}/jrpcgen.jar"
				basedir="${buildDir}"
				includes="org/acplt/oncrpc/apps/jrpcgen/**/*.class,org/acplt/oncrpc/ant/*.class">
			<manifest>
				<attribute name="Main-Class" value="org.acplt.oncrpc.apps.jrpcgen.jrpcgen"/>
				<attribute name="Extension-Name" value="ONC/RPC"/>
				<attribute name="Specification-Title" value="Open Network Computing Remote Procedure Call (rpcgen)"/> 
				<attribute name="Specification-Version" value="unknown (rpcgen x.x)"/> 
				<attribute name="Specification-Vendor" value="Sun Microsystems, Inc"/> 
				<attribute name="Implementation-Title" value="Open Network Computing Remote Procedure Call (rpcgen)"/> 
				<attribute name="Implementation-Version" value="${distVersion}"/>  
				<attribute name="Implementation-Vendor" value="RemoteTea SF Project"/> 
			</manifest>
		</jar>
		<delete file="${buildDir}/portmap.jar"/>
		<jar
				jarfile="${buildDir}/portmap.jar"
				basedir="${buildDir}"
				includes="org/acplt/oncrpc/*.class,org/acplt/oncrpc/server/*.class,org/acplt/oncrpc/apps/jportmap/*.class">
			<manifest>
				<attribute name="Main-Class" value="org.acplt.oncrpc.apps.jportmap.jportmap"/>
				<attribute name="Extension-Name" value="ONC/RPC"/>
				<attribute name="Specification-Title" value="Open Network Computing Remote Procedure Call (rpcbind)"/> 
				<attribute name="Specification-Version" value="2.0"/> 
				<attribute name="Specification-Vendor" value="Sun Microsystems, Inc"/> 
				<attribute name="Implementation-Title" value="Open Network Computing Remote Procedure Call (rpcbind)"/> 
				<attribute name="Implementation-Version" value="${distVersion}"/>  
				<attribute name="Implementation-Vendor" value="RemoteTea SF Project"/> 
			</manifest>
		</jar>
	</target>
	
	<!-- Generate JavaDoc -->
	<target name="javadoc" description="generate JavaDoc documentation files">
		<delete dir="${javadocDir}"/>
		<mkdir dir="${javadocDir}" />
		<javadoc
				destdir="${javadocDir}"
				author="on">
			<fileset dir=".">
				<include name="oncrpc/${srcDir}/**/*.java" />
				<include name="jrpcgen/${srcDir}/**/*.java" />
				<include name="jportmap/${srcDir}/**/*.java" />
			</fileset>
			<package name="org.acplt.oncrpc" />
			<package name="org.acplt.oncrpc.server" />
			<package name="org.acplt.oncrpc.web" />
			<package name="org.acplt.oncrpc.apps.jrpcgen" />
			<package name="org.acplt.oncrpc.apps.jportmap" />
			<package name="org.acplt.oncrpc.apps.ant" />
		</javadoc>
	</target>

	<!-- Generate SF file packages -->
	<target name="sf" description="generate SF file packages"
		    depends="jar,javadoc">
		<echo>generating SF file packages for version ${distVersion}...</echo>
		<mkdir dir="${distDir}"/>
		<!-- binary plus documentation distribution -->
		<zip zipfile="${distDir}/remotetea-bin-doc-${distVersion}.zip">
			<zipfileset dir="${infoDir}" prefix="remotetea/" />
			<zipfileset dir="." prefix="remotetea/">
				<include name="${buildDir}/*.jar" />
				<include name="${javadocDir}/" />
			</zipfileset>
		</zip>
		<!-- source only distribution -->
		<zip zipfile="${distDir}/remotetea-src-${distVersion}.zip">
			<zipfileset dir="." prefix="remotetea/">
				<include name="build.xml" />
				<include name="pom.xml" />
				<include name="oncrpc/" />
				<include name="jrpcgen/" />
				<include name="jportmap/" />
				<include name="maven-plugin/" />
				<include name="information/" />
				<exclude name="**/target/" />
				<exclude name="**/.settings/" />
				<exclude name="**/.project" />
				<exclude name="**/.classpath" />
			</zipfileset>
		</zip>
	</target>

	<!-- compile Jrpcgen test example and compile resulting Java files -->
	<target name="jrpcgen-test" description="run jrpcgen test" depends="compile">
		<echo>Cleaning up example mess...</echo>
		<delete><!-- make a fresh start so we don't get bitten by damaged example source code -->
			<fileset dir="jrpcgen/${testSrcDir}/tests/org/acplt/oncrpc/jrpcgen"
				     includes="*.java"
			         excludes="demoClientExample.java demoServer.java PredefinedType*.java"/>
		</delete>
		<echo>Running Jrpcgen x protocol compiler on demo.x...</echo>
		<java classname="org.acplt.oncrpc.apps.jrpcgen.jrpcgen"
		      classpath="${buildDir}"
			  dir="jrpcgen/${testSrcDir}/tests/org/acplt/oncrpc/jrpcgen"
			  fork="yes">
			<arg value="-verbose"/>
			<arg value="-ser"/>
			<arg value="-bean"/>
			<arg value="-p"/>
			<arg value="tests.org.acplt.oncrpc.jrpcgen"/>
			<arg value="-nobackup"/>
			<arg value="demo.x"/>
		</java>
		<echo>Running Jrpcgen x protocol compiler on demo2.x...</echo>
		<java classname="org.acplt.oncrpc.apps.jrpcgen.jrpcgen"
		      classpath="${buildDir}"
			  dir="jrpcgen/${testSrcDir}/tests/org/acplt/oncrpc/jrpcgen"
			  fork="yes">
			<arg value="-verbose"/>
			<arg value="-debug" />
			<arg value="-p"/>
			<arg value="tests.org.acplt.oncrpc.jrpcgen"/>
			<arg value="-nobackup"/>
			<arg value="-noenum"/> 
			<arg value="demo2.x"/>
		</java>
		<echo>Compiling example mess...</echo>
		<javac srcdir="jrpcgen/${testSrcDir}/tests/org/acplt/oncrpc/jrpcgen" />
		<echo>Succeeded.</echo>
	</target>
	
</project>

<!-- End of build.xml -->
