Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Only one Maven profile executed when using activeByDefault

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.

like image 504
Misterer Avatar asked Sep 17 '15 09:09

Misterer


1 Answers

Profiles that are active by default are automatically deactivated when another profile is activated. Since both of your profiles are activated by default, the second one turns active and deactivates the first one.

Quoting from the Maven docs about the activeByDefault property (emphasis mine):

This profile will automatically be active for all builds unless another profile in the same POM is activated using one of the previously described methods. All profiles that are active by default are automatically deactivated when a profile in the POM is activated on the command line or through its activation config.

like image 139
Tunaki Avatar answered Sep 30 '22 18:09

Tunaki