如何为多模块项目的一个模块执行不同的目标? [英] How to execute a different goal for one module of a multi module project?

查看:58
本文介绍了如何为多模块项目的一个模块执行不同的目标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由两个不同模块组成的项目.我无法控制这些模块的pom文件,因此无法更改它们.我对项目pom文件有完全控制权.在模块中未将项目ID定义为父项.

文件夹结构:

project
 + module1
 + module2

作为变通方法的一部分,我需要为两个模块执行两个不同的目标,以便将module1安装到本地存储库中,而不是安装到module2中.这只是一个例子.我的实际问题是包含更多的级别,每个级别有2个以上的模块.

为了最小化CI系统所需的配置,我想在一个Maven调用中运行它.

我是在梦见

mvn install -Dspecial=module:compile

这可能吗,如果可以,我该怎么做?

解决方案

(...)为了最大程度地减少CI系统所需的配置,我想在一个maven调用中运行它.

恐怕这不可能.正如我在

mvn install -Dspecial=module:compile

Is this possible and if yes, how do I do that?

(...) To minimize the configuration necessary for my CI system, I want to run this in one maven call.

I'm afraid this won't be possible. As I explained in this answer, the phase or goal invoked as part of a multi modules build is run against all modules.

If you want to run a different phase or goal for a subset of the sub-modules, you'll have to call maven twice, maybe using the --projects, -pl options to pick the right subset:

  • mvn -pl module1,module3 somegoal
  • mvn -pl module2 someothergoal

这篇关于如何为多模块项目的一个模块执行不同的目标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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