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

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

问题描述

我们有一个包含大量模块的 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 reactor 构建中排除模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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