To deploy on build, and undeploy on clean for:
- Enterprise Application project (EAR)
- Web Application projects (WAR)
Copy this ant script to the 'build.xml' file inside your project, and change the property jboss.dir to your path:
<project>
...
<property name="jboss.dir"
value="D:/Share/Sync/Dev/tools/j/jboss-as-7.1.1.Final/standalone/deployments"/>
<target depends="-post-clean" name="post-clean"/>
<target depends="-jboss-env" name="-post-clean">
<echo>Undeploying: ${jboss.projectFile}</echo>
<delete file="${jboss.dir}/${jboss.projectFile}"/>
<delete file="${jboss.dir}/${jboss.projectFile}.${jboss.projectState}"/>
</target>
<target depends="-post-dist" name="post-dist"/>
<target depends="-jboss-env" name="-post-dist">
<echo>Deploying: ${jboss.projectFile}</echo>
<copy file="${dist.dir}/${jboss.projectFile}" todir="${jboss.dir}"/>
<delete file="${jboss.dir}/${jboss.projectFile}.failed" />
</target>
<target name="-jboss-env" >
<condition property="jboss.projectFile" value="${war.name}">
<isset property="war.name"/>
</condition>
<condition property="jboss.projectFile" value="${jar.name}">
<isset property="jar.name"/>
</condition>
<available property="jboss.projectState"
file="${jboss.dir}/${jboss.projectFile}.undeployed"
value="undeployed"/>
<available property="jboss.projectState"
file="${jboss.dir}/${jboss.projectFile}.failed"
value="failed"/>
<available property="jboss.projectState"
file="${jboss.dir}/${jboss.projectFile}.deployed"
value="deployed"/>
</target>
</project>