如何将特定的活动配置文件属性传递给子pom

时间:2019-01-15 11:54:50

标签: java maven properties pom.xml profile

我每个人,我正在与所有已连接的n maven项目一起工作。在我的父亲pom中,我定义了4个配置文件(PROD,CI,CE,LOCAL),每个配置文件使用具有不同值(common,commonCI,commonCE,commonPROD)的相同属性键(project.type.environment)。当我启动配置文件时,其他作业将使用此属性来过滤正确的属性文件。但是,如果我启动两个配置文件,两者都与密钥存在冲突,并且仅用于最后定义的配置文件。我知道有一个相似性问题,但我想知道是否有可能,在为每个配置文件重命名属性(project.type.prod,project.type.ci ecc)之后,将右键传递给每个配置文件工作。

//这是父亲pom中定义的一个配置文件

    <profiles>
            <profile>
                <id>profile-local</id>
                <build>
                    <plugins>

                        <plugin>
                            ...
                        </plugin>
                    </plugins>
                </build>
                <activation>
                    <activeByDefault>false</activeByDefault>
                    <property>
                        <name>PROFILE</name>
                        <value>profile-local</value>
                    </property>
                </activation>
                <properties>
                    <project.type.environment>common</project.type.environment>
                </properties>
            </profile>

//and this is the filter in each pom job

    <build>
            <filters>
                <filter>src/main/resources/filter/commonGE.properties</filter>
                <filter>src/main/resources/filter/${project.type.environment}.properties</filter>
            </filters>
    ...
    </build>

(common GE is a generic common) 

//我想做这样的事情:

..
<project.type.local>common</project.type.local>
..

//并在过滤器中

<filter>src/main/resources/filter/commonGE.properties</filter>
                <filter>src/main/resources/filter/ (key of the current active profile).properties</filter>

谢谢

0 个答案:

没有答案