首页 > 解决方案 > 基于配置文件的条件模块

问题描述

只有在未设置某个属性的情况下,我才想通过包含的 pom 包含一个模块。

所以我在我的父母 pom 中定义:

<profiles>
    <profile>
        <id>aggregator</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <aggregator>aggregator</aggregator>
        </properties>
        </profile>
 </profiles>

在其中一个子模块中,如果未设置属性,我想激活另一个配置文件:

<profiles>
    <profile>
        <id>incubation</id>
        <activation>
           <property>
                <name>!aggregator</name>
            </property>
        </activation>
        <modules>
            <module>../../examples/org.eclipse.nebula.examples</module>
            <module>../../examples/org.eclipse.nebula.examples.feature</module>
        </modules>
    </profile>
 </profiles>

AFAICS 这就是https://maven.apache.org/guides/introduction/introduction-to-profiles.html描述它的方式。

但是仍然包含示例模块。这个设置有什么问题?

标签: maven

解决方案


我以不同的方式解决了它。仅在顶级 pom 中使用配置文件,并且仅包含基于该配置文件的部分模块。


推荐阅读