<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<project
	default="default"
	name="ant-timer">
	<description>
		This build file compiles, tests, packages and distributes the core
		library of the file ant-timer application.
	</description>

	<property
		name="ant.dir"
		location="ant" />

	<import
		file="${ant.dir}/build-common.xml" />
	<import
		file="${ant.dir}/build-checkstyle.xml" />
	<import
		file="${ant.dir}/build-version.xml" />
	<import
		file="${ant.dir}/build-svn.xml" />
	<import
		file="${ant.dir}/build-slowest-tests.xml" />

	<!-- declare all our classpaths  -->
	<target
		name="classpaths">
		<path
			id="compile.classpath">
			<fileset
				dir="${lib.dir}">
				<include
					name="*.jar" />
			</fileset>
		</path>

		<path
			id="junit.classpath">
			<fileset
				dir="${junit.lib.dir}">
				<include
					name="*.jar" />
			</fileset>
		</path>
	</target>

	<target
		name="classpaths-extended"
		depends="version,revision">
		<property
			name="project.name-ver"
			value="${project.name}-${project.version}-r${project.revision}" />
		<property
			name="target.name"
			value="${project.name-ver}.jar" />
		<property
			name="target.jar"
			location="${dist.dir}/${target.name}" />

		<path
			id="test.compile.classpath">
			<path
				refid="compile.classpath" />
			<pathelement
				location="${target.jar}" />
			<path
				refid="junit.classpath" />
		</path>

		<property
			name="test.classes.dir"
			location="${test.dir}/classes" />

		<path
			id="test.classpath">
			<path
				refid="test.compile.classpath" />
			<pathelement
				location="${test.classes.dir}" />
			<pathelement
				location="cfg" />
		</path>
	</target>

	<fileset
		id="ftp.upload.fileset"
		dir="${dist.dir}">
		<include
			name="*.zip" />
		<include
			name="*.zip.sha1" />
		<include
			name="*.tar.gz" />
		<include
			name="*.tar.gz.sha1" />
	</fileset>

	<target
		name="dist"
		depends="sign-jar,sign-lib,docs"
		description="Creates the distributables needed to launch the program by jnlp">

		<copy
			todir="${dist.dir}/cfg">
			<fileset
				dir="cfg" />
		</copy>
	</target>

	<target
		name="create-bin-zipfile"
		depends="sign-jar,sign-lib,docs"
		description="Create the distributable zip file">

		<property
			name="target.zip"
			location="${dist.dir}/${project.name-ver}.zip" />

		<zip
			destfile="${target.zip}"
			duplicate="fail">
			<zipfileset
				file="${target.jar}"
				prefix="${project.name-ver}" />
			<zipfileset
				dir="${doc.dir}"
				includes="**/*"
				prefix="${project.name-ver}" />
			<zipfileset
				dir="${javadoc.dir}"
				includes="**/*"
				prefix="${project.name-ver}/api" />
			<zipfileset
				dir="${dist.lib.dir}"
				includes="**/*"
				prefix="${project.name-ver}/lib" />
			<zipfileset
				dir="cfg"
				includes="**/*"
				prefix="${project.name-ver}/cfg" />
		</zip>
	</target>

	<!-- TAR file creation  -->
	<target
		name="create-bin-tar"
		depends="sign-jar,sign-lib,docs"
		description="Create the distributable tar file">

		<property
			name="target.tar"
			location="${dist.dir}/${project.name-ver}.tar" />
		<property
			name="target.tar.gz"
			location="${target.tar}.gz" />
		<property
			name="target.tar.bz2"
			location="${target.tar}.bz2" />

		<tar
			destfile="${target.tar}"
			longfile="gnu">
			<tarfileset
				file="${target.jar}"
				prefix="${project.name-ver}" />
			<tarfileset
				dir="${doc.dir}"
				includes="**/*"
				prefix="${project.name-ver}" />
			<tarfileset
				dir="${javadoc.dir}"
				includes="**/*"
				prefix="${project.name-ver}/api" />
			<tarfileset
				dir="${dist.lib.dir}"
				includes="**/*"
				prefix="${project.name-ver}/lib" />
			<tarfileset
				dir="cfg"
				includes="**/*"
				prefix="${project.name-ver}/cfg" />
		</tar>

		<gzip
			src="${target.tar}"
			destfile="${target.tar.gz}" />
		<bzip2
			src="${target.tar}"
			destfile="${target.tar.bz2}" />
	</target>

	<target
		name="all"
		depends="compile,test,checkstyle,dist,package" />

</project>


