jboss 4.0.4 GA的build文件
jboss文档中,构建、部署及初始化duke's bank应用的步骤如下:
第一步、Compiling the Java Source
ant -f jboss-build.xml compile第二步、Package the EJBs
ant -f jboss-build.xml package-ejb第三步、Package the WAR File
ant -f jboss-build.xml package-web第四步、Package the Java Client
ant -f jboss-build.xml package-client第五步、Assembling the EAR
ant -f jboss-build.xml assemble-app第六步、Creating the Database Schema:
to create the necessary tables
ant -f jboss-build.xml db-create-tablepopulate them with the required data.
ant -f jboss-build.xml db-insert第七步、Deploying the Application
ant -f jboss-build.xml deploy详细build文件如下:
<project name="jboss-dukes-bank" default="all" basedir="."> <property file="../../jboss-build.properties"/> <property name="lib.dir" value="../../libs"/> <property name="src.dir" value="${basedir}/src"/> <property name="build.dir" value="${basedir}/build"/> <!-- The classpath for running the client --> <path id="client.classpath"> <pathelement location="${build.dir}"/> <fileset dir="${jboss.home}/client"> <include name="**/*.jar"/> </fileset> </path> <!-- The build classpath --> <path id="build.classpath"> <path refid="client.classpath"/> <fileset dir="${jboss.server}/lib/"> <include name="javax.servlet*.jar"/> </fileset> </path> <!-- Hypersonic SQL classpath --> <path id="hsql.classpath"> <pathelement location="${jboss.server}/lib/hsqldb.jar"/> </path> <!-- =================================================================== --> <!-- Initialises the build. --> <!-- =================================================================== --> <target name="prepare"> <mkdir dir="${build.dir}"/> </target> <!-- ================================================================ --> <!-- Compiles the source code --> <!-- ================================================================ --> <target name="compile" depends="prepare"> <javac destdir="${build.dir}" classpathref="build.classpath" debug="on"> <src path="${src.dir}"/> </javac> </target> <target name="package-ejb" depends="compile"> <mkdir dir="jar" /> <delete file="jar/account-ejb.jar"/> <jar jarfile="jar/bank-ejb.jar"> <metainf dir="dd/ejb" includes="**/*.xml" /> <fileset dir="${build.dir}"> <include name="com/sun/ebank/util/**"/> <include name="com/sun/ebank/ejb/**" /> </fileset> </jar> </target> <target name="package-ws"> <mkdir dir="jar" /> <delete file="jar/bankws-ejb.jar"/> <jar jarfile="jar/bankws-ejb.jar"> <metainf dir="dd/ws" includes="**/*" /> <fileset dir="${build.dir}"> <include name="com/jboss/ebank/**" /> <include name="com/sun/ebank/ejb/account/AccountController**"/> <include name="com/sun/ebank/ejb/exception/**"/> <include name="com/sun/ebank/util/**"/> </fileset> </jar> </target> <target name="package-client" depends="compile"> <mkdir dir="jar" /> <copy todir="${build.dir}"> <fileset dir="${src.dir}"> <include name="**/appclient/*.properties"/> </fileset> <mapper type="flatten"/> </copy> <delete file="jar/app-client.jar"/> <jar jarfile="jar/app-client.jar"> <metainf dir="dd/client" includes="*.xml"/> <fileset dir="${build.dir}"> <include name="com/sun/ebank/appclient/**"/> <include name="com/sun/ebank/ejb/exception/**"/> <include name="com/sun/ebank/util/**"/> <include name="com/sun/ebank/ejb/customer/Account.class"/> <include name="com/sun/ebank/ejb/customer/AccountHome.class"/> </fileset> <fileset dir="dd/client"> <include name="jndi.properties"/> </fileset> <fileset dir="${src.dir}/com/sun/ebank/"> <include name="appclient/*.properties"/> </fileset> </jar> </target> <target name="package-web" depends="compile"> <mkdir dir="jar" /> <delete file="jar/web-client.war"/> <copy file="web/WebMessages.properties" tofile="web/WebMessages_en.properties" /> <war warfile="jar/web-client.war" webxml="dd/web/web.xml"> <fileset dir="web"> <include name="*.jsp"/> <include name="template/*"/> <include name="images/*.gif"/> </fileset> <webinf dir="dd/web"> <include name="jboss-web.xml"/> </webinf> <webinf dir="web"> <include name="*.tld"/> <exclude name="*.jsp"/> <exclude name="*.txt"/> <exclude name="images/**"/> </webinf> <webinf dir="jar"> <include name="*.tld"/> </webinf> <lib dir="${lib.dir}"> <include name="jstl.jar"/> <include name="standard.jar"/> </lib> <classes dir="${build.dir}"> <include name="**/*.class"/> <exclude name="com/sun/ebank/appclient/**"/> <exclude name="com/sun/ebank/ejb/**"/> <exclude name="com/sun/ebank/util/**"/> </classes> <classes dir="web"> <include name="*.properties"/> </classes> </war> </target> <target name="wstool"> <taskdef name="wstools" classname="org.jboss.ws.tools.ant.wstools"> <classpath refid="build.classpath" /> </taskdef> <wstools dest="dd/ws" config="wstools-config.xml"/> </target> <target name="deploy-ws"> <copy file="jar/bankws-ejb.jar" todir="${jboss.server}/deploy"/> </target> <target name="run-ws"> <java classname="com.jboss.ebank.WSClient" fork="true"> <jvmarg value="-Djava.endorsed.dirs=${jboss.home}/lib/endorsed" /> <classpath> <path refid="client.classpath"/> <pathelement path="${java.class.path}"/> </classpath> </java> </target> <target name="ws" depends="wstool,package-ws,deploy-ws"> </target> <!-- Creates an ear file containing the ejb jars and the web client war. --> <target name="assemble-app"> <delete file="jar/JBossDukesBank.ear"/> <ear destfile="jar/JBossDukesBank.ear" appxml="dd/application.xml"> <fileset dir="jar" includes="*-ejb.jar,app-client.jar,*.war,*.wsr"/> <fileset dir="src" includes="users.properties,roles.properties"/> </ear> </target> <!-- Deploys the EAR file by copying it to the JBoss deploy directory. --> <target name="deploy" depends="assemble-app"> <copy file="jar/JBossDukesBank.ear" todir="${jboss.server}/deploy"/> </target> <!-- Run the standalone client --> <target name="run-client"> <echo>${java.class.path}</echo> <java classname="com.sun.ebank.appclient.BankAdmin" fork="yes"> <classpath> <pathelement path="jar/app-client.jar"/> <path refid="client.classpath"/> <pathelement path="${java.class.path}"/> </classpath> </java> </target> <!-- Call the HSQL ScriptTool utility. --> <target name="db-create-table"> <java classname="org.hsqldb.util.ScriptTool" fork="yes"> <arg value="-url"/> <arg value="jdbc:hsqldb:hsql:"/> <arg value="-database"/> <arg value="//localhost:1701"/> <arg value="-script"/> <arg value="sql/hsql-create-table.sql"/> <classpath refid="hsql.classpath"/> </java> </target> <target name="db-insert"> <java classname="org.hsqldb.util.ScriptTool" fork="yes"> <arg value="-url"/> <arg value="jdbc:hsqldb:hsql:"/> <arg value="-database"/> <arg value="//localhost:1701"/> <arg value="-script"/> <arg value="sql/hsql-insert.sql"/> <classpath refid="hsql.classpath"/> </java> </target> <target name="db-list"> <java classname="org.hsqldb.util.ScriptTool" fork="yes"> <arg value="-url"/> <arg value="jdbc:hsqldb:hsql:"/> <arg value="-database"/> <arg value="//localhost:1701"/> <arg value="-script"/> <arg value="sql/hsql-list.sql"/> <classpath refid="hsql.classpath"/> </java> </target><!-- <target name="db-delete"> <java classname="org.hsqldb.util.ScriptTool" fork="yes"> <arg value="-url"/> <arg value="jdbc:hsqldb:hsql:"/> <arg value="-database"/> <arg value="//localhost:1701"/> <arg value="-script"/> <arg value="sql/delete.sql"/> <classpath refid="hsql.classpath"/> </java> </target> <target name="db-reset-key"> <java classname="org.hsqldb.util.ScriptTool" fork="yes"> <arg value="-url"/> <arg value="jdbc:hsqldb:hsql:"/> <arg value="-database"/> <arg value="//localhost:1701"/> <arg value="-script"/> <arg value="sql/hsql-reset-key.sql"/> <classpath refid="hsql.classpath"/> </java> </target>--> <target name="clean"> <delete dir="${build.dir}" /> <mkdir dir="${build.dir}" /> </target> <target name="db-all" depends="db-create-table,db-insert,db-list" /> <target name="all" depends="compile,package-ejb,package-web,package-client,assemble-app,deploy" /></project>