<project name="Quickstart_bpel_purchase" default="deploy" basedir=".">

	<description>${ant.project.name}</description>

	<!-- Import the base Ant build script... -->
	<property file="../../../install/deployment.properties" />

	<property name="version" value="1" />

	<property name="server.dir"
	          value="${org.jboss.as.home}/server/${org.jboss.as.config}" />
	<property name="conf.dir" value="${server.dir}/conf" />
	<property name="deploy.dir" value="${server.dir}/deploy" />
	<property name="server.lib.dir" value="${server.dir}/lib" />

	<property name="sample.jar.name" value="${ant.project.name}-${version}.jar" />
	<property name="war.build.dir" location="build/war/classes" />
	<property name="ejb.build.dir" location="build/ejb/classes" />

	<path id="compile-classpath">
		<pathelement location="${org.jboss.as.home}/common/lib/servlet-api.jar" />
		<pathelement location="${org.jboss.as.home}/client/jboss-javaee.jar" />
	</path>

	<target name="deployq">
		<copy todir="${deploy.dir}" file="purchase-queue-service.xml" />
	</target>

	<target name="undeployq">
		<delete file="${deploy.dir}/purchase-queue-service.xml" />
	</target>

	<target name="makewar" description="make war">
		<!-- Compile -->
		<mkdir dir="${war.build.dir}" />
		<javac srcdir="war/src"
		       destdir="${war.build.dir}"
		       target="1.5"
		       debug="true">
			<classpath refid="compile-classpath" />
		</javac>
		<copy todir="${war.build.dir}">
			<fileset dir="war/src" includes="**/*.xml" />
		</copy>

		<!-- War -->
		<war warfile="build/${ant.project.name}.war"
		     webxml="${basedir}/war/resources/WEB-INF/web.xml">
			<classes dir="${war.build.dir}" />
			<webinf dir="${basedir}/war/resources/WEB-INF" includes="jboss-web.xml" />
		</war>
	</target>

	<target name="deploywar" depends="makewar,deployq">
		<copy todir="${deploy.dir}" file="build/${ant.project.name}.war" />
	</target>

	<target name="undeploywar">
		<delete file="${deploy.dir}/${ant.project.name}.war" />
	</target>

	<target name="makeejb">
		<!-- Compile -->
		<mkdir dir="${ejb.build.dir}" />
		<javac srcdir="ejb/src"
		       destdir="${ejb.build.dir}"
		       target="1.5"
		       debug="true">
			<classpath refid="compile-classpath" />
		</javac>

		<!-- Jar -->
		<jar destfile="build/${ant.project.name}_ejb.jar">
			<fileset dir="${ejb.build.dir}" />
		</jar>
	</target>

	<target name="deployejb" depends="makeejb,deployq">
		<copy todir="${deploy.dir}" file="build/${ant.project.name}_ejb.jar" />
	</target>

	<target name="undeployejb">
		<delete file="${deploy.dir}/${ant.project.name}_ejb.jar" />
	</target>

	<target name="deploy" depends="deploywar,deployejb">
		<echo>Deploy ${ant.project.name}</echo>
		<jar basedir="bpel" destfile="${deploy.dir}/${sample.jar.name}" />
	</target>

	<target name="undeploy" depends="undeploywar,undeployejb,undeployq">
		<echo>Undeploy ${ant.project.name}</echo>
		<delete file="${deploy.dir}/${sample.jar.name}" />
	</target>

</project>
