Using Maven
Mavenを使用する

Congratulations! Now that you have installed Maven and/or integrated with your project, you are now ready to start reaping the benefits of Maven. The rest of this document will be a guided tour through the basic operation of Maven's build system. You will learn how to build any of the following Maven-enabled Turbine projects: Torque, Stratum, Fulcrum, and Turbine. The process for each project is the identical thanks to Maven (as are the results).

おめでとうございます! Mavenのインストールが終わって、そしてプロジェクトと統合出来ました。 これでMavenの利点を受ける準備が整いました。 この文書の残りで、Mavenビルドシステムの基本的なオペレーションを紹介します。 Mavenを使用できる以下のTurbineプロジェクトをビルドする方法を学びます: Torque、Stratum、Fulcrum、Turbine。 それぞれのプロジェクトの処理はMavenのおかげで(結果的に)全く同一です。

First, checkout the source for any of the above Turbine projects. If you do not know how to do this, please refer to the CVS Repositories document. For those familiar with the growing family of Jakarta projects, several of the projects include all of the JAR files required to build and distribute the projects in their CVS repositories. Maven eliminates this practice altogether because it provides facilities to automatically download all dependencies from one or more central repositories. Thus, before any Maven goal is executed, Maven will automatically download all of the required dependencies from the remote repositories defined by the ${maven.repo.remote} property.

最初に上記のTurbineプロジェクトのどれかのソースをチェックアウトします。 やり方が分からなければ、CVS Repositoriesを参照して下さい。 成長中のJakartaプロジェクトファミリーに詳しい人へ: いくつかのプロジェクトはビルドや配布に必要なJARファイルをCVSリポジトリに含んでいます。 Mavenは1つ以上の集中リポジトリからこれらの依存するファイルをすべて自動的にダウンロードする能力を持ちます。 そのためこれらのプラクティスは不要になります。 任意のMavenのgoalが実行される前に、${maven.repo.remote}プロパティで定義されたリモートのリポジトリから自動的にすべての必要な依存ファイルをダウンロードします。

After Maven has automatically downloaded your dependencies, they are stored in your local repository. Recall, Maven uses this directory to store all JAR files. There are two exceptions: 1) non-distributable JARs will result in a message pointing you to the location where you can download the JAR yourself, and 2) JARs that don't exist in the local or remote repositories will result in an error. In either case, you'll have to download those yourself and manually place them in $MAVEN_HOME/repository . After you have downloaded all of the dependent JARs, generating a JAR for a Maven-enabled Turbine project is easy. Type the following:

自動的に依存ファイルをダウンロードしたあと、ローカルのリポジトリに保管します。 このディレクトリをすべてのJARファイルの保管に使用することを思い出して下さい。 ただし、2つの例外があります: 1)配布されないJARはJARをダウンロード可能な場所を示すメッセージを表示します。 2)ローカルにもリモートにも存在しないJARはエラーとなります。 どちらの場合でも、自分でダウンロードして$MAVEN_HOME/repository に置く必要があります。 すべての依存するJARをダウンロードした後は、Mavenを使用可能なTurbineプロジェクトの JARを簡単に生成できます。 以下を実行して下さい:

maven java:jar

You'll notice that all of the code is compiled, and then unit tested, before it is packaged into a JAR file. The unit tests generate reports that are later parsed to create an HTML report that is part of the generated site documentation. The JAR file can also be automatically distributed.

JARファイルにパッケージングされる前に、すべてのコードがコンパイルされ、 ユニットテストが実行されるのが分かるでしょう。 ユニットテストで生成されたレポートはあとでパースされ、HTMLレポートが作成されます。 これも生成されたサイトドキュメンテーションの一部です。 JARファイルを自動的に配布することもできます。

The biggest bang for you buck right now is the generation of your site documentation. Maven will generate documentation that is consistent with the rest of the site. This list of documentation includes: developer lists, mailing lists, dependencies, unit test reports, source code metrics, change logs, JavaDocs, and cross-referenced source code (not too bad considering all you have to do is produce a project descriptor)! It will also create a standard navigation system that is added to all of your xdocs . To generate all of the documentation mentioned above, type the following:

今すぐに元気づけてくれる最大の事柄はサイトドキュメンテーションの生成です。 サイトの他の部分に関連する文書が生成されます。 この文書は以下のような種類があります: 開発者リスト、メイリングリスト、依存関係、ユニットテストのレポート、 ソースコードのメトリクス、変更ログ、JavaDoc、相互参照ソースコード。 (ひどい話ではないことに、プロジェクトディスクリプタを作成するだけで済みます) また、すべてのxdocs に追加される基本的なナビゲーションシステムも生成します。 上記のすべての文書を生成するために、以下を実行して下さい:

maven site:generate

The result of this command is a target/docs directory in the project's base directory that contains an entire web site of documentation.

このコマンドを実行すると、プロジェクトの基準ディレクトリ内の target/docsに完全なドキュメンテーションのウェブサイトが出来ます。

If you are a maintainer of the project's website, you can use Maven to publish the generated web site to a server. Maven will use the settings defined in the project descriptor to specify various settings (hostname of web server and directory on the server where the site resides) required for deployment. Type the following:

プロジェクトのウェブサイトの管理者は、 生成したサイトをMavenを使用してサーバに公開することが出来ます。 Mavenはプロジェクトディスクリプタに定義された様々な設定 (ウェブサーバのホスト名、サイトを配置するサーバのディレクトリ) に基づいて配置します。 以下を実行して下さい:

maven site:deploy

Assuming you have access to the web server, your entire site would have been published. This makes updating the project's web site very easy. It can also be easily automated. Finally, to conclude the example, you might want to clean the project directory because you are so excited about Maven that you want to try everything again! Type the following:

ウェブサーバにアクセスできるなら、完全なサイトが公開されるでしょう。 この機能はプロジェクトのウェブサイトの更新をとてもやりやすくしますし、 同時に自動化しやすくなります。 例を完結させるために、最後にプロジェクトのディレクトリを奇麗にしたくなったとします。 すっかりMavenに熱を上げてしまって、すべてをもう一度試してみたくなったのです。 以下を実行して下さい:

maven clean

For a full description of all of the Maven goals available type:

利用可能なすべてのMavenのgoalの説明を表示するには、以下を実行して下さい:

maven -g

That concludes the tour of Maven. All of the Turbine projects currently use Maven to generate their web sites, please have a look and see what Maven can do for you. The Maven-specific content can be found in the navigation section called "Maven Documentation".

これでMavenの紹介は終わりです。 現在、すべてのTurbineのプロジェクトでMavenを使用してウェブサイトを生成しています。 利用できるMavenの機能がないか、調べてみて下さい。 Mavenに特有のコンテンツは"Maven Documentation"のセクションにあります。