[英]Maven run class before test phase: exec-maven-plugin exec:java not executing class
[英]java maven exec-maven-plugin not executing on mvn clean install
后續問題的后續: Maven在測試階段之前運行類:exec-maven-plugin exec:java不執行類 。
我在jenkins盒子上運行jUnit4測試,用maven構建。 我需要在構建的測試階段之前運行特定的main方法java程序。 目的是在測試運行之前恢復測試數據庫。
如果我運行了這個exec分配給的確切階段,我的類按預期執行; 但是當我運行整個構建時,我的類不會執行:
具體來說,它運行:
mvn -X exec:java generate-test-resources
但不運行:
mvn -X -e install
- 要么 -
mvn -X -e clean install
pom.xml:我的pom.xml文件包括:
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>build-test-environment</id>
<phase>generate-test-resources</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>main.java._tools.BuildTestEnvironment</mainClass>
</configuration>
</plugin>
</plugins>
</pluginManagement>
生命周期默認:我還沒有看到maven的生命周期。 日志將其報告為:
[DEBUG] Lifecycle default -> [
validate,
initialize,
generate-sources,
process-sources,
generate-resources,
process-resources,
compile,
process-classes,
generate-test-sources,
process-test-sources,
generate-test-resources,
process-test-resources,
test-compile,
process-test-classes,
test,
prepare-package,
package,
pre-integration-test,
integration-test,
post-integration-test,
verify,
install,
deploy
]
使用<pluginManagement>
下定義的插件,您實際上在告訴maven在調用插件時將在整個項目中使用哪個插件版本。 我通常希望<pluginManagement>
標記出現在父pom中。
要調用插件 - 只需輸入<plugins/>
元素即可。 它可能會也可能不會從a繼承
因此,要使用該插件,您只需要通過put來調用插件
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>build-test-environment</id>
<phase>generate-test-resources</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>main.java._tools.BuildTestEnvironment</mainClass>
</configuration>
</plugin>
...AnyOtherPlugin
<plugins>
沒有任何<pluginManagement>
標記
Ashish接着說: <pluginManagement>
正在殺死它。
我認為我需要<pluginManagement>
因為Eclipse和m2e存在問題。 原來m2e的人有一個解決方案(一個非常復雜的解決方案)。
看到:
如何解決Spring Data Maven Builds的“生命周期配置未涵蓋的插件執行”
- 和 -
http://wiki.eclipse.org/M2E_plugin_execution_not_covered
祝你好運,如果遇到這個!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.