Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

このコマンドを入力すると、antはjboss-build.xmlファイル中に定義してあるターゲットを使って大学祭アプリケーションをビルドし、JBossサーバーにデプロイします。<target name="deploy" ...>, にご注目ください。jboss-build.xml中のこの箇所でWARファイルをデプロイする場所を指定しています。以下の例でjboss-build.xmlファイル中の定義を示します。

Code Block
xmlxml
borderStylesolid
titlejboss-build.xml
xml
<?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 を示します。

xml
Code Block
xml
borderStylesolid
titleJBoss deployment descriptor
xml
<?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ツールで生成されたものです。

xml
Code Block
xml
borderStylesolid
titleGeronimo specific deployment plan geronimo-web.xml
xml
<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の例です。

xml
Code Block
xml
borderStylesolid
titlebuild.xml
xml
<?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>

...