「テスト」フェーズの開始時にMavenから「dependency:tree」目標の出力を取得して、使用されているすべてのバージョンを知る必要がある問題のデバッグに役立てる必要があります。
Antでは簡単だったでしょう。Mavenのドキュメントとここにある多数の回答を調べましたが、それでも理解できません。確かにそれほど難しくはありませんか?
これにより、テスト依存関係ツリーが出力されます。
mvn test dependency:tree -DskipTests=true
フェーズの最初にdependency:tree
実行されていることを確認したい場合は、元の目標をの後に実行するように移動する必要があります。これを行うには、プラグインを実行する順序で配置する必要があります。test
surefire:test
dependency:tree
の前にpom.xml
を追加する完全な例を次に示します。元のファイルは無効になり、新しいものが追加されます。これは実行後に実行されます。maven-dependency-plugin
maven-surefire-plugin
default-test
custom-test
dependency-tree
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.stackoverflow</groupId>
<artifactId>Q12687743</artifactId>
<version>1.0-SNAPSHOT</version>
<name>${project.artifactId}-${project.version}</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<id>dependency-tree</id>
<phase>test</phase>
<goals>
<goal>tree</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7.2</version>
<executions>
<execution>
<id>default-test</id>
<!-- Using phase none will disable the original default-test execution -->
<phase>none</phase>
</execution>
<execution>
<id>custom-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
少し厄介ですが、それが実行を無効にする方法です。
プロジェクトPOMでこれを宣言します。
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<phase>test-compile</phase>
<goals>
<goal>tree</goal>
</goals>
</execution>
</executions>
</plugin>
このパターンを採用して、特定のビルドフェーズ中にプラグインをトリガーできます。http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Pluginsを参照してください。
ビルドフェーズのリストについては、http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Referenceも参照してください。tree
mabaが指摘しているように、目標が正しい時間に実行されるように、フェーズを慎重に選択する必要があります。