مخضرم تشغيل "التبعية: شجرة "في بداية" اختبار " المرحلة
سؤال
أحتاج إلى الحصول على إخراج هدف" التبعية:الشجرة "من مخضرم في بداية مرحلة" الاختبار " ، للمساعدة في تصحيح مشكلة أحتاج إلى معرفة إصدارات كل شيء التي يتم استخدامها.
في النملة كان من السهل, لقد بحثت من خلال مستندات مخضرم والعديد من الإجابات هنا ولكن لا يزال لا يمكن معرفة ذلك,بالتأكيد ليس من الصعب?
المحلول
إذا كنت تريد أن تتأكد من أن 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>
إنه أمر محرج بعض الشيء ولكن هذه هي الطريقة لتعطيل عمليات الإعدام.
نصائح أخرى
هذا سيخرج شجرة التبعية الاختبار: giveacodicetagpre.
أعلن هذا في مشروعك بوم:
<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
يتم تنفيذ الهدف في الوقت الصحيح.