如何从Maven反应堆构建中排除模块? [英] How to exclude a module from a Maven reactor build?

查看:100
本文介绍了如何从Maven反应堆构建中排除模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个Maven 2项目,其中包含许多模块.示例:

We have a Maven 2 project with lots of modules in it. Example:

<modules>
  <module>common</module>
  <module>foo</module>
  <module>data</module>
  <module>bar</module>
  ... more ...
</module>

比方说,数据"模块的构建非常耗时,我们希望在CI服务器构建项目时将其排除在外.当前,我们使用两个pom.xml文件来实现此目的.一个模块中包含所有模块,另一个模块具有所有模块,但那些模块可以保留给CI.但这很烦人,因为有时我们忘记将新模块放入两个文件中.

Let's say the "data" module is time consuming to build and we want to exclude it when the project is build by a CI server. Currently we use two pom.xml files to achieve this. One has all modules in it and the other one has all modules except the ones which can be left out for CI. But that's pretty annoying because sometimes we forget to put a new module into both files.

是否有不需要两个单独的模块列表的解决方案?

Is there a solution which doesn't need two separate module lists?

推荐答案

最简单的方法是像这样使用profiles:

The easiest might be to use profiles like this:

<project>
  ...
  <modules>
    <module>common</module>
    <module>foo</module>
    <module>bar</module>
  <modules>
  ...
  <profiles>
    <profile>
      <id>expensive-modules-to-build</id>
      <modules>
        <module>data</module>
      </modules>
    </profile>
  </profiles>
</project>

然后,您应该查看您可以激活配置文件的方式

这篇关于如何从Maven反应堆构建中排除模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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