<project name="publish"  basedir="." xmlns:oracle="antlib:oracle">
	<import file="oracle/ant-oracle.xml"/>
		
	<!-- Only localhost is currently supported by this implementation -->
	<property name="oc4j.host" value="localhost"/> 

	<property name="deployer.uri" value="deployer:oc4j:${oc4j.host}:${oc4j.admin.port}" />
	
	<target name="check.skip.web.deploy">
		<uptodate property="skip.deploy" targetfile="${server.publish.dir}/${module.name}.war">
			<srcfiles dir="${module.dir}">
				<include name="**/*.*"/>
				<exclude name="**/*.war"/>
				<exclude name="**/*.java"/>
			</srcfiles>
		</uptodate>
	</target>
	
	<target name="check.skip.ejb.deploy">
		<uptodate property="skip.deploy" targetfile="${server.publish.dir}/${module.name}.jar">
			<srcfiles dir="${module.dir}">
				<include name="**/*.*"/>
				<exclude name="**/*.java"/>
			</srcfiles>
		</uptodate>
	</target>
	
	<target name="check.skip.ear.deploy">
		<uptodate property="skip.deploy" targetfile="${server.publish.dir}/${module.name}.ear">
			<srcfiles dir="${module.dir}">
				<include name="**/*.*"/>
				<exclude name="**/*.java"/>
			</srcfiles>
		</uptodate>
	</target>
	
	<target name="package.module.web">
		<jar destfile="${server.publish.dir}/${module.name}.war"> 
			<zipfileset dir="${module.dir}">
				<include name="**/*.*"/>
				<exclude name="**/*.war"/>
				<exclude name="**/*.java"/>
			</zipfileset>
		</jar>
	</target>
		
	<target name="package.module.ejb">
		<jar destfile="${server.publish.dir}/${module.name}.jar"> 
			<zipfileset dir="${module.dir}">
				<include name="**/*.*"/>
				<exclude name="**/*.java"/>
			</zipfileset>
		</jar>
	</target>
		
	<target name="package.module.ear">
		<jar destfile="${server.publish.dir}/${module.name}.ear"> 
			<zipfileset dir="${module.dir}">
				<include name="**/*.*"/>
				<exclude name="**/*.java"/>
			</zipfileset>
		</jar>
	</target>	
	
	<target name="deploy.j2ee.web" depends="check.skip.web.deploy" unless="skip.deploy">
		<antcall target="package.module.web"/>
		<oracle:deploy
			deployerUri="${deployer.uri}" 
			userId="${oc4j.admin.user}"
			password="${oc4j.admin.password}"
			file="${server.publish.dir}/${module.name}.war"
			deploymentName="${module.name}"
			contextRoot="${module.name}"
			bindAllWebApps="${oc4j.bind.website}"/>
	</target>
	
	<target name="deploy.j2ee.ejb" depends="check.skip.ejb.deploy" unless="skip.deploy" >
		<antcall target="package.module.ejb"/>
		<oracle:deploy
			deployerUri="${deployer.uri}" 
			userId="${oc4j.admin.user}"
			password="${oc4j.admin.password}"
			file="${server.publish.dir}/${module.name}.jar"
			deploymentName="${module.name}"
			bindAllWebApps="${oc4j.bind.website}"/>
	</target>
	
	<target name="deploy.j2ee.ear" depends="check.skip.ear.deploy" unless="skip.deploy">
		<antcall target="package.module.ear"/>
		
		<oracle:deploy
			deployerUri="${deployer.uri}" 
			userId="${oc4j.admin.user}"
			password="${oc4j.admin.password}"			
			file="${server.publish.dir}/${module.name}.ear"
			deploymentName="${module.name}"
			bindAllWebApps="${oc4j.bind.website}"/>
	</target>
	
	<target name="undeploy.j2ee.module">
		<oracle:undeploy
			deployerUri="${deployer.uri}"
			userId="${oc4j.admin.user}"
			password="${oc4j.admin.password}"
			deploymentName="${module.name}"/>
	</target>
	
</project>
