A default-activated profile in the profiles.xml file is not deactivated when 
another profile is activated explicitly
--------------------------------------------------------------------------------------------------------------------

                 Key: MNG-4337
                 URL: http://jira.codehaus.org/browse/MNG-4337
             Project: Maven 2
          Issue Type: Bug
          Components: Profiles
    Affects Versions: 2.2.1, 2.1.0, 2.0.10
         Environment: Java 1.6.0, Debian GNU/Linux 5.0
            Reporter: Clemens Fuchslocher
         Attachments: profiles.tar.gz

The behavior of the activeByDefault element inside a POM is documented in 
[Introduction to Build 
Profiles|http://maven.apache.org/guides/introduction/introduction-to-profiles.html]:

{quote}
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.
{quote}

And it also works this way:

{noformat}
$ tar -zxvf profiles.tar.gz
$ cd profiles/internal
$ mvn help:all-profiles
...
  Profile Id: red (Active: true , Source: pom)
  Profile Id: green (Active: false , Source: pom)
  Profile Id: blue (Active: false , Source: pom)
...

$ mvn help:all-profiles -P blue
...
  Profile Id: blue (Active: true , Source: pom)
  Profile Id: red (Active: false , Source: pom)
  Profile Id: green (Active: false , Source: pom)
...

$ mvn help:active-profiles
...
The following profiles are active:

 - red (source: pom)
...

$ mvn help:active-profiles -P blue
...
The following profiles are active:

 - blue (source: pom)
...

$ mvn help:effective-pom
...
  <properties>
    <color>red</color>
  </properties>
...

$ mvn help:effective-pom -P blue
...
  <properties>
    <color>blue</color>
  </properties>
...
{noformat}

But if the profiles are defined in the profiles.xml file, then the behavior of 
the activeByDefault element is changed unexpectedly: The red profile and the 
color property is always active and red:

{noformat}
$ tar -zxvf profiles.tar.gz
$ cd profiles/external
$ mvn help:all-profiles
...
  Profile Id: red (Active: true , Source: profiles.xml)
  Profile Id: green (Active: false , Source: profiles.xml)
  Profile Id: blue (Active: false , Source: profiles.xml)
...

$ mvn help:all-profiles -P blue
...
  Profile Id: blue (Active: true , Source: profiles.xml)
  Profile Id: red (Active: true , Source: profiles.xml)
  Profile Id: green (Active: false , Source: profiles.xml)
...

$ mvn help:active-profiles
...
The following profiles are active:

 - red (source: profiles.xml)
...

$ mvn help:active-profiles -P blue
...
The following profiles are active:

 - blue (source: profiles.xml)
 - red (source: profiles.xml)
...

$ mvn help:effective-pom
...
  <properties>
    <color>red</color>
  </properties>
...

$ mvn help:effective-pom -P blue
...
  <properties>
    <color>red</color>
  </properties>
...
{noformat}

Principle of Least Surprise?

Maybe a bug.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to