使用配置文件来控制构建哪些Maven模块 [英] Using profiles to control which Maven modules are built

查看:108
本文介绍了使用配置文件来控制构建哪些Maven模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Maven POM.xml中有以下XML:

I have the following XML in my maven POM.xml:

<profiles>
  <profile>
     <id>default</id>
     <activation>
        <activeByDefault>true</activeByDefault>
        <property>
           <name>default</name>
           <value>!disabled</value>
        </property>
     </activation>
     <modules>
        <module>m1</module>
        <module>m2</module>
        <module>m3</module>
     </modules>
  </profile>
  <profile>
     <id>x</id>
     <modules>
        <module>m1</module>
     </modules>
  </profile>
</profiles>

我要实现的目标是:

  1. 当我运行mvn install时,我希望它构建m1,m2和m3项目.

  1. When I run mvn install, I want it to build m1, m2 and m3 projects.

当我运行mvn install -Px时,我希望它构建m1.

When I run mvn install -Px, I want it to only build m1.

我当前的问题是,使用上面的代码,选项2构建了所有m1,m2和m3.

My current problem is that with the code above, option 2 builds all m1, m2 and m3.

推荐答案

找到了解决方案专家,先定义"x"配置文件和默认"配置文件,然后正常工作(疯狂的Maven !!).这是最终结果:

Found the solution guys, define 'x' profile first and the 'default' and it works fine (insane Maven!!). Here's the final result:

   <profiles>
      <!-- DO NOT CHANGE THE *ORDER* IN WHICH THESE PROFILES ARE DEFINED! -->
      <profile>
         <id>x</id>
         <modules>
            <module>m1</module>
         </modules>
      </profile>
      <profile>
         <id>default</id>
         <activation>
            <activeByDefault>true</activeByDefault>
         </activation>
         <modules>
            <module>m1</module>
            <module>m2</module>
            <module>m3</module>
         </modules>
      </profile>
   </profiles>

这篇关于使用配置文件来控制构建哪些Maven模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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