如何在testCompile和测试阶段之间执行Maven的antrun(在Surefire执行之前)?

时间:2014-01-21 18:00:40

标签: java maven maven-3 maven-surefire-plugin maven-antrun-plugin

在我的Maven构建中,我有一小段Ant代码,需要在Surefire执行一些配置之前运行。

代码是用antrun执行的,但我无法在Surefire之前执行。

以下是我的构建输出的相关部分:

[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ com...tests ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 7 source files to C:\...\com...tests\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.16:test (default-test) @ com...tests ---
[INFO] Surefire report directory: C:\...\com...tests\target\surefire-reports

基本上我需要在maven-compiler-plugin:3.1:testCompilemaven-surefire-plugin:2.16:test之间执行。

我尝试将antrun绑定到测试阶段并将其放在POM文件中的surefire插件之前,但它总是在Surefire插件之后执行。我还尝试将其配置为在testCompile阶段运行,并将其放在maven-compiler-plugin插件之后,但也没有成功..它在surefire之后执行。

有谁知道如何让它在这两者之间执行?

谢谢!

爱德华

2 个答案:

答案 0 :(得分:4)

您可以在process-test-classes生命周期阶段执行antrun插件,该阶段位于test-compiletest之间

答案 1 :(得分:4)

如果您查看build life-cycle,您可以看到compile / testCompile和test ...之间有几个步骤...

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

所以我建议在你的情况下使用process-test-classes,这正是你需要的。

相关问题