Java Tutorial - Java Scipt : Compiling the TestUserEJB Application

Java Tutorial - Java Scipt :

Compiling the TestUserEJB Application


The following build.xml file can be used with Ant to compile the application and create a .war file for deployment into JBoss.

<?xml version=”1.0” encoding=”UTF-8”?>
<project basedir=”.” default=”compile” name=”ch14”>
<property name=”app.name” value=”ch14”/>
<property name=”jboss.home”
value=”C:/openjava/jboss-3.0.6_tomcat-4.1.18”/>
<property name=”jboss.deploy”
value=”${jboss.home}/server/default/deploy”/>
<property name=”lib.dir” value=”${jboss.home}/client”/>
<path id=”build.classpath”>
<fileset dir=”${lib.dir}”>
<include name=”*.jar”/>
</fileset>
</path>
<target name=”init”>
</target>
<target depends=”init” name=”compile”>
<javac
classpathref=”build.classpath”
debug=”true”
deprecation=”true”
destdir=”./WEB-INF/classes”
srcdir=”./WEB-INF/classes”>
</javac>
</target>
<target depends=”compile” name=”war”>
<war destfile=”${app.name}.war”
update=”no”
excludes=”build.xml”
webxml=”./WEB-INF/web.xml”>
<fileset dir=”.”>
<include name=”**/*.jar”/>
<include name=”**/*.class”/>
<include name=”**/*.java”/>
<include name=”**/*.xml”/>
<exclude name=”**/web.xml”/>
</fileset>
</war>
</target>
<target depends=”war” name=”all”/>
<target depends=”war” name=”deploy”>
<copy file=”${app.name}.war” todir=”${jboss.deploy}”/>
</target>
<target depends=”war” name=”undeploy”>
<delete file=”${jboss.deploy}/${app.name}.war”/>
</target>
</project>

The .war target compiles any code that still needs to be compiled and builds the .war file. Make certain you edit the jboss.home and app.name properties near the top of the file to reflect the values for your system. You can include the Java source code in your .war files so that they can be edited in place. If you do not want to include the source code, then remove the line in the .war task that reads:
<include name=”**/*.java”/>