私はほぼ同じ2つのプロファイルを持っています。それぞれの設定を複製するのではなく、あるプロファイルを他のプロファイルから「継承」したいのですが、maven 3を使用してこれを行う明確な方法はわかりません。Mavenプロファイルは別のMavenプロファイルから継承できますか?
mavenではプロファイルの継承が可能ですか?
私はほぼ同じ2つのプロファイルを持っています。それぞれの設定を複製するのではなく、あるプロファイルを他のプロファイルから「継承」したいのですが、maven 3を使用してこれを行う明確な方法はわかりません。Mavenプロファイルは別のMavenプロファイルから継承できますか?
mavenではプロファイルの継承が可能ですか?
いいえ、プロファイルを継承することはできません。
しかし、複数のアクティブなプロファイルを持つことができます。これにより、2つのプロファイルの共通要素を他の2つのプロファイルのいずれかをアクティブにするたびにアクティブ化する3つ目のプロファイルに分解することで、
厳密に言えば、親pomで定義されたプロファイルは、Mavenのドキュメントのように、子プロセスでは利用できません。ただし、親pomsで指定されているプロパティおよびビルドプラグイン(pluginManagementではなく)はアクティブになり、子ポームのビルド環境を変更できます。たとえば 私は、次のプロファイルセクションを持つ親ポンポンA、持っている場合:
</profiles>
<profile>
<id>integrationTest</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<parallel>none</parallel>
<excludes>
<exclude>**/*Test.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<includes
<include>**/*IT.java</include>
</includes>
<!-- need to exclude nothing as it is possible that some by default some tests are excluded and we need to override that -->
<excludes>
<exclude>none</exclude>
</excludes>
<parallel>none</parallel>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
そして、デフォルトのビルドで構成されたフェイルセーフプラグインを持っていますが、経由POMを継承していない子ポンポンBを親タグを開き、子pomディレクトリから「mvn clean install -P integrationTest」を実行すると、Aで指定されたプラグイン情報が取得されます。