6

I have two profiles defined in my pom.xml:

<profiles>
    <profile>
        <id>nobrand</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <brand>nobrand</brand>
        </properties>
    </profile>
    <profile>
        <id>mybrand</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <brand>mybrand</brand>
        </properties>
    </profile>
</profiles>

The <build> section simply uses the property that is set by each profile.

Both profiles are set as active by default. However, only the last one is executed by mvn package. Why? I expected the build to be executed twice.

4

1 回答 1

6

默认情况下处于活动状态的配置文件会在激活另一个配置文件时自动停用。由于您的两个配置文件都默认激活,因此第二个激活并停用第一个。

引用关于该activeByDefault属性的 Maven 文档(强调我的):

除非使用上述方法之一激活同一 POM 中的另一个配置文件,否则此配置文件将自动对所有构建处于活动状态。当在命令行或通过其激活配置激活 POM 中的配置文件时,默认情况下处于活动状态的所有配置文件都会自动停用。

于 2015-09-17T11:42:42.250 回答