<project name="deployextension"  default="deploy.j2ee.web"  basedir=".">

	<property name="was.home" value="${wasHome}"/>
    <property name="module.working.dir" value="${project.working.dir}/${project.name}"></property>
	<path id="toolpath">
		<fileset dir="${was.home}/lib">
			<include name="*.jar" />
		</fileset>
		<pathelement path="${was.home}/lib/properties" />
		<pathelement path="${was.home}/optionalLibraries/jython.jar" />
	</path>

	<taskdef classpathref="toolpath" name="wsadmin" classname="com.ibm.websphere.ant.tasks.WsAdmin" />
	<taskdef classpathref="toolpath" name="wsejbdeploy" classname="com.ibm.websphere.ant.tasks.WsEjbDeploy" />	
	<taskdef classpathref="toolpath" name="wsinstallapp" classname="com.ibm.websphere.ant.tasks.InstallApplication" />	

	<target name="deploy.j2ee.web">
		<echo message="Module Working Day  ${module.working.dir} Project Working Dir=${project.working.dir} Message Dir=${module.dir} Module Name ${module.name}"></echo>
		<jar destfile="${project.working.dir}/${module.name}.war"> 
			<zipfileset dir="${module.working.dir}">
				<include name="**/*.*"/>
				<exclude name="**/*.war"/>
			</zipfileset>
		</jar>
		<wsadmin  
			washome="${was.home}" 	
			properties="${wasProfile}/properties/wsadmin.properties" 
			command="$AdminApp uninstall ${module.name}" 
			failonerror="false">
		</wsadmin>
	    <wsadmin  
			washome="${was.home}" 				
			properties="${wasProfile}/properties/wsadmin.properties" 
			command="$AdminApp install ${project.working.dir}/${module.name}.war {-appname ${module.name} -contextroot  ${contextRoot} -usedefaultbindings}" 
			failonerror="true">
		</wsadmin>
	    <wsadmin  
		  washome="${was.home}" 
		  properties="${wasProfile}/properties/wsadmin.properties" 
		  command="$AdminControl invoke [$AdminControl queryNames type=ApplicationManager,*] startApplication ${module.name}" 
		  failonerror="true">
	    </wsadmin>			
	</target>
	
	<target name="deploy.j2ee.ejb">
		<jar destfile="${project.working.dir}/${module.name}.jar"> 
			<zipfileset dir="${module.dir}">
	        	<include name="**/*.*"/>
	       		<exclude name="**/*.java"/>
			</zipfileset>
		</jar>
		<wsejbdeploy 
				inputJar="${project.working.dir}/${module.name}.jar" 
				wasHome="${was.home}" 
				washome="${was.home}" 
				classpathref="toolpath"
				outputJar="${project.working.dir}/${module.name}-was.jar" 
				codegen="true " 
				keepGenerated="true" 
				quiet="false" 
				noValidate="true" 
				noWarnings="false" 
				noInform="false" 
				compatible35="false" 
				failonerror="true" 
				trace="true" 
				jvmMaxMemory="256M" />
	
			<wsadmin  
				washome="${was.home}" 
				properties="${wasProfile}/properties/wsadmin.properties" 
				command="$AdminApp uninstall ${module.name}" 
				failonerror="false">
			</wsadmin>

		    <wsadmin  
				washome="${was.home}" 				
				properties="${wasProfile}/properties/wsadmin.properties" 
				command="$AdminApp install ${project.working.dir}/${module.name}.jar {-appname ${module.name} -usedefaultbindings}" 
				failonerror="true">
			</wsadmin>

			<wsadmin  
			  washome="${was.home}" 
			  properties="${wasProfile}/properties/wsadmin.properties" 
			  command="$AdminControl invoke [$AdminControl queryNames type=ApplicationManager,*] startApplication ${module.name}" 
			  failonerror="true">
		    </wsadmin>	
	</target>
	
	<target name="deploy.j2ee.ear">
		<jar destfile="${project.working.dir}/${module.name}.ear"> 
			<zipfileset dir="${module.dir}">
	        	<include name="**/*.*"/>
	       		<exclude name="**/*.java"/>
			</zipfileset>
		</jar>

		<wsadmin  
					washome="${was.home}" 
					properties="${wasProfile}/properties/wsadmin.properties" 
					command="$AdminApp uninstall ${module.name}" 
					failonerror="false">
		</wsadmin>

		<wsadmin  
					washome="${was.home}" 				
					properties="${wasProfile}/properties/wsadmin.properties" 
					command="$AdminApp install ${project.working.dir}/${module.name}.ear {-appname ${module.name} -deployejb -usedefaultbindings}" 
					failonerror="true">
		</wsadmin>
		<wsadmin  
				  washome="${was.home}" 
				  properties="${wasProfile}/properties/wsadmin.properties" 
				  command="$AdminControl invoke [$AdminControl queryNames type=ApplicationManager,*] startApplication ${module.name}" 
				  failonerror="true">
		 </wsadmin>	
		
	</target>	
	
	<target name="undeploy.j2ee.web">
		
		<wsadmin  
			washome="${was.home}" 
			
			properties="${wasProfile}/properties/wsadmin.properties" 
			command="$AdminApp uninstall ${module.name}" 
			failonerror="false">
		</wsadmin>
	</target>
	<target name="undeploy.j2ee.ejb">
		<wsadmin  
			washome="${was.home}" 
			
			properties="${wasProfile}/properties/wsadmin.properties" 
			command="$AdminApp uninstall ${module.name}" 
			failonerror="false">
		</wsadmin>
	</target>	
	
	<target name="undeploy.j2ee.ear">
		<wsadmin  
			washome="${was.home}" 
			
			properties="${wasProfile}/properties/wsadmin.properties" 
			command="$AdminApp uninstall ${module.name}" 
			failonerror="false">
		</wsadmin>
	</target>	

</project>
