<?xml version="1.0" encoding="UTF-8"?>
<project name="build-spring-webflow" default="package">
	<property file="build.properties"/>

	<path id="classpath">
		<fileset dir="/" includesfile="classpath-debian"/>
		<fileset dir="${dir.build}/dist" includes="*.jar"/>
	</path>

	<target name="init">
		<mkdir dir="${dir.build}/dist"/>
	</target>

	<target name="clean">
		<delete dir="${dir.build}"/>
		<delete file="${dir.src.spring-ldap-core}/org/springframework/ldap/core/DnParserImpl.java"/>
		<delete file="${dir.src.spring-ldap-core}/org/springframework/ldap/core/DnParserImplConstants.java"/>
		<delete file="${dir.src.spring-ldap-core}/org/springframework/ldap/core/DnParserImplTokenManager.java"/>
		<delete file="${dir.src.spring-ldap-core}/org/springframework/ldap/core/ParseException.java"/>
		<delete file="${dir.src.spring-ldap-core}/org/springframework/ldap/core/SimpleCharStream.java"/>
		<delete file="${dir.src.spring-ldap-core}/org/springframework/ldap/core/Token.java"/>
		<delete file="${dir.src.spring-ldap-core}/org/springframework/ldap/core/TokenMgrError.java"/>
		<delete includeemptydirs="true">
			<fileset dir="${dir.docs}/reference" includes="**/*"/>
		</delete>
	</target>

	<target name="compile-spring-ldap-core" depends="init">
		<javacc
			target="${dir.src.spring-ldap-core}/org/springframework/ldap/core/DnParserImpl.jj"
			outputdirectory="${dir.src.spring-ldap-core}/org/springframework/ldap/core"
			javacchome="${dir.javacchome}"
		/>
		<javac
			srcdir="${dir.src.spring-ldap-core}"
			destdir="${dir.build}"
			classpathref="classpath"
			debug="${debug}"
			source="${target}"
		/>
	</target>

	<target name="compile-spring-ldap-core-tiger" depends="jar-spring-ldap-core">
		<javac
			srcdir="${dir.src.spring-ldap-core-tiger}"
			destdir="${dir.build}"
			classpathref="classpath"
			debug="${debug}"
			source="${target}"
		/>
	</target>

	<target name="compile-spring-ldap-test" depends="init"/>

	<target name="jar-spring-ldap-core" depends="compile-spring-ldap-core">
		<mkdir dir="${dir.build}/dist"/>
		<jar
			destfile="${dist.file.spring-ldap-core}"
			basedir="${dir.build}"
			includes="org/springframework/**">
			<manifest>
				<attribute name="Class-Path" value="${classpath.spring-ldap-core}"/>
			</manifest>
		</jar>
	</target>

	<target name="jar-spring-ldap-core-tiger" depends="compile-spring-ldap-core-tiger">
		<mkdir dir="${dir.build}/dist"/>
		<jar destfile="${dist.file.spring-ldap-core-tiger}">
			<fileset dir="${dir.build}">
				<include name="org/springframework/ldap/core/simple/**"/>
			</fileset>
			<manifest>
				<attribute name="Class-Path" value="${classpath.spring-ldap-core-tiger}"/>
			</manifest>
		</jar>
	</target>

	<target name="jar-spring-ldap-test" depends="compile-spring-ldap-test"/>

	<target name="javadoc">
		<mkdir dir="${dir.build.api}"/>
		<javadoc destdir="${dir.build.api}" classpathref="classpath"
		         link="/usr/share/doc/default-jdk-doc/api/">
			<packageset dir="${dir.src.spring-ldap-core}"/>
			<packageset dir="${dir.src.spring-ldap-core-tiger}"/>
		</javadoc>
	</target>

	<target name="reference">
		<copy todir="${dir.build}/reference">
			<fileset dir="${basedir}/../docs/reference"/>
		</copy>
	</target>

	<target name="all-compile"
		depends="clean,init,compile-spring-ldap-core,compile-spring-ldap-core-tiger"/>

	<target name="all-jars"
		depends="jar-spring-ldap-core,jar-spring-ldap-core-tiger"/>

	<target name="package" depends="all-jars,javadoc"/>

</project>
