Maven은 "테스트" 단계 시작 시 "종속성:트리"를 실행합니다.
문제
모든 것의 어떤 버전이 사용되고 있는지 알아야 하는 문제를 디버깅하는 데 도움이 되도록 "테스트" 단계 시작 시 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/소개 / 소개 - the-the-lifecycle.html # 플러그인 .
http : //maven.apache.org / 가이드 / 소개 / 소개 - - the-lifecycle.html # lifecycle_reference 빌드 위상 목록입니다.MABA가 지적하기 때문에 정확한 시간에 tree
목표가 실행되도록 위상을 신중하게 선택해야합니다.