...
このコマンドを入力すると、antはjboss-build.xmlファイル中に定義してあるターゲットを使って大学祭アプリケーションをビルドし、JBossサーバーにデプロイします。<target name="deploy" ...>, にご注目ください。jboss-build.xml中のこの箇所でWARファイルをデプロイする場所を指定しています。以下の例でjboss-build.xmlファイル中の定義を示します。
Code Block |
---|
| xml |
---|
| xml |
---|
borderStyle | solid |
---|
title | jboss-build.xmlxml |
---|
|
<?xml version="1.0"?>
<!-- build file for building a war -->
<project name="build" default="war" basedir=".">
<property file="build.properties"/>
<property name="src.dir" value="src"/>
<property name="dest.dir" value="bin"/>
<target name="clean" description="Delete all generated files">
<echo message="Deleting bin directory" />
<delete dir="bin" />
</target>
<target name="compile">
<mkdir dir="${dest.dir}"/>
<javac srcdir="${src.dir}" destdir="${dest.dir}">
<classpath path="${java.home}/lib/tools.jar"/>
<classpath path="${j2ee.home}/lib/j2ee.jar"/>
</javac>
</target>
<target name="war" depends="compile">
<war destfile="college_fest.war" webxml="WEB-INF/web.xml">
<zipfileset dir="jsp" prefix="jsp"/>
<zipfileset dir="pix" prefix="pix"/>
<classes dir="${dest.dir}"/>
<webinf dir="WEB-INF" />
</war>
</target>
<target name="deploy" depends="war">
<copy file="college_fest.war" todir="${jboss.server}/deploy"/>
</target>
<target name="undeploy">
<delete file="${jboss.server}/deploy/college_fest.war"/>
</target>
</project>
|
Antのビルドで作成されたwarはJBoss固有のデプロイメント記述子を含んでいます。下記にWARのWEB-INFディレクトリー中の jboss-web.xml を示します。
Code Block |
---|
| xml |
---|
| xml |
---|
borderStyle | solid |
---|
title | JBoss deployment descriptorxml |
---|
|
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<context-root>college_fest</context-root>
<context-priority-classloader>
false
</context-priority-classloader>
</jboss-web>
|
...
Note |
---|
以下のgeronimo-web.xmlはJ2Gツールで生成されたものです。 |
Code Block |
---|
| xml |
---|
| xml |
---|
borderStyle | solid |
---|
title | Geronimo specific deployment plan geronimo-web.xmlxml |
---|
|
<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1"
xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1"
xmlns:security="http://geronimo.apache.org/xml/ns/security-1.1"
xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.1">
<sys:environment>
<sys:moduleId>
<sys:groupId>j2g</sys:groupId>
<sys:artifactId>web-module</sys:artifactId>
<sys:version>1.0</sys:version>
<sys:type>war</sys:type>
</sys:moduleId>
<sys:dependencies/>
</sys:environment>
<context-root>college_fest</context-root>
</web-app>
|
...
Antを使ってサンプルの大学祭アプリケーションをビルドした際には、デフォルトのbuild.xmlの代わりにjboss-build.xml を使用しました。以下がデフォルトのbuild.xmlの例です。
Code Block |
---|
| xml |
---|
| xml |
---|
borderStyle | solid |
---|
title | build.xmlxml |
---|
|
<?xml version="1.0"?>
<!-- build file for building a war -->
<project name="build" default="war" basedir=".">
<property file="build.properties"/>
<property name="src.dir" value="src"/>
<property name="dest.dir" value="bin"/>
<target name="clean" description="Delete all generated files.">
<echo message="Deleting bin folder" />
<delete dir="bin"/>
</target>
<target name="compile">
<mkdir dir="${dest.dir}"/>
<javac srcdir="${src.dir}" destdir="${dest.dir}">
<classpath path="${java.home}/lib/tools.jar"/>
<!--classpath path="${j2ee.home}/lib/j2ee.jar"/-->
<classpath path="${geronimo.home}/repository/org/apache/geronimo/specs/geronimo-servlet_2.5_spec/1.1/geronimo-servlet_2.5_spec-1.1.jar" />
</javac>
</target>
<target name="war" depends="compile">
<war destfile="college_fest.war" webxml="WEB-INF/web.xml">
<zipfileset dir="jsp" prefix="jsp"/>
<zipfileset dir="pix" prefix="pix"/>
<classes dir="${dest.dir}"/>
<webinf dir="WEB-INF" />
</war>
</target>
</project>
|
...