maven -> profile -> activation - all conditions are required or just one?

java, maven, maven-3

Solution

The problem here is that the activation list with your trigger conditions is connected with `OR`. They do have a ticket to provide multiple activation triggers, but it's still open. That means, that it matches your sdk rule which is true and therefore active.

<profile>
    <id>profile-1</id>
    <activation> <!-- true || true = true -->
        <jdk>1.6</jdk> <!-- true -->
        <property> <!-- true -->
            <name>name</name>
            <value>Hubert</value>
        </property>
    </activation>
</profile>
<profile>
    <id>profile-2</id>
    <activation> <!-- true || false = true -->
        <jdk>1.6</jdk> <!-- true -->
        <property> <!-- false -->
            <name>name</name>
            <value>Wiktoria</value>
        </property>
    </activation>
</profile>

Problem

Configuration: - Maven: 3.0.5 - Java: 1.6.0_45 Description: Let's say we have profile configuration like below: ``` <profiles> <profile> <id>profile-1</id> <activation> <jdk>1.6</jdk> <property> <name>name</name> <value>Hubert</value> </property> </activation> </profile> <profile> <id>profile-2</id> <activation> <jdk>1.6</jdk> <property> <name>name</name> <value>Wiktoria</value> </property> </activation> </profile> </profiles> ``` We have two profiles: profile-1 and profile-2. Profile profile-1 should be active when two requirements are met: - jdk is version 1.6 - property name has value Hubert Question: Let's check this configuration: mvn -Dname=Hubert help:active-profiles As a result I get that there are two active profiles: profile-1 and profile-2. Hmm... Profile profile-2 should not be active since property name has value different from expected Wiktoria. Could someone explain me why this work like this? Is it a normal behavior? Thanks.

Original source