# マルチモジュール構成プロジェクト用実行時オプション

マルチモジュール構成のプロジェクトにおける`mvn`コマンドの使い方を紹介していきます。

## すべてのモジュールをビルドする

すべてのモジュールをinstallしたい場合は、普段どおりで構いません。モジュールのビルド順はMavenが計算してくれます。

```bash
mvn install
```

## 特定のモジュールだけをビルドする

`--projects`オプションを使うことで、特定のモジュールだけをビルドできます。 たとえば次のコマンドはcoreモジュールだけをinstallします。

```bash
mvn install --projects core
```

なお`--projects`の代わりに`-pl`と短縮して書くことも可能です。

## 指定モジュールが依存しているモジュールもすべてビルドする

`--projects`オプションだけでは指定モジュールが依存しているモジュールはビルドされないため、それらの最新版を使っての ビルドにはなりません。依存モジュールのビルドも必要な場合には、`--also-make`オプションを利用しましょう。 Mavenはモジュール間の依存関係を自動的に計算して、依存モジュールをどの順にビルドするべきかも判断してくれます。

たとえばcoreモジュールとそれが依存するモジュールだけinstallしたい場合は、次のようにコマンドを実行します。

```bash
mvn install --also-make --projects core
```

なお`--also-make`は`-am`と短縮して書くことも可能です。

## 指定モジュールに依存しているモジュールもすべてビルドする

自分がモジュールに加えた変更が他のモジュールに悪影響を与えていないことを確認するために、変更したモジュールに 依存するすべてのモジュールをビルドしたいこともあるでしょう。その場合は`--also-make-dependents`を使用します。

```bash
mvn install --also-make-dependents --projects core
```

なお`--also-make-dependents`は`-amd`と短縮して書くことも可能です。

## 途中のモジュールからビルドを再開（--resume-fromオプション）

ビルドが失敗してそれを修正した場合、ビルドを最初からやり直す必要はありません。修正したモジュールからビルドを再開することで、 ビルドにかかる時間を短縮できます。ビルドを開始したいモジュールを`--resume-from`で指定してください。

```bash
mvn install --also-make --projects core --resume-from test
```

なお`--resume-from`は`-rf`と短縮して書くことも可能です。

## 並列ビルド（--threadsオプション）

Maven3では複数モジュールを同時にビルドする`--threads`オプションが提供されています。 非対応のプラグインがあること、実験的な実装であることに注意が必要ですが、CPUがボトルネックになっている ビルドを高速化したい場合には利用を検討できます。

* [Parallel builds in Maven 3](https://cwiki.apache.org/confluence/display/MAVEN/Parallel+builds+in+Maven+3)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://maven3.kengo-toda.jp/module/option.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
