ant task to deploy/undeploy war on jboss

JBoss AS7 has a deployment scanner enabled by default, so you can just copy the war file to ${jboss.home}/standalone/deployments and it will automatically be deployed, ie:

<copy file="${war.path}" todir="${jboss.home}/standalone/deployments"/>      
(
We can just use this sentence to deploy war whatever it exists.)

Once the war is deployed, a file called ${war.filename}.war.deployed will appear in the deployments directory. To undeploy a war, delete the related .deployed file, ie:

<delete file="${jboss.deployments.dir}/${war.filename}.war.deployed"/>

Once the war has been undeployed, there will be a file called ${jboss.deployments.dir}/${war.filename}.war.undeployed in the deployments directory.

To prompt a redeployment, you can either delete the .undeployed file, or create a file with the same name as the war and a .dodeploy extension, ie:

<touch file="${jboss.deployments.dir}/${war.filename}.war.dodeploy"/>

This StackOverflow post has an example of an Ant task for an undeploy followed by a deploy.

Obviously, for the above to work you need to declare the various properties used somewhere, ie:

<property name="war.filename" value="mywar"/>
<property name="war.path" value="dir/mywar.war"/>
<property name="jboss.deployments.dir" value="${jboss.home}/standalone/deployments"/>
posted @ 2013-06-14 13:55  wangle100  阅读(470)  评论(0编辑  收藏  举报