<?xml version="1.0" encoding="UTF-8"?>
<project name="package-top-level">

	<target name="package" description="Creates the release package for this project">
		<delete dir="${package.output.dir}" quiet="true"/>
		<mkdir dir="${package.output.dir}"/>
		<delete file="${package.output.file}" quiet="true"/>
		<mkdir dir="${artifacts.dir}"/>

		<all-bundles target="package">
			<property name="package.output.dir" value="${package.output.dir}"/>
		</all-bundles>

		<ant target="javadoc-api" inheritAll="false">
			<property name="target.dir" value="${package.docs.dir}"/>
		</ant>

		<ant dir="../spring-webflow-reference" target="doc" inheritAll="false">
			<property name="package.output.dir" value="${package.output.dir}"/>
			<propertyset>
				<propertyref builtin="commandline"/>
			</propertyset>
			<property name="timestamp" value="${timestamp}"/>
		</ant>

		<subant target="package" verbose="true" buildpath="../spring-webflow-reference">
			<property name="package.output.dir" value="${package.output.dir}"/>
			<propertyset>
				<propertyref builtin="commandline"/>
			</propertyset>
			<property name="timestamp" value="${timestamp}"/>
		</subant>

		<copy todir="${package.output.dir}">
			<fileset dir="${basedir}/resources"/>
		</copy>

		<copy todir="${package.output.dir}/projects">
			<fileset dir="${basedir}/..">
				<exclude name="**/target/**"/>
				<exclude name="integration-repo/**"/>
				<exclude name="ivy-cache/repository/org.apache.velocity/org.apache.velocity.docbookframework.dist/**"/>
				<exclude name="spring-build/lib/docbook/**" />
				<exclude name="**/*OLD*/**"/>
			</fileset>
		</copy>

		<replaceregexp match="build.stamp.*\n" replace="" flags="g"
				file="${package.output.dir}/projects/build.properties"/>

		<replaceregexp match="release.type=.*" replace="release.type=integration" flags="g"
				file="${package.output.dir}/projects/build.properties"/>

		<zip destfile="${package.output.file}">
			<zipfileset dir="${package.dir}">
				<exclude name="${package.basename}/projects/ivy-cache/**"/>
			</zipfileset>
		</zip>

		<zip destfile="${artifacts.dir}/${package.basename}-with-dependencies.zip">
			<zipfileset dir="${package.dir}"/>
		</zip>
	</target>

</project>
