CLOVER🍀

That was when it all began.

マルチプロジェクト構成のMavenプロジェクトで、特定のサブプロジェクトのゴールを実行する

Mavenでのマルチプロジェクト構成に慣れていないので、いざ使ってちょっと調べてみたことをメモ。

例えば、以下のようなプロジェクト構成の場合に、

pom.xml (parent)
sub-1/pom.xml
sub-2/pom.xml
sub-3/pom.xml

sub-2のみのtestを実行したいという場合。

以下のコマンドを実行します。実行ディレクトリは、親pomがある場所です(サブプロジェクトのディレクトリには入らない)。

$ mvn -pl sub-2 -am test

ここで、「-pl」は「--projects」オプションの短縮形、「-am」は「--also-make」オプションの短縮形みたいです。

-rf, --resume-from
Resume reactor from specified project
-pl, --projects
Build specified reactor projects instead of all projects
-am, --also-make
If project list is specified, also build projects required by the list
-amd, --also-make-dependents
If project list is specified, also build projects that depend on projects on the list

http://stackoverflow.com/questions/1612854/build-single-module-from-multimodule-pom

その他、参考)
https://maven.apache.org/guides/mini/guide-multiple-modules.html