This Ant script should work for the standard Dynamic Web Project project structure:
Create Ant build.xml with the replacement of two properties at the beginning:
<?xml version="1.0" encoding="UTF-8"?> <project name="Deploy From Eclipse to JBoss" basedir="." default="deploy"> <property name="warfile" value="MyProject"/> <property name="deploy" value="/home/honza/jboss-as-7.1.1.Final/standalone/deployments"/> <target name="create"> <war destfile="${warfile}.war" webxml="WebContent/WEB-INF/web.xml" update="true"> <classes dir="build\classes"/> <fileset dir="WebContent"> <exclude name="WEB-INF/web.xml"/> </fileset> </war> </target> <target name="copy"> <copy todir="${deploy}" overwrite="true"> <fileset dir="."> <include name="${warfile}.war"/> </fileset> </copy> </target> <target name="clear"> <delete includeemptydirs="true"> <fileset dir="${deploy}" defaultexcludes="false"> <include name="${warfile}.*/**" /> </fileset> </delete> </target> <target name="deploy"> <antcall target="create"/> <antcall target="clear"/> <antcall target="copy"/> </target> </project>
Now you need to command "ant" to create a WAR and copy them to JBoss. JBoss automatically deploys wars that are in the deployment directory.
To start automatically after build (Project-Build) add this build file here:
MyProject - Properties - New - Ant builder
Honza
source share