maven中指定build一个project中几个特定的子modules

问题由来:

      一个项目可能会有多个子module,在特定情况下可能只需要build其中几个module。

例如我的项目的目录结构如下

myproject

|------------module_one

|------------module_two

|------------module_three

|------------module_four

|------------module_five

|------------module_six

|------------module_seven

|------------pom.xml

解决方法一:

例:我想要build module_three,module_five,module_seven三个子module

在根pom同一级目录运行如下命令:

mvn clean install -pl module_three,module_five,module_seven

也可以在此命令上加上以下参数

-am 不仅build module_three,module_five,module_seven这三个,而且build这些子module require的其他项目,require是指其parent项目。

-amd 不仅build module_three,module_five,module_seven这三个,而且build依赖这三个module的项目,如module_other。

 

解决方法二:

增加一个profile,如:

<profiles>      
  <profile>
            <id>patch_001</id>
            <properties>
                
            </properties>
            <modules>
                <module>module_three</module>
                <module>module_five</module>
                <module>module_seven</module>
            </modules>
        </profile>
</profiles>

然后运行maven命令:

mvn clean install -Ppatch_001  #这样也可以只build这三个子module

PS:我采用第二种方法的时候,发现在profile这样定义了所要build的module后,外面就不能再定义需要build的module了,否则就会按照外面定义的来build一系列,不知道是什么原因,或者是我的写法有错误,如果有哪位大神知道,还望不吝赐教。

 

转载于:https://www.cnblogs.com/wenbozhou123/p/7885905.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值