<?xml version="1.0" encoding="EUC-JP"?>

<!--
<!DOCTYPE document SYSTEM "./dtd/document-v10.dtd">
-->

<document>
  <header>
    <title>Ant との統合/Ant Integration</title>
    <authors>
      <person name="Vincent Massol" email="vmassol@apache.org"/>
    </authors>
    <translators><person name="漆島賢二"/></translators>
  </header>

  <body>

    <s1 title="継続的インテグレーション/Continuous integration">

      <note>
        <strong>This tutorial was written when I wrote Cactus 1.2. Since then
        I have improved my command of Ant. However this tutorial has not yet
        been updated. I believe it still provides some very good
        methodology on how to use Ant, although not the latest. If you wish to
        keep track of the latest change, have a look at the Cactus build files,
        found in the source distribution.</strong>
      </note>

      <note>
        <strong>
	本チュートリアルは Cactus 1.2 を作成した時に書かれたもので、
	作者の Ant コマンドは更新されています。
	しかしながら、このチュートリアルは、まだ更新されていません。
	これは、最新のものではありませんが、
	Ant の使用法についての良い方法論を与え続けられると信じています。
	最新の更新について調べたい場合には、
	配布されたソースにある Cactus ビルドファイルを参照してください。
	</strong>
      </note>

      <p>
        A strong principle of eXtreme Programming (XP) is the continuous
        integration aspect (see the
        <link href="http://www.martinfowler.com/articles/continuousIntegration.html">
        Continuous Integration</link> article by Martin Fowler). The traditional
        approach has been
        to developing the code first, then test it and then integrate
        it with other appications. The continuous integration principle is to
        develop code, tests and integrate at the same time, i.e. at any point
        in time, you have a functioning code along with tests and integrated.
      </p>

      <p>
	エクストリームプログラミング(XP)の強力な原理は、
	継続的インテグレーションの一側面です。		
	(Martin Fowler 氏の論文<link href="http://www.martinfowler.com/articles/continuousIntegration.html">
        継続的インテグレーション</link>を参照してください。)
	古典的な開発のアプローチでは、
	まず最初にコーディングし、テストし、他のアプリケーションと統合するというものでした。
	継続的インテグレーションの原理では、
	コーディング、テスト、統合を同時に行います。
	即ち、開発者はどの時点でもテストされ、
	統合された、動作するプログラムコードを持っているのです。
      </p>

      <p>
        In order to be able to do continuous integration, you need to be able
        to automatically run the build for your application, including passing
        the unit tests (based on JUnit, Cactus, HttpUnit or others). Ant is
        the perfect tool for this task.
      </p>
      <p>
	継続的インテグレーションを行うためには、
	(JUnit、Cactus、HttpUnit、他、に基づき)
	単体テストを通すことを含めて、
	自動的にアプリケーションをビルドできなければなりません。
	Ant はこのような作業を行うための完璧なツールなのです。	
      </p>

    </s1>

    <s1 title="Ant のメリット/Ant benefits">

      <p>
        The benefits of using Ant for running unit tests are as follows :
      </p>
      <p>
        単体テストを行うために Ant を使う利点は次の通りです : 
      </p>

      <table>
        <tr>
          <th>
            メリット/Benefits
          </th>
        </tr>
        <tr>
          <td>
            Ant is written in Java and thus the same scripts can be used on
            several systems (Windows and Unix for example). Is is therefore very
            well suited for building java applications.
          </td>
        </tr>
        <tr>
          <td>
	    Ant は Java により記述されているので、
	    同じスクリプトが複数のシステムで利用可能です。
	    (例えば、Windows 及び Unix)
	    従って、Java アプリケーションを開発するのに、最適です。
          </td>
        </tr>
        <tr>
          <td>
            Ant provides enough built-in and optional tasks to be able to
            achieve almost any needed build task without needing to use
            system dependent scripts.
          </td>
        </tr>
        <tr>
          <td>
	    Ant では、
    	    システム依存のスクリプトを使わずに、
	    ビルドで必要な、ほぼ全ての事を達成できるように、
	    充分な組み込みそしてオプションのタスクが提供されています。
          </td>
        </tr>
        <tr>
          <td>
            By being able to very quickly rerun unit test you can verify that
            your tests still pass when you modify some part of your code (
            regression testing)
          </td>
        </tr>
        <tr>
          <td>
	    単体テストを迅速に再実行できるので、
	    コードを一部変更した時でも、テストに合格するか確認できます。(回帰テスト)
          </td>
        </tr>
        <tr>
          <td>
            As it is automated, it fits well in the continuous integration
            principle and your tests can thus be ran automatically and
            continously
          </td>
        </tr>
        <tr>
          <td>
	    自動化されているので、継続的インテグレーションの原理にとてもよくマッチし、
	    テストを自動的に、かつ、継続的に実行できます。
          </td>
        </tr>
      </table>

    </s1>

    <s1 title="Ant ビルドファイル作成のチュートリアル/Writing an Ant build script tutorial">

      <p>
        The sample Ant build file described below is taken from the
        <link href="downloads.html">Cactus Sample for Servlet API 2.2
        </link> project.
      </p>

      <p>
	下に示すAnt のサンプルビルドファイルは
	<link href="downloads.html">Servlet API 2.2 用 Cactus サンプル</link>
	のプロジェクトにあるものです。
      </p>

      <note>
        This section is both a tutorial for automating builds and unit testing
        with Ant and Cactus and also a best practice and methodology guide
        for using Ant in general (independent of Cactus). This is an Ant
        configuration that has been working for me on several project. Of course,
        you are free to adapt/modify it to suit your needs.
      </note>

      <note>
	本節では、
	Ant と Cactus によるビルドと単体テストの自動化のためのチュートリアル、
	そして、Antを使った一般的な最高の練習と方法論(これは Cactus
	に無関係です)について説明します。
	これは、筆者の幾つかのプロジェクトで動いていた Ant の設定です。
	もちろん、必要に応じて自由に変更して構いません。
      </note>

      <s2 title="プロジェクトのディレクトリ構造/Project directory structure">

        <p>
          Create the following directories :
        </p>
        <p>
          次のディレクトリを作成します :
        </p>

        <table>
          <tr>
            <th>
              Directory name
            </th>
            <th>
              Content of the directory
            </th>
          </tr>
          <tr>
            <td>
              <code>build</code>
            </td>
            <td>
              The Ant build file and some other ancillary files (properties file, ...)
            </td>
          </tr>
          <tr>
            <td>
              <code>conf</code>
            </td>
            <td>
              Configuration files for the project. These are the configuration
              files that will <em>not</em> be put into the runtime jar. They
              are configuration file that need to be visible and modifyable
              by a user of the project. If they were bundled in the jar they
              would be hard to modify. On the other hand, we don't want a
              proliferation of configuration files, so all <em>technical</em>
              configuration files (messages to display for errors, ...)
              should be put in the <code>src</code> directory in correct java
              packages.
            </td>
          </tr>
          <tr>
            <td>
              <code>conf/test</code>
            </td>
            <td>
              Configuration files needed for testing the project only.
            </td>
          </tr>
          <tr>
            <td>
              <code>docs</code>
            </td>
            <td>
              Project documentation.
            </td>
          </tr>
          <tr>
            <td>
              <code>docs/skins</code>
            </td>
            <td>
              Documentation skin for Stylebook (if using Stylebook).
            </td>
          </tr>
          <tr>
            <td>
              <code>docs/xdocs</code>
            </td>
            <td>
              Documentation files (XML files) for Stylebook (if using Stylebook).
            </td>
          </tr>
          <tr>
            <td>
              <code>src</code>
            </td>
            <td>
              The project sources : java files + java test files +
              properties files + test properties files + other files for
              runtime or test (XML files, ...). Note that all test files
              should begin by 'Test' or 'test' in order to easily separate them
              from other files so that in an Ant target we'll be able to include
              only the runtime files.
            </td>
          </tr>
          <tr>
            <td>
              <code>web</code>
            </td>
            <td>
              The project web files : HTML, JSP, ... (if any)
            </td>
          </tr>
        </table>

        <table>
          <tr>
            <th>
              ディレクトリ名
            </th>
            <th>
              ディレクトリの内容
            </th>
          </tr>
          <tr>
            <td>
              <code>build</code>
            </td>
            <td>
              Antビルドファイル、および補助ファイル(プロパティファイル、など)
            </td>
          </tr>
          <tr>
            <td>
              <code>conf</code>
            </td>
            <td>
		プロジェクトの設定ファイル。
		これらは、ランタイムの jar
		ファイルに<em>置かれない</em>設定ファイルです。
		これらは、プロジェクトのユーザーにより、
		参照および編集が必要な設定ファイルです。
		もし、これが jar ファイルの中に置かれていたなら、
		変更は難しかったでしょう。
		一方で、
		設定ファイルを増殖させたくはないので、
		全ての<em>技術的な</em>設定ファイル
		(エラーで表示されるメッセージなど、、)は
		正しい java パッケージの<code>src</code>
		ディレクトリに置くべきです。
            </td>
          </tr>
          <tr>
            <td>
              <code>conf/test</code>
            </td>
            <td>
		プロジェクトのテストにのみ必要な設定ファイル
            </td>
          </tr>
          <tr>
            <td>
              <code>docs</code>
            </td>
            <td>
		プロジェクトのドキュメント
            </td>
          </tr>
          <tr>
            <td>
              <code>docs/skins</code>
            </td>
            <td>
		(stylebookを使う場合)stylebook用のドキュメントテンプレート
            </td>
          </tr>
          <tr>
            <td>
              <code>docs/xdocs</code>
            </td>
            <td>
		(stylebookを使う場合)stylebook用のドキュメントファイル(XMLファイル)
            </td>
          </tr>
          <tr>
            <td>
              <code>src</code>
            </td>
            <td>
              プロジェクトのソース : java ファイル + java テストファイル +
              プロパティファイル + テストプロパティファイル
		+ ランタイムやテスト用の他のファイル(XMLファイル等)。
		Ant ターゲットにおいてランタイムファイルのみを含められるよう、
		簡単にこれらを他のファイルと区別するために、
		全てのテストファイル名は 'Test' あるいは 'test' 
		で始らなくてはなりません。
            </td>
          </tr>
          <tr>
            <td>
              <code>web</code>
            </td>
            <td>
              (もしあれば)プロジェクトのウェブファイル : HTML,JSP...
            </td>
          </tr>
        </table>

        <note>
          In the sample application provided with Cactus, we don't generate
          any web site documentation (only javadoc) so we're not using the
          stylebook-related directories and Ant targets. However we do so in
          Cactus itself, so if you need to take a look, download the Cactus
          sources.
        </note>

        <note>
	Cactus で提供されるサンプルアプリケーションにおいて、
	(javadoc 以外は)ウェブサイトのドキュメントを生成しないので、
	stylebook に関するディレクトリおよびAntのターゲットは使っていません。
	しかしながら、Cactus 自身においては、ウェブサイトドキュメントを生成しています。
	見たい場合には、Cactus のソースをダウンロードしてください。	
        </note>

        <note>
          An <code>out</code> directory will be created by the Ant build. All
          build-generated files will be put in that directory (compiled classes,
          generated javadoc documentation, test configuration files for running
          an application server, ...).
        </note>

        <note>
	<code>out</code>ディレクトリはAntのビルドにより生成されます。
	ビルドが生成した全てのファイルはこのディレクトリに置かれます。
	(コンパイルされたクラス、生成された javadoc ドキュメント,
	アプリケーションサーバーを実行するためのテスト設定ファイル、等)
        </note>

        <note>
          We don't have any <code>lib</code> directory because it is always
          better not to include dependent jars in your project whenever
          possible for the following reasons : better continuous integration
          with other libraries (meaning they also evolve and you should test
          as much as possible with the latest version to discover potential
          problems early, more lightweight downloads, less jar proliferation
          (you'll end up with tens of the same jars otherwise), more version
          control and integration checks (if your project uses 2 external
          libraries that need another third library but not in the same version
          you are in trouble !), ...
        </note>

        <note>
	我々は<code>lib</code>ディレクトリを使いたくありません。
	なぜなら、可能ならば次に示す理由により、
	プロジェクトに依存関係のある
	jar ファイルをインクルードしない方が必ず良いからです : 
	それは、
	他のライブラリとの継続的インテグレーションがやりやすいという事です。
	(これにより、進化し、
	問題発生の可能性を早く見つけるために、
	最新のバージョンでできる限り多くテストし、
	ダウンロードを軽量化し、
	jar ファイルの増殖を防ぎ、
	(さもないと、同じ 10 個の jar を持つことになります。)
	バージョンコントロールおよび結合テストが数多くできます。
	(もし、同じバージョンでないような、
	別の第3のライブラリを必要とする
	2 つの外部ライブラリをプロジェクトで使っているとしたら、
	トラブルに巻き込まれるでしょう)、、、
        </note>

      </s2>

      <s2 title="Ant のターゲットの一覧/Ant Target List">

        <p>
          Define the following targets in your <code>build.xml</code>.
        </p>
        <p>
	<code>build.xml</code>において次のターゲットを定義してください
        </p>

        <note>
          The <em>Type</em> column specify whether the target is an external
          target that can be called by the user of the build file or if it is
          an internal target, intended to be called internally by another
          target inside the build script.
        </note>
        <note>
        <em>種類</em>の列は、
	ビルドファイルのユーザーにより呼び出され得る外部ターゲットか、
	ビルドファイル内の別のターゲットにより内部的に呼び出されるはずのターゲットかを示しています。
        </note>

        <table>
          <tr>
            <th>
              Target name
            </th>
            <th>
              Description
            </th>
            <th>
              Type
            </th>
          </tr>
          <tr>
            <td>
              <jump anchor="init"><code>init</code></jump>
            </td>
            <td>
              Defines token filters, timestamp, display some information on
              screen, ...
            </td>
            <td>
              Internal
            </td>
          </tr>
          <tr>
            <td>
              <jump anchor="usage"><code>usage</code></jump>
            </td>
            <td>
              Display usage information about the targets.
            </td>
            <td>
              External
            </td>
          </tr>
          <tr>
            <td>
              <jump anchor="prepare"><code>prepare</code></jump>
            </td>
            <td>
              Set up the output directory where build generated files will be
              put and copy the java sources to this output directory,
              replacing tokens with the values defined in the <code>init</code>
              target.
            </td>
            <td>
              Internal
            </td>
          </tr>
          <tr>
            <td>
              <jump anchor="compile"><code>compile</code></jump>
            </td>
            <td>
              Compile the java sources and put the result in the output
              directory. All copies non java source files such as
              <code>.properties</code> files, XML configuration files, ...
            </td>
            <td>
              Internal
            </td>
          </tr>
          <tr>
            <td>
              <jump anchor="source"><code>source</code></jump>
            </td>
            <td>
              Generate a zipped file containing the full sources of the project
              (i.e. the whole directory structure, excluding any build
              generated files).
            </td>
            <td>
              External
            </td>
          </tr>
          <tr>
            <td>
              <jump anchor="javadoc"><code>javadoc</code></jump>
            </td>
            <td>
              Generates the javadoc of the project. This javadoc will be part
              of the project documentation, as generated by the <code>doc</code>
              target.
            </td>
            <td>
              Internal
            </td>
          </tr>
          <tr>
            <td>
              <jump anchor="doc"><code>doc</code></jump>
            </td>
            <td>
              Generates the full project documentation : javadoc + README files
              + documentation web site (using Stylebook for example).
            </td>
            <td>
              External
            </td>
          </tr>
          <tr>
            <td>
              <jump anchor="clean"><code>clean</code></jump>
            </td>
            <td>
              Remove any build generated files. In particular, delete the
              output directory.
            </td>
            <td>
              External
            </td>
          </tr>
          <tr>
            <td>
              <jump anchor="jar"><code>jar</code></jump>,
              <jump anchor="war"><code>war</code></jump>,
              <code>ear</code>, ...
            </td>
            <td>
              Generate the project runtime. If the project is a framework, it
              is usually a jar. If the project is a web application, it is
              usually a war file. If the project is an EJB application, it is
              usually either one or several jars or an ear file. Etc ...
            </td>
            <td>
              External
            </td>
          </tr>
          <tr>
            <td>
              <jump anchor="tests"><code>tests_XXX</code></jump> where XXX is
              the name of the servlet engine on which the tests run.
            </td>
            <td>
              Run the Cactus unit tests.
            </td>
            <td>
              External
            </td>
          </tr>
        </table>

        <table>
          <tr>
            <th>
              ターゲット名
            </th>
            <th>
              説明
            </th>
            <th>
              種類
            </th>
          </tr>
          <tr>
            <td>
              <jump anchor="init"><code>init</code></jump>
            </td>
            <td>
		トークンフィルター、タイムスタンプを定義し、
		スクリーン上に何らかの情報を表示します、、、
            </td>
            <td>
            	内部
            </td>
          </tr>
          <tr>
            <td>
              <jump anchor="usage"><code>usage</code></jump>
            </td>
            <td>
		ターゲットに関する使用法の情報を表示します
            </td>
            <td>
            	外部
            </td>
          </tr>
          <tr>
            <td>
              <jump anchor="prepare"><code>prepare</code></jump>
            </td>
            <td>
		出力先ディレクトリを設定します。
		このディレクトリに、
		ビルドにより生成されたファイルが置かれ、
		<code>init</code>ターゲットにおいて定義された値により、
		トークンを置換して、この出力ディレクトリに
		java のソースをコピーします。
            </td>
            <td>
            	内部
            </td>
          </tr>
          <tr>
            <td>
              <jump anchor="compile"><code>compile</code></jump>
            </td>
            <td>
		java ソースをコンパイルし、結果を出力先ディレクトリに置きます。
		<code>.properties</code> ファイルや、
		XML 設定ファイルといった全てのファイルをコピーします。
            </td>
            <td>
            	内部
            </td>
          </tr>
          <tr>
            <td>
              <jump anchor="source"><code>source</code></jump>
            </td>
            <td>
		プロジェクトの全てのソースを含んだ ZIP アーカイブを生成します。
		(即ち、ビルドにより生成されたファイルを除いた、
		ディレクトリ構造全体です。)
            </td>
            <td>
            	外部
            </td>
          </tr>
          <tr>
            <td>
              <jump anchor="javadoc"><code>javadoc</code></jump>
            </td>
            <td>
		プロジェクトの javadoc を生成します。
		<code>doc</code>ターゲットに生成されたように、
		この javadoc はプロジェクトドキュメントの一部です。
            </td>
            <td>
            	内部
            </td>
          </tr>
          <tr>
            <td>
              <jump anchor="doc"><code>doc</code></jump>
            </td>
            <td>
		プロジェクトドキュメント全体を生成します :
		javadoc + README ファイル +
		(例えば stylebook を使った)ウェブサイトのドキュメント
            </td>
            <td>
            	外部
            </td>
          </tr>
          <tr>
            <td>
              <jump anchor="clean"><code>clean</code></jump>
            </td>
            <td>
		ビルドにより生成されたファイルを全て削除します。
		特に output ディレクトリを削除します。
            </td>
            <td>
            	外部
            </td>
          </tr>
          <tr>
            <td>
              <jump anchor="jar"><code>jar</code></jump>,
              <jump anchor="war"><code>war</code></jump>,
              <code>ear</code>, ...
            </td>
            <td>
		プロジェクトのランタイムを生成します。
		プロジェクトがフレームワークの場合、通常 jar が、
		ウェブアプリケーションの場合、通常 war が、
		EJB アプリケーションの場合、通常、
		一つかそれ以上の jar か、あるいは、
		一つの ear ファイルが生成されます。
            </td>
            <td>
            	外部
            </td>
          </tr>
          <tr>
            <td>
              <jump anchor="tests"><code>tests_XXX</code></jump>
		ここで XXX はテストを実行するサーブレットエンジンの名前です。		
            </td>
            <td>
            	Cactus 単体テストを実行します
            </td>
            <td>
            	外部
            </td>
          </tr>
        </table>

      </s2>

      <anchor id="basedir"/>

      <s2 title="ステップ 1 : Ant のプロジェクトの basedir/Step 1 : The Ant project basedir">

        <p>
          You <code>build.xml</code> file being in located in
          <code>build/</code> you should set the <code>project</code> tag
          <code>basedir</code>
          attribute to '<code>..</code>' so that all other paths are relative
          to your project root directory. Indeed, the batch file (shell script)
          that was used to bootstrap Ant is located in
          <code>&lt;root&gt;/build</code>, so '<code>..</code>' is the root
          directory.
        </p>

        <p>
	他の全てのパスがプロジェクトのルートディレクトリから相対的になるように、
	<code>build/</code>ディレクトリにある<code>build.xml</code>ファイルにおいて、
	<code>project</code>タグ中の<code>basedir</code>属性を
	'<code>..</code>' に設定しなければなりません。
	実際に、
	'<code>..</code>' がルートディレクトリなので、
	Ant を起動するのに使われるバッチファイル(シェルスクリプト)は
	<code>&lt;root&gt;/build</code> にあります。
        </p>

        <p>
          Example :
        </p>
        <p>
          例 :
        </p>
<source><![CDATA[
<?xml version="1.0"?>
[...]
<project name="Cactus Sample" default="war" basedir="..">
]]></source>

      </s2>

      <s2 title="ステップ 2 : プロジェクトプロパティの初期化/Step 2 : initialization of project properties">

	<p>
          You should define as properties all values that can be factorized
          and which are used often in your build file such as source locations,
          output locations, external jar locations and names, ... You can also
          define useful file patterns there (see the sample below).
        </p>
        <p>
	ソースの場所、出力先、外部 jar の位置や名前など、
	要素に分解できて、ビルドファイル中で頻繁に使われる値はプロパティとして定義すべきです。
	そこでは便利なファイルパターンも定義できます。
	(下を参照してください)
	</p>	

        <p>
          A good principle is to defined any properties that depend on your
          environment (such as external jar locations) in a file (let's call
          it <code>build.properties</code> located either where
          <code>build.xml</code> is located or in your home directory. The
          properties defined in this file will be loaded by
          <code>build.xml</code> using the following code :
        </p>

        <p>
	プロパティを定義する良い原則は、
	(外部 jar の場所など)自分の環境に依存するどんなプロパティでも、
	一つのファイル中に定義することです。
	(<code>build.xml</code> ファイルがある場所や、
	ホームディレクトリにあったとしても、
	これを<code>build.properties</code>と呼ぶことにします。)
	このファイルで定義されたプロパティは次のような文を使って、
	<code>build.xml</code>に読み込まれます。
        </p>

<source><![CDATA[
    <!-- Give user a chance to override without editing this file
         (and without typing -D each time it compiles it) -->
    <property file="build/build.properties" />
    <property file="${user.home}/build.properties" />
]]></source>

<source><![CDATA[
    <!-- ユーザにこのファイルを編集せずに
	(さらにコンパイルするたびに -D と打たずに)
	設定を上書きするチャンスを与えます -->
    <property file="build/build.properties" />
    <property file="${user.home}/build.properties" />
]]></source>

        <p>
          Here are our properties initializations :
        </p>
        <p>
        以下にプロパティの初期化を示します :
        </p>

<source><![CDATA[
<project name="Cactus Sample" default="war" basedir="..">

    <!-- Give user a chance to override without editing this file
         (and without typing -D each time it compiles it) -->
    <property file="build/build.properties" />
    <property file="${user.home}/build.properties" />

    <!-- Generic project properties -->
    <property name="project.fullname" value="Cactus Sample"/>
    <property name="project.version" value="1.3"/>
    <property name="project.name" value="cactus-sample"/>

    <!-- Miscellaneous settings -->
    <property name="year" value="2000-2002"/>
    <property name="debug" value="on"/>
    <property name="optimize" value="off"/>
    <property name="deprecation" value="off"/>

    <!--
       ========================================================================
         Set the properties related to the source tree
       ========================================================================
    -->
    <!-- Source locations for the build -->
    <property name="src.dir" value="src"/>
    <property name="src.java.dir" value="${src.dir}/share"/>
    <property name="src.java.servlet.dir" value="${src.dir}/servlet@servlet.api@"/>
    <property name="build.dir" value="build"/>
    <property name="etc.dir" value="${build.dir}/etc"/>
    <property name="lib.dir" value="lib"/>
    <property name="conf.dir" value="conf"/>
    <property name="conf.test.dir" value="conf/test"/>
    <property name="web.dir" value="web"/>

    <!--
       ========================================================================
         Set the properties related to the build area
       ========================================================================
    -->
    <!-- Destination locations for the build (relative to the basedir as -->
    <!-- specified in the basedir attribute of the project tag)          -->
    <property name="out.dir" value="out"/>
    <property name="out.dist.dir" value="${out.dir}/dist"/>
    <property name="out.lib.dir" value="${out.dir}/lib"/>
    <property name="out.test.dir" value="${out.dir}/test"/>
    <property name="out.src.dir" value="${out.dir}/src"/>
    <property name="out.classes.dir" value="${out.dir}/classes"/>
    <property name="out.doc.dir" value="${out.dir}/doc"/>
    <property name="out.javadoc.dir" value="${out.doc.dir}/javadoc"/>
    <property name="out.conf.dir" value="${out.dir}/conf"/>

    <!-- Names of deliverables -->

    <!-- The Cactus Sample war file. This is the file that should be
         used at runtime by end users (it excludes the test classes) -->
    <property name="final.war.name" value="${out.dir}/${project.name}-@servlet.api@.war"/>

    <!-- The full sources of Cactus Sample in a zip file -->
    <property name="final.src.name" value="${out.dir}/${project.name}-src-@servlet.api@.zip"/>

    <!-- The Cactus Sample documentation in a zip : javadoc -->
    <property name="final.doc.name" value="${out.dir}/${project.name}-doc-@servlet.api@.zip"/>

    <!--
       ========================================================================
         Useful file patterns for targets
       ========================================================================
    -->
    <!-- All source files of the projet. These source files will be copied
         to the destination source directory in the prepare task -->
    <patternset id="all.src.files">

        <!-- All java files -->
        <include name="**/*.java"/>

        <!-- All doc files -->
        <include name="**/package.html"/>
        <include name="**/overview.html"/>

        <!-- All conf files (including test files) -->
        <include name="**/*.txt"/>
        <include name="**/*.xml"/>
        <include name="**/*.properties"/>

    </patternset>

    <!-- All non java files in the src directory -->
    <patternset id="all.nonjava.files">

        <!-- All conf files (including test files) -->
        <include name="**/*.txt"/>
        <include name="**/*.xml"/>
        <include name="**/*.properties"/>

    </patternset>
]]></source>

<source><![CDATA[
<project name="Cactus Sample" default="war" basedir="..">

    <!-- ユーザにこのファイルを編集せずに
	(さらにコンパイルするたびに -D と打たずに)
	設定を上書きするチャンスを与えます -->
    <property file="build/build.properties" />
    <property file="${user.home}/build.properties" />

    <!-- 一般的なプロジェクトのプロパティ -->
    <property name="project.fullname" value="Cactus Sample"/>
    <property name="project.version" value="1.3"/>
    <property name="project.name" value="cactus-sample"/>

    <!-- 種々の設定 -->
    <property name="year" value="2000-2002"/>
    <property name="debug" value="on"/>
    <property name="optimize" value="off"/>
    <property name="deprecation" value="off"/>

    <!--
       ========================================================================
         ソースツリーに関する設定
       ========================================================================
    -->
    <!-- ビルドのためのソースの場所 -->
    <property name="src.dir" value="src"/>
    <property name="src.java.dir" value="${src.dir}/share"/>
    <property name="src.java.servlet.dir" value="${src.dir}/servlet@servlet.api@"/>
    <property name="build.dir" value="build"/>
    <property name="etc.dir" value="${build.dir}/etc"/>
    <property name="lib.dir" value="lib"/>
    <property name="conf.dir" value="conf"/>
    <property name="conf.test.dir" value="conf/test"/>
    <property name="web.dir" value="web"/>

    <!--
       ========================================================================
         ビルドエリアに関するプロパティ
       ========================================================================
    -->
    <!-- ビルドのための出力先 (プロジェクトタグの basedir 属性で -->
    <!-- 指定される basedir に関するもの) -->
    <property name="out.dir" value="out"/>
    <property name="out.dist.dir" value="${out.dir}/dist"/>
    <property name="out.lib.dir" value="${out.dir}/lib"/>
    <property name="out.test.dir" value="${out.dir}/test"/>
    <property name="out.src.dir" value="${out.dir}/src"/>
    <property name="out.classes.dir" value="${out.dir}/classes"/>
    <property name="out.doc.dir" value="${out.dir}/doc"/>
    <property name="out.javadoc.dir" value="${out.doc.dir}/javadoc"/>
    <property name="out.conf.dir" value="${out.dir}/conf"/>

    <!-- 配布物の名称 -->

    <!-- Cactus サンプル war ファイル。これは、エンドユーザーにより -->
    <!-- 実行時に使われるファイルです。(テストクラスは除きます) -->
    <property name="final.war.name" value="${out.dir}/${project.name}-@servlet.api@.war"/>

    <!-- ZIP化したCactusサンプルの全ソース -->
    <property name="final.src.name" value="${out.dir}/${project.name}-src-@servlet.api@.zip"/>

    <!-- ZIP化したCactusサンプルドキュメント : javadoc -->
    <property name="final.doc.name" value="${out.dir}/${project.name}-doc-@servlet.api@.zip"/>

    <!--
       ========================================================================
         ターゲット用の便利なファイルパターン
       ========================================================================
    -->
    <!-- プロジェクトの全ソースファイル。これらのソースファイルは、
	準備タスクにおいて出力ソースディレクトリにコピーされます。-->
    <patternset id="all.src.files">

        <!-- 全 java ファイル -->
        <include name="**/*.java"/>

        <!-- 全 doc ファイル -->
        <include name="**/package.html"/>
        <include name="**/overview.html"/>

        <!-- 全 conf ファイル (テストファイルを含む) -->
        <include name="**/*.txt"/>
        <include name="**/*.xml"/>
        <include name="**/*.properties"/>

    </patternset>

    <!-- srcディレクトリにある全ての java でないファイル -->
    <patternset id="all.nonjava.files">

        <!-- 全 conf ファイル (テストファイルを含む) -->
        <include name="**/*.txt"/>
        <include name="**/*.xml"/>
        <include name="**/*.properties"/>

    </patternset>
]]></source>

      </s2>

      <anchor id="init"/>

      <s2 title="ステップ 3 : 'init' ターゲット/Step 3 : 'init' target">

        <p>
          Useful for initializing a timestamp (DSTAMP, TODAY, TSTAMP), defining
          token filters, printing some information messages, registering
          custom Ant tasks, ...
        </p>

        <p>
	タイムスタンプ(DSTAMP,TODAY,TSTAMP)を初期化したり、
	トークンフィルターを定義したり、メッセージ情報を出力したり、
	カスタム Ant タスクを登録したり、等に便利です。
        </p>

<source><![CDATA[
    <!--
       ========================================================================
         Initialize the build. Must be called by all targets
       ========================================================================
    -->
    <target name="init">

        <!-- So that we can use the ${TSTAMP}, ${DSTAMP}, ... time stamps
             in targets, if need be -->
        <tstamp/>

        <echo message="--------- ${project.fullname} ${project.version} ---------"/>
        <echo message=""/>

        <echo message="java.class.path = ${java.class.path}"/>
        <echo message=""/>
        <echo message="java.home = ${java.home}"/>
        <echo message="user.home = ${user.home}"/>
        <echo message=""/>
        <echo message="basedir = ${basedir}"/>
        <echo message=""/>
        <echo message="servlet.jar = ${servlet.jar}"/>
        <echo message="cactus.jar = ${cactus.jar}"/>
        <echo message="junit.jar = ${junit.jar}"/>
        <echo message="cactus.ant.jar = ${cactus.ant.jar}"/>

        <!-- Filters -->
        <filter token="version" value="${project.version}"/>
        <filter token="year" value="${year}"/>

        <!-- Initialize custom Ant task needed for running the server tests -->
        <taskdef name="runservertests" classname="org.apache.cactus.ant.RunServerTestsTask">
            <classpath>
                <pathelement location="${cactus.ant.jar}"/>
                <pathelement path="${java.class.path}"/>
            </classpath>
        </taskdef>

    </target>
]]></source>

<source><![CDATA[
    <!--
       ========================================================================
         ビルドの初期化をします。全てのターゲットにより呼び出されます。
       ========================================================================
    -->
    <target name="init">

        <!-- 必要であれば、${TSTAMP}, ${DSTAMP} 等、
		タイムスタンプを使えるよう -->
        <tstamp/>

        <echo message="--------- ${project.fullname} ${project.version} ---------"/>
        <echo message=""/>

        <echo message="java.class.path = ${java.class.path}"/>
        <echo message=""/>
        <echo message="java.home = ${java.home}"/>
        <echo message="user.home = ${user.home}"/>
        <echo message=""/>
        <echo message="basedir = ${basedir}"/>
        <echo message=""/>
        <echo message="servlet.jar = ${servlet.jar}"/>
        <echo message="cactus.jar = ${cactus.jar}"/>
        <echo message="junit.jar = ${junit.jar}"/>
        <echo message="cactus.ant.jar = ${cactus.ant.jar}"/>

        <!-- フィルタ -->
        <filter token="version" value="${project.version}"/>
        <filter token="year" value="${year}"/>

        <!-- サーバーテストの実行に必要なカスタムAntタスクの初期化 -->
        <taskdef name="runservertests" classname="org.apache.cactus.ant.RunServerTestsTask">
            <classpath>
                <pathelement location="${cactus.ant.jar}"/>
                <pathelement path="${java.class.path}"/>
            </classpath>
        </taskdef>

    </target>
]]></source>

      </s2>

      <anchor id="usage"/>

      <s2 title="ステップ 4 : 'usage' ターゲット/Step 4 : 'usage' targets">

        <p>
          Display a usage message.
        </p>
        <p>
          使用法メッセージの表示
        </p>

<source><![CDATA[
    <!--
       ========================================================================
         Help on usage. List available targets
       ========================================================================
    -->
    <target name="usage" depends="init">

        <echo message=""/>
        <echo message="${project.fullname} build file"/>
        <echo message="------------------------------------------------------"/>
        <echo message=""/>
        <echo message=" Available targets are :"/>
        <echo message=""/>
        <echo message=" war    --> generates the war file (default)"/>
        <echo message=" clean  --> cleans up the build directory"/>
        <echo message=" source --> generates source zip of the project"/>
        <echo message=" doc    --> generates the docs (javadoc, ...)"/>
        <echo message=" all    --> do it all at once"/>
        <echo message="            (clean, war, source, doc)"/>
        <echo message=""/>
        <echo message=" Targets for running the tests for Servlet API 2.2 :"/>
        <echo message=""/>
        <echo message=" tests_resin_12    --> run tests for Resin 1.2"/>
        <echo message=" tests_tomcat_32   --> run tests for Tomcat 3.2"/>
        <echo message=" tests_weblogic_51 --> run tests for WebLogic 5.1"/>
        <echo message=" tests_orion_14    --> run tests for Orion 1.4"/>
        <echo message=""/>

    </target>
]]></source>

<source><![CDATA[
    <!--
       ========================================================================
         使用法のヘルプ。利用可能なターゲットの一覧。
       ========================================================================
    -->
    <target name="usage" depends="init">

        <echo message=""/>
        <echo message="${project.fullname} build file"/>
        <echo message="------------------------------------------------------"/>
        <echo message=""/>
        <echo message=" 利用可能なターゲットは :"/>
        <echo message=""/>
        <echo message=" war    --> war ファイルを生成します (デフォルト)"/>
        <echo message=" clean  --> ビルドディレクトリをクリーンします"/>
        <echo message=" source --> プロジェクトのソースのZIPの生成"/>
        <echo message=" doc    --> docs の生成 (javadoc, ...)"/>
        <echo message=" all    --> 全ターゲットの実行"/>
        <echo message="            (clean, war, source, doc)"/>
        <echo message=""/>
        <echo message=" Servlet API 2.2 のテスト実行のためのターゲット :"/>
        <echo message=""/>
        <echo message=" tests_resin_12    --> Resin 1.2 のテスト実行"/>
        <echo message=" tests_tomcat_32   --> Tomcat 3.2 のテスト実行"/>
        <echo message=" tests_weblogic_51 --> WebLogic 5.1 のテスト実行"/>
        <echo message=" tests_orion_14    --> Orion 1.4 のテスト実行"/>
        <echo message=""/>

    </target>
]]></source>

      </s2>

      <anchor id="prepare"/>

      <s2 title="ステップ 5 : 'prepare' ターゲット/Step 5 : 'prepare' target">

        <p>
          This target is needed for both compiling and generating the javadoc.
          It copies all the source files from their <code>src/</code> directory
          to the <code>out</code> directory, replacing tokens in the source
          code (replacing the <code>1.3</code> by the version number
          for example).
        </p>
        <p>
	このターゲットはコンパイルおよび javadoc の生成の両方で必要です。
	ソースコード中のトークンを置換しながら、
	<code>src/</code>ディレクトリの全てのソースファイルを
	<code>out</code>ディレクトリにコピーします。
	(例えば、<code>1.3</code> をバージョン番号で置き換えます。)
        </p>

<source><![CDATA[
    <!--
       ========================================================================
         Prepare the output directory by copying the source files into it
       ========================================================================
    -->
    <target name="prepare" depends="init">

        <mkdir dir="${out.src.dir}"/>

        <!-- Copy all source files to destination dir. Apply the filters in
             order to replace the tokens for the copyright year and the
             version -->
        <copy todir="${out.src.dir}" filtering="on">
            <fileset dir="${src.java.dir}">
                <patternset refid="all.src.files"/>
            </fileset>
            <fileset dir="${src.java.servlet.dir}">
                <patternset refid="all.src.files"/>
            </fileset>
        </copy>

    </target>
]]></source>

<source><![CDATA[
    <!--
       ========================================================================
         ソースファイルをコピーして出力ディレクトリを準備
       ========================================================================
    -->
    <target name="prepare" depends="init">

        <mkdir dir="${out.src.dir}"/>

        <!-- 全ソースファイルを出力ディレクトリにコピーします。
	     トークンを著作権表示の年、およびバージョンで置換するために、
	     フィルターを適用します。-->
        <copy todir="${out.src.dir}" filtering="on">
            <fileset dir="${src.java.dir}">
                <patternset refid="all.src.files"/>
            </fileset>
            <fileset dir="${src.java.servlet.dir}">
                <patternset refid="all.src.files"/>
            </fileset>
        </copy>

    </target>
]]></source>

      </s2>

      <anchor id="compile"/>

      <s2 title="ステップ 6 : 'compile' ターゲット/Step 6 : 'compile' target">

        <p>
          The <code>compile</code> target simply compiles the java files into
          <code>.class</code> files and also copies the support files that are
          in <code>src/</code> to the directory where the class file have been
          generated.
        </p>
        <p>
	<code>compile</code> ターゲットは単に、
	java ファイルを <code>.class</code> ファイルにコンパイルし、さらに、
	<code>src/</code> にあるサポートファイルを、
	クラスファイルが生成されたディレクトリにコピーします。
        </p>

<source><![CDATA[
    <!--
       ========================================================================
         Compiles the source directory
       ========================================================================
    -->
    <!-- Preparation target for the compile target -->
    <target name="prepare-compile" depends="prepare">

        <mkdir dir="${out.classes.dir}"/>

    </target>

    <!-- Run the java compilation -->
    <target name="compile" depends="prepare-compile">

        <javac srcdir="${out.src.dir}"
            destdir="${out.classes.dir}"
            debug="${debug}"
            deprecation="${deprecation}"
            optimize="${optimize}">

            <!-- Exclude all files that are not .java source files -->

            <!-- All doc files -->
            <exclude name="**/package.html"/>
            <exclude name="**/overview.html"/>

            <!-- All conf files (including test files) -->
            <exclude name="**/*.txt"/>
            <exclude name="**/*.xml"/>
            <exclude name="**/*.properties"/>

            <classpath>
                <pathelement path="${java.class.path}"/>
                <pathelement location="${servlet.jar}"/>
                <pathelement location="${cactus.jar}"/>
            </classpath>

        </javac>

        <!-- Copies non java files that need to be in the classes directory -->
        <copy todir="${out.classes.dir}">
            <fileset dir="${src.java.dir}">
                <patternset refid="all.nonjava.files"/>
            </fileset>
            <fileset dir="${conf.test.dir}">
                <include name="cactus.properties"/>
            </fileset>
        </copy>

    </target>
]]></source>

<source><![CDATA[
    <!--
       ========================================================================
         Compiles the source directory
       ========================================================================
    -->
    <!-- Preparation target for the compile target -->
    <target name="prepare-compile" depends="prepare">

        <mkdir dir="${out.classes.dir}"/>

    </target>

    <!-- Run the java compilation -->
    <target name="compile" depends="prepare-compile">

        <javac srcdir="${out.src.dir}"
            destdir="${out.classes.dir}"
            debug="${debug}"
            deprecation="${deprecation}"
            optimize="${optimize}">

            <!-- Exclude all files that are not .java source files -->

            <!-- All doc files -->
            <exclude name="**/package.html"/>
            <exclude name="**/overview.html"/>

            <!-- All conf files (including test files) -->
            <exclude name="**/*.txt"/>
            <exclude name="**/*.xml"/>
            <exclude name="**/*.properties"/>

            <classpath>
                <pathelement path="${java.class.path}"/>
                <pathelement location="${servlet.jar}"/>
                <pathelement location="${cactus.jar}"/>
            </classpath>

        </javac>

        <!-- Copies non java files that need to be in the classes directory -->
        <copy todir="${out.classes.dir}">
            <fileset dir="${src.java.dir}">
                <patternset refid="all.nonjava.files"/>
            </fileset>
            <fileset dir="${conf.test.dir}">
                <include name="cactus.properties"/>
            </fileset>
        </copy>

    </target>
]]></source>

<source><![CDATA[
    <!--
       ========================================================================
         ソースディレクトリのコンパイル
       ========================================================================
    -->
    <!-- コンパイルターゲットのための準備ターゲット -->
    <target name="prepare-compile" depends="prepare">

        <mkdir dir="${out.classes.dir}"/>

    </target>

    <!-- java のコンパイルの実行 -->
    <target name="compile" depends="prepare-compile">

        <javac srcdir="${out.src.dir}"
            destdir="${out.classes.dir}"
            debug="${debug}"
            deprecation="${deprecation}"
            optimize="${optimize}">

            <!-- .java ソースファイル以外を除外する -->

            <!-- 全 doc ファイル -->
            <exclude name="**/package.html"/>
            <exclude name="**/overview.html"/>

            <!-- 全 conf ファイル (テストファイルを含む) -->
            <exclude name="**/*.txt"/>
            <exclude name="**/*.xml"/>
            <exclude name="**/*.properties"/>

            <classpath>
                <pathelement path="${java.class.path}"/>
                <pathelement location="${servlet.jar}"/>
                <pathelement location="${cactus.jar}"/>
            </classpath>

        </javac>

        <!-- クラスディレクトリに置く必要がある java でないファイルのコピー -->
        <copy todir="${out.classes.dir}">
            <fileset dir="${src.java.dir}">
                <patternset refid="all.nonjava.files"/>
            </fileset>
            <fileset dir="${conf.test.dir}">
                <include name="cactus.properties"/>
            </fileset>
        </copy>

    </target>
]]></source>

      </s2>

      <anchor id="source"/>

      <s2 title="ステップ 7 : 'source' ターゲット/Step 7 : 'source' target">

        <p>
          Zip up the sources for distribution.
        </p>
        <p>
          ディストリビューションのためのソースのZIPアーカイブの作成
        </p>

<source><![CDATA[
    <!--
       ========================================================================
         Generates source zip of the project
       ========================================================================
    -->
    <target name="source" depends="prepare">

        <zip zipfile="${final.src.name}" basedir=".">

            <exclude name="${out.dir}/**"/>
            <exclude name="**/*.log"/>
            <exclude name="**/*.bak"/>
            <exclude name="**/*.class"/>
            <exclude name="${build.dir}/build.properties"/>

        </zip>

    </target>
]]></source>

<source><![CDATA[
    <!--
       ========================================================================
         プロジェクトのソースの ZIP アーカイブの生成
       ========================================================================
    -->
    <target name="source" depends="prepare">

        <zip zipfile="${final.src.name}" basedir=".">

            <exclude name="${out.dir}/**"/>
            <exclude name="**/*.log"/>
            <exclude name="**/*.bak"/>
            <exclude name="**/*.class"/>
            <exclude name="${build.dir}/build.properties"/>

        </zip>

    </target>
]]></source>

      </s2>

      <anchor id="javadoc"/>

      <s2 title="ステップ 8 : 'javadoc' ターゲット/Step 8 : 'javadoc' target">

        <p>
          Generate the project's javadoc.
        </p>
        <p>
          プロジェクトの javadoc の生成
        </p>

<source><![CDATA[
    <!--
       ========================================================================
         Generate the javadoc
       ========================================================================
    -->
    <!-- Preparation target for the javadoc target -->
    <target name="prepare-javadoc" depends="prepare">

        <mkdir dir="${out.javadoc.dir}"/>

    </target>

    <!-- Generate the javadoc for the current Servlet API -->
    <target name="javadoc" depends="prepare-javadoc">

        <javadoc
            sourcepath="${out.src.dir}"
            packagenames="org.apache.cactus.sample.*"
            destdir="${out.javadoc.dir}"
            author="true"
            public="true"
            version="true"
            use="true"
            windowtitle="${project.fullname} ${project.version} for Servlet @servlet.api@ API"
            doctitle="${project.fullname} ${project.version} for Servlet @servlet.api@ API"
            bottom="Copyright &amp;copy; ${year} Apache Software Foundation. All Rights Reserved.">

            <classpath>
                <pathelement path="${java.class.path}"/>
                <pathelement location="${servlet.jar}"/>
                <pathelement location="${cactus.jar}"/>
            </classpath>

        </javadoc>

    </target>
]]></source>

<source><![CDATA[
    <!--
       ========================================================================
         javadoc の生成
       ========================================================================
    -->
    <!-- javadoc ターゲットのための準備ターゲット -->
    <target name="prepare-javadoc" depends="prepare">

        <mkdir dir="${out.javadoc.dir}"/>

    </target>

    <!-- 現在の Servlet API 用の javadoc の生成 -->
    <target name="javadoc" depends="prepare-javadoc">

        <javadoc
            sourcepath="${out.src.dir}"
            packagenames="org.apache.cactus.sample.*"
            destdir="${out.javadoc.dir}"
            author="true"
            public="true"
            version="true"
            use="true"
            windowtitle="${project.fullname} ${project.version} for Servlet @servlet.api@ API"
            doctitle="${project.fullname} ${project.version} for Servlet @servlet.api@ API"
            bottom="Copyright &amp;copy; ${year} Apache Software Foundation. All Rights Reserved.">

            <classpath>
                <pathelement path="${java.class.path}"/>
                <pathelement location="${servlet.jar}"/>
                <pathelement location="${cactus.jar}"/>
            </classpath>

        </javadoc>

    </target>
]]></source>

      </s2>

      <anchor id="doc"/>

      <s2 title="ステップ 9 : 'doc' ターゲット/Step 9 : 'doc' target">

        <p>
          Generate the project's documentation. It includes the javadoc,
          additional README files (if any) and the documentation web site
          (built using Stylebook for example, as shown in the example below).
        </p>
        <p>
	プロジェクトのドキュメントの生成。
	これには、javadoc や、
	(あれば)付加的な README ファイルや、
	ウェブサイト用のドキュメント
	(例えば、下の例のように stylebook を使って生成されます。)
	が含まれます。
        </p>

        <p>
          Example not using Stylebook :
        </p>
        <p>
          stylebook を使わない例 :
        </p>

<source><![CDATA[
    <!--
       ========================================================================
         Generate the full documentation
       ========================================================================
    -->
    <!-- Preparation target for the doc target -->
    <target name="prepare-doc" depends="javadoc">

        <mkdir dir="${out.doc.dir}"/>

    </target>

    <!-- Generate the documentation -->
    <target name="doc" depends="prepare-doc">

        <!-- Create the zipped documentation -->
        <zip zipfile="${final.doc.name}" basedir="${out.doc.dir}"/>

    </target>
]]></source>

<source><![CDATA[
    <!--
       ========================================================================
         全ドキュメントの生成
       ========================================================================
    -->
    <!-- doc ターゲットの準備ターゲットPreparation target for the doc target
    <target name="prepare-doc" depends="javadoc">

        <mkdir dir="${out.doc.dir}"/>

    </target>

    <!-- ドキュメントの生成 -->
    <target name="doc" depends="prepare-doc">

        <!-- Create the zipped documentation -->
        <zip zipfile="${final.doc.name}" basedir="${out.doc.dir}"/>

    </target>
]]></source>

        <p>
          Example using Stylebook (from the Cactus build file itself) :
        </p>
        <p>
          stylebook を使った例(Cactus ビルドファイル自身より) :
        </p>

<source><![CDATA[
    <!--
       ========================================================================
         Generate the full documentation for a given Servlet API, i.e.
         web site + javadoc
       ========================================================================
    -->
    <!-- Preparation target for the doc target -->
    <target name="prepare-doc" depends="javadoc">

        <mkdir dir="${out.doc.dir}"/>
        <mkdir dir="${out.doc.dir}/images"/>

        <!-- Copy doc-book.xml to book.xml for defining the documentation web
             site and replacing token filters (year) -->
        <delete file="${xdoc.dir}/book.xml"/>
        <copy file="${xdoc.dir}/doc-book.xml" tofile="${xdoc.dir}/book.xml"
            filtering="on"/>

        <!-- Copy the images -->
        <copy todir="${out.site.dir}/images">
            <fileset dir="${xdoc.dir}/images"/>
        </copy>

    </target>

    <!-- Generate the documentation -->
    <target name="doc" depends="prepare-doc">

        <!-- Generate the documentation web site -->
        <stylebook book="${xdoc.dir}/book.xml"
            skinDirectory="${skin.dir}/jakarta.apache.org"
            targetDirectory="${out.doc.dir}">

            <classpath>
                <pathelement path="${java.class.path}"/>
            </classpath>

        </stylebook>

    </target>
]]></source>

<source><![CDATA[
    <!--
       ========================================================================
	 与えられた Servlet API 用の全ドキュメントの生成。
	 即ち、ウェブサイト + javadoc
       ========================================================================
    -->
    <!-- doc ターゲットのための準備ターゲット -->
    <target name="prepare-doc" depends="javadoc">

        <mkdir dir="${out.doc.dir}"/>
        <mkdir dir="${out.doc.dir}/images"/>

        <!-- ドキュメントのウェブサイトを定義し、
	     トークンフィルター(year)を置換するために、
	     doc-book.xml を book.xml にコピー -->
        <delete file="${xdoc.dir}/book.xml"/>
        <copy file="${xdoc.dir}/doc-book.xml" tofile="${xdoc.dir}/book.xml"
            filtering="on"/>

        <!-- 画像のコピー -->
        <copy todir="${out.site.dir}/images">
            <fileset dir="${xdoc.dir}/images"/>
        </copy>

    </target>

    <!-- ドキュメントの生成 -->
    <target name="doc" depends="prepare-doc">

        <!-- ウェブサイトのドキュメントの生成 -->
        <stylebook book="${xdoc.dir}/book.xml"
            skinDirectory="${skin.dir}/jakarta.apache.org"
            targetDirectory="${out.doc.dir}">

            <classpath>
                <pathelement path="${java.class.path}"/>
            </classpath>

        </stylebook>

    </target>
]]></source>

      </s2>

      <anchor id="clean"/>

      <s2 title="ステップ 10 : 'clean' ターゲット/Step 10 : 'clean' target">

        <p>
          Removes all build generated files.
        </p>
        <p>
        ビルドにより生成された全ファイルの削除
        </p>

<source><![CDATA[
    <!--
       ========================================================================
         Remove all build generated files
       ========================================================================
    -->
    <target name="clean" depends="init">

        <!-- Deletes all files ending with '~' -->
        <delete>
            <fileset dir="." includes="**/*~" defaultexcludes="no"/>
        </delete>

        <!-- Remove the out directory -->
        <delete dir="${out.dir}"/>

        <!-- Delete log files -->
        <delete>
            <fileset dir=".">
                <include name="**/*.log"/>
            </fileset>
        </delete>

    </target>
]]></source>

<source><![CDATA[
    <!--
       ========================================================================
         ビルドにより生成された全ファイルの削除
       ========================================================================
    -->
    <target name="clean" depends="init">

        <!-- '~' で終る全ファイルの削除 -->
        <delete>
            <fileset dir="." includes="**/*~" defaultexcludes="no"/>
        </delete>

        <!-- 出力先ディレクトリの削除 -->
        <delete dir="${out.dir}"/>

        <!-- ログファイルの削除 -->
        <delete>
            <fileset dir=".">
                <include name="**/*.log"/>
            </fileset>
        </delete>

    </target>
]]></source>

      </s2>

      <s2 title="ステップ 11 : 'jar'、'war' ターゲット/Step 11 : 'jar', 'war' targets">

        <anchor id="jar"/>

        <s3 title="'jar' ターゲット/'jar' target">

          <p>
            This target is useful if your project is a framework for example and
            you need to deliver a jar file. We also include a manifest file
            in the jar, with version information. We copy the manifest to the
            output directory in order to replace the <code>1.3</code>
            token with it's value.
          </p>
          <p>
	  このターゲットは、例えば、自分のプロジェクトが、
	  フレームワークで 'jar' ファイルで配布する必要があるときに便利です。
	  jar ファイルには、バージョン情報を持ったマニフェストファイルも入れます。
	  <code>1.3</code> トークンを、その値に置換するために、
	  マニフェストファイルを出力ディレクトリにコピーします。
          </p>

          <p>
            Example (from the Cactus build file) :
          </p>
          <p>
            例 (Cactus ビルドファイルより) :
          </p>

<source><![CDATA[
    <!--
       ========================================================================
         Create the runtime jar file
       ========================================================================
    -->
    <!-- Preparation target for the jar target -->
    <target name="prepare-jar" depends="compile">

        <mkdir dir="${out.conf.dir}"/>
        <mkdir dir="${out.lib.dir}"/>

        <!-- Copy the manifest in order to replace the version token filter -->
        <copy todir="${out.conf.dir}" filtering="on">
            <fileset dir="${conf.dir}" >
                <include name="manifest"/>
            </fileset>
        </copy>

    </target>

    <!-- Generate the jar file -->
    <target name="jar" depends="prepare-jar">

        <jar jarfile="${final.jar.name}" basedir="${out.classes.dir}"
            manifest="${out.conf.dir}/manifest">

            <!-- Do not include test files in the runtime jar -->
            <exclude name="**/Test*.*"/>
            <exclude name="**/test*.*"/>

        </jar>

    </target>
]]></source>

<source><![CDATA[
    <!--
       ========================================================================
         ランタイム jar ファイルの生成
       ========================================================================
    -->
    <!-- jar ターゲットのための準備ターゲット -->
    <target name="prepare-jar" depends="compile">

        <mkdir dir="${out.conf.dir}"/>
        <mkdir dir="${out.lib.dir}"/>

        <!-- バージョンのトークンフィルターを置換するために、
	     マニフェストをコピー -->
        <copy todir="${out.conf.dir}" filtering="on">
            <fileset dir="${conf.dir}" >
                <include name="manifest"/>
            </fileset>
        </copy>

    </target>

    <!-- jar ファイルの生成 -->
    <target name="jar" depends="prepare-jar">

        <jar jarfile="${final.jar.name}" basedir="${out.classes.dir}"
            manifest="${out.conf.dir}/manifest">

            <!-- ランタイム jar ではテストファイルを含めない -->
            <exclude name="**/Test*.*"/>
            <exclude name="**/test*.*"/>

        </jar>

    </target>
]]></source>

        </s3>

        <anchor id="war"/>

        <s3 title="'war' ターゲット/'war' target">

          <p>
            This target is useful if you're building a web application.
            We also include a manifest file in the war, with version
            information. We copy the manifest to the output directory in order
            to replace the <code>1.3</code> token with it's value.
          </p>
          <p>
	  このターゲットはウェブアプリケーションを構築する時に便利です。
	  バージョン情報を持ったマニフェストファイルも war に入れます。
	  <code>1.3</code> トークンをその値に置換するために、
	  マニフェストを出力ディレクトリにコピーします。
          </p>

          <p>
            Example (from the Cactus sample) :
          </p>
          <p>
            例 (Cactus のサンプルより) :
          </p>

<source><![CDATA[
    <!--
       ========================================================================
         Create the runtime war file
       ========================================================================
    -->
    <!-- Preparation target for the war target -->
    <target name="prepare-war" depends="compile">

        <mkdir dir="${out.conf.dir}"/>

        <!-- Copy the manifest in order to replace the version token filter  -->
        <copy todir="${out.conf.dir}" filtering="on">
            <fileset dir="${conf.dir}" >
                <include name="manifest"/>
            </fileset>
        </copy>

    </target>

    <!-- Generate the war file -->
    <target name="war" depends="prepare-war">

        <war warfile="${final.war.name}"
             webxml="${conf.dir}/web.xml"
             manifest="${out.conf.dir}/manifest">

            <classes dir="${out.classes.dir}">
                <!-- Do not include test files in the runtime jar -->
                <exclude name="**/Test*.*"/>
                <exclude name="**/test*.*"/>

                <!-- Also exclude the test cactus.properties file -->
                <exclude name="cactus.properties"/>
            </classes>

            <fileset dir="${web.dir}">
                <exclude name="test/**"/>
            </fileset>
        </war>

    </target>
]]></source>

<source><![CDATA[
    <!--
       ========================================================================
         ランタイム war ファイルの生成
       ========================================================================
    -->
    <!-- war ターゲットの準備ターゲット -->
    <target name="prepare-war" depends="compile">

        <mkdir dir="${out.conf.dir}"/>

        <!-- バージョントークンフィルターの置換のためにマニフェストをコピー -->
        <copy todir="${out.conf.dir}" filtering="on">
            <fileset dir="${conf.dir}" >
                <include name="manifest"/>
            </fileset>
        </copy>

    </target>

    <!-- war ファイルの生成 -->
    <target name="war" depends="prepare-war">

        <war warfile="${final.war.name}"
             webxml="${conf.dir}/web.xml"
             manifest="${out.conf.dir}/manifest">

            <classes dir="${out.classes.dir}">
                <!-- テストファイルをランタイムjarから除外 -->
                <exclude name="**/Test*.*"/>
                <exclude name="**/test*.*"/>

                <!-- テスト用の cactus.properties ファイルも除外 -->
                <exclude name="cactus.properties"/>
            </classes>

            <fileset dir="${web.dir}">
                <exclude name="test/**"/>
            </fileset>
        </war>

    </target>
]]></source>

        </s3>

      </s2>

      <anchor id="tests"/>

      <s2 title="ステップ 12 : 'tests_XXX' ターゲット/Step 12 : 'tests_XXX' target">

        <p>
          The <code>tests_XXX</code> target is in charge of running the
          Cactus unit tests. It must prepare the test environment for a
          given servlet engine and package the tests, start that servlet
          engine, run the tests by starting the JUnit runner and stop the
          servlet engine.
        </p>
        <p>
	<code>tests_XXX</code> ターゲットは、
	Cactus 単体テストの実行を担当しています。
	与えられたサーブレットエンジンのテスト環境の準備をし、
	テストをパッケージ化し、サーブレットエンジンを実行し、
	JUnit runner を起動することによりテストを実行し、
	サーブレットエンジンを終了します。	
        </p>

        <p>
          See the <link href="howto_ant_cactus.html">Using Cactus with
          Ant</link> tutorial for details on to do this.
        </p>
        <p>
	これを行うための詳細については、
	<link href="howto_ant_cactus.html">Ant での Cactus の利用</link>
        のチュートリアルを見てください。
        </p>

      </s2>

    </s1>

  </body>
</document>
