maven Modules在pom.xml中是可选的 [英] Maven Modules optional in pom.xml

查看:143
本文介绍了maven Modules在pom.xml中是可选的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的父pom.xml就像下面..,说我目前有4个模块..
但是在某些时候我可能没有所有的4个模块..
有没有办法在root pom.xml中使这些模块(子项目)可选。
这意味着子项目不会出现在一个分支中,但会出现在另一个分支中。我不想为不同的分支使用多个 root pom.xml 。 。有可能吗?

Hi I've parent pom.xml like below.. , say I've 4 modules currently.. But at certain times I might not have all the 4 modules all the time.. Is there any way to make these module(s) (Child projects) optional within root pom.xml. Which means that child project will not be present in the one branch , but will be present in another branch .. I don't want to use multiple root pom.xml's for different branches.. Is it possible?

 <project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.xx.xx.correspondence</groupId>
  <artifactId>xxHudsonTP</artifactId>
  <version>1</version>
  <packaging>pom</packaging>

  <modules>
    <module>xxCastor</module>
    <module>cxxYYYCastor</module>
    <module>xxCommon</module>
    <module>xxxx</module>    
  </modules>
</project> 


推荐答案

您可以使用配置文件,例如他们这样做在flex-mojos插件项目中:

You can use profiles, like they did it for example in flex-mojos plugin project:

...
<profiles>

    <profile>
      <id>minimal</id>
      <modules>
        <module>flexmojos-parent</module>
        <module>flexmojos-sandbox</module>
        <module>flexmojos-generator</module>
        <module>flexmojos-maven-plugin</module>
        <module>flexmojos-super-poms</module>        
        <module>flexmojos-testing</module>        
      </modules>
    </profile>

    <profile>
      <id>release</id>
      <modules>
        <module>flexmojos-parent</module>
        <module>flexmojos-sandbox</module>
        <module>flexmojos-generator</module>
        <module>flexmojos-maven-plugin</module>
        <module>flexmojos-super-poms</module>
        <module>flexmojos-archetypes</module>
        <module>flexmojos-testing</module>
      </modules>
    </profile>

<profiles>

这篇关于maven Modules在pom.xml中是可选的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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