<p>I'm trying to convince my providers to use ANT instead of Rational Application Development so anyone can recompile, recheck, redeploy the solution anyplace, anytime, anyhow. :P</p>

<p>I started a build.xml for a project that generates a JAR file but stopped there and I need real examples to compare notes. My good friends! I don't have anyone close to chat about this! </p>

<p>This is my <a href="http://pastebin.ca/1094382" rel="noreferrer">build.xml</a> so far. </p>

<p><i>(*) I edited my question based in the <a href="https://stackoverflow.com/questions/4046/can-someone-give-me-a-working-example-of-a-buildxml-for-an-ear-that-deploys-in-#4298">suggestion</a> of to use pastebin.ca</i></p>

My Environment: Fedora 8; WAS 6.1 (as installed with Rational Application Developer 7)
The documentation is very poor in this area and there is a dearth of practical examples.
Using the WebSphere Application Server (WAS) Ant tasks
To run as described here, you need to run them from your server
profile
bin directory using the
ws_ant.sh
or
ws_ant.bat
commands.
```
```
<?xml version="1.0"?>
<project name="project" default="wasListApps" basedir=".">
    <description>
        Script for listing installed apps.
        Example run from:
        /opt/IBM/SDP70/runtimes/base_v61/profiles/AppSrv01/bin
    </description>

    <property name="was_home"
        value="/opt/IBM/SDP70/runtimes/base_v61/">
    </property>
    <path id="was.runtime">
        <fileset dir="${was_home}/lib">
            <include name="**/*.jar" />
        </fileset>
        <fileset dir="${was_home}/plugins">
            <include name="**/*.jar" />
        </fileset>
    </path>
    <property name="was_cp" value="${toString:was.runtime}"></property>
    <property environment="env"></property>

    <target name="wasListApps">
        <taskdef name="wsListApp"
            classname="com.ibm.websphere.ant.tasks.ListApplications"
            classpath="${was_cp}">
        </taskdef>
        <wsListApp wasHome="${was_home}" />
    </target>

</project>
```
```
Command:
```
```
./ws_ant.sh -buildfile ~/IBM/rationalsdp7.0/workspace/mywebappDeploy/applist.xml
```
```
A Deployment Script
```
```
<?xml version="1.0"?>
<project name="project" default="default" basedir=".">
<description>
Build/Deploy an EAR to WebSphere Application Server 6.1
</description>

    <property name="was_home" value="/opt/IBM/SDP70/runtimes/base_v61/" />
    <path id="was.runtime">
        <fileset dir="${was_home}/lib">
            <include name="**/*.jar" />
        </fileset>
        <fileset dir="${was_home}/plugins">
            <include name="**/*.jar" />
        </fileset>
    </path>
    <property name="was_cp" value="${toString:was.runtime}" />
    <property environment="env" />
    <property name="ear" value="${env.HOME}/IBM/rationalsdp7.0/workspace/mywebappDeploy/mywebappEAR.ear" />

    <target name="default" depends="deployEar">
    </target>

    <target name="generateWar" depends="compileWarClasses">
        <jar destfile="mywebapp.war">
            <fileset dir="../mywebapp/WebContent">
            </fileset>
        </jar>
    </target>

    <target name="compileWarClasses">
        <echo message="was_cp=${was_cp}" />
        <javac srcdir="../mywebapp/src" destdir="../mywebapp/WebContent/WEB-INF/classes" classpath="${was_cp}">
        </javac>
    </target>

    <target name="generateEar" depends="generateWar">
        <mkdir dir="./earbin/META-INF"/>
        <move file="mywebapp.war" todir="./earbin" />
        <copy file="../mywebappEAR/META-INF/application.xml" todir="./earbin/META-INF" />
        <jar destfile="${ear}">
            <fileset dir="./earbin" />
        </jar>
    </target>

    <!-- http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.javadoc.doc/public_html/api/com/ibm/websphere/ant/tasks/package-summary.html -->
    <target name="deployEar" depends="generateEar">
        <taskdef name="wsInstallApp" classname="com.ibm.websphere.ant.tasks.InstallApplication" classpath="${was_cp}"/>
        <wsInstallApp ear="${ear}" 
            failonerror="true" 
            debug="true" 
            taskname=""
            washome="${was_home}" />
    </target>

</project>
```
```
Notes:
You can only run this once! You cannot install if the app name is in use - see other tasks like
wsUninstallApp
It probably won't start the app either
You need to run this on the server and the script is quite fragile
Alternatives
I would probably use Java Management Extensions (JMX). You could write a file-upload servlet that accepts an EAR and uses the deployment MBeans to deploy the EAR on the server. You would just POST the file over HTTP. This would avoid any WAS API dependencies on your dev/build machine and could be independent of any one project.