在 Maven 构建期间跳过子模块 [英] Skip a submodule during a Maven build

查看:62
本文介绍了在 Maven 构建期间跳过子模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们需要能够在某些环境中跳过子模块.

We have a need to be able to skip a submodule in certain environments.

有问题的模块包含集成测试,需要半小时才能运行.因此,我们希望在 CI 服务器上构建时包含它,但是当开发人员在本地构建(并运行测试)时,我们希望跳过该模块.

The module in question contains integration tests and takes half an hour to run. So we want to include it when building on the CI server, but when developers build locally (and tests get run), we want to skip that module.

有没有办法通过配置文件设置来做到这一点?我已经使用谷歌搜索并查看了此处的其他问题/答案,但没有找到好的解决方案.

Is there a way to do this with a profile setting? I've done some googling and looked at the other questions/answers here and haven't found a good solution.

我想一种选择是从父 pom.xml 中完全删除该子模块,然后在我们的 CI 服务器上添加另一个项目来构建该模块.

I suppose one option is to remove that submodule from the parent pom.xml entirely, and just add another project on our CI server to just build that module.

建议?

推荐答案

当然,这可以使用配置文件来完成.您可以在父 pom.xml 中执行以下操作.

Sure, this can be done using profiles. You can do something like the following in your parent pom.xml.

  ...
   <modules>
      <module>module1</module>
      <module>module2</module>  
      ...
  </modules>
  ...
  <profiles>
     <profile>
       <id>ci</id>
          <modules>
            <module>module1</module>
            <module>module2</module>
            ...
            <module>module-integration-test</module>
          </modules> 
      </profile>
  </profiles>
 ...

在您的 CI 中,您将使用 ci 配置文件运行 maven,即 mvn -P ci clean install

In your CI, you would run maven with the ci profile, i.e. mvn -P ci clean install

这篇关于在 Maven 构建期间跳过子模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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