本文介绍了有条件地执行maven插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在pom.xml中配置了一些Maven插件。我只想在运行测试时执行这些插件(可以使用 -Dmaven.test.skip = true 或 -DskipTests跳过测试)。
I have some Maven plugins configured in my pom.xml. I only want to execute these plugins if the tests are being run (tests may be skipped using either -Dmaven.test.skip=true or -DskipTests).
其中一个插件绑定到进程类构建生命周期阶段和另一个绑定到预集成测试阶段。
One of these plugins is bound to the process-classes build lifecycle phase and the other is bound to the pre-integration-test phase.
推荐答案您可以使用具有以下特殊激活条件的个人资料:
You can use profile with special activation conditions like this:
<project> ... <profiles> <profile> <id>my-test-plugins</id> <activation> <property><name>!maven.test.skip</name></property> <property><name>!skipTests</name></property> </activation> <build> <plugins> <!-- define your plugins here --> </plugins> </build> </profile> </profiles> </project>您可以在此处找到更多信息:
More info you can find here:
books.sonatype/mvnref-book/reference/profiles-sect -activation.html
更多推荐
有条件地执行maven插件
发布评论