Mavenは「テスト」フェーズの開始時に「依存関係:ツリー」を実行します。
質問
「テスト」フェーズの開始時に「テスト」フェーズの開始時に「依存関係:ツリー」ゴール出力を得る必要があります。
Antは簡単だったでしょう、私はここでMavenのドキュメントと数多くの答えを見ましたが、まだそれを理解することはできません、確かにそれはそれほど難しいですか?
解決
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>
.
それは少し厄介ですが、それが実行を無効にする方法です。
他のヒント
これはテスト依存関係ツリーを出力します:
mvn test dependency:tree -DskipTests=true
. プロジェクト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/はじめに/紹介-LifeCycle.html#plugins 。
関連項目 http://maven.apache。org / guides /序文/序論からlifecycle.html#lifecycle.html#lifecycle_reference ビルドフェーズのリスト。MABAが指摘すると、tree
の目標が正しい時間に実行されるように慎重に選択する必要があります。