有条件地执行maven插件 [英] conditionally execute maven plugins

查看:160
本文介绍了有条件地执行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:

http://books.sonatype.com/mvnref-book/reference/profiles-sect -activation.html

这篇关于有条件地执行maven插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆