<?xml version="1.0" encoding="UTF-8"?>
<project name="Jboss 5.0 Ear Deployment with Servlet and JSP" default="all" basedir=".">

	<property name="dirs.base" value="${basedir}" />
	<property name="src" value="${dirs.base}/src" />
	<property name="web" value="${dirs.base}/WebContent" />
	<property name="classdir" value="${web}/WEB-INF/classes" />
	<property name="deploymentdescription" value="${dirs.base}/build/deploymentdescriptors" />
	<property name="dir.deploy.folder" value="C:\JavaHonk\jboss-6.1.0.Final\server\default\deploy" />

	<property name="warFile" value="EarDeploymentJbossServlet.war" />
	<property name="earFile" value="EarDeploymentJbossServlet.ear" />

	<property name="earDir" value="${dirs.base}/build/ear" />
	<property name="warDir" value="${dirs.base}/build/war" />

	<target name="clean" description="Remove all generated files.">
		<delete dir="${warDir}/WEB-INF" />
		<delete dir="${warDir}/WEB-INF/classes" />
		<delete file="${earDir}/${warFile}" />
		<delete file="${dirs.base}/${earFile}" />
		<echo message="Cleaned" />
	</target>

	<target name="clean_folder" description="Remove all generated files.">
		<delete dir="${warDir}/WEB-INF" />
		<delete dir="${warDir}/WEB-INF/classes" />
		<delete file="${earDir}/${warFile}" />
		<delete file="${dirs.base}/${earFile}" />
		<echo message="Cleaned" />
	</target>

	<!-- Main target -->
	<target name="all" depends="clean,buildWar,buildEar,deploy,clean_folder" />

	<!-- Create the War File -->
	<target name="buildWar">
		<fileset dir="${classdir}" includes="**/*.class" />
		<fileset dir="${web}" includes="web.xml" />
		<fileset dir="${web}" includes="**/*.*" />
		<!-- Create war file and place in ear directory -->
		<jar jarfile="${earDir}/${warFile}" basedir="${web}" />
	</target>

	<!-- Create the Ear File -->
	<target name="buildEar">
		<fileset dir="${deploymentdescription}" includes="application.xml" />
		<!-- Create ear file and place in ear directory -->
		<jar jarfile="${dirs.base}/${earFile}" basedir="${earDir}" />
	</target>

	<target name="deploy">
		<copy todir="${dir.deploy.folder}" overwrite="yes">
			<fileset file="EarDeploymentJbossServlet.ear" />
		</copy>
		<echo message="deployed" />
	</target>

</project>