You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Andy Bryant (JIRA)" <ji...@codehaus.org> on 2007/07/13 11:39:13 UTC

[jira] Created: (MNG-3106) Multiple profile activation conditions broken

Multiple profile activation conditions broken
---------------------------------------------

                 Key: MNG-3106
                 URL: http://jira.codehaus.org/browse/MNG-3106
             Project: Maven 2
          Issue Type: Bug
          Components: Profiles
    Affects Versions: 2.0.4
            Reporter: Andy Bryant


Having multiple profile activation conditions behaves in an unexpected manner. It doesn't cause a build failure, but the actual algorithm for activating a profile is very different from expected. My expectation was that if you include multiple conditions, they are ANDed together. However what appears to happen is that the conditions overwrite each other.

If an <os> condition is added, it overrides any <property> or <file> conditions regardless of their results.
If a <file> condition is added, it overrides any <property> condition regardless of results

The following table gives a sample of conditions matched, and whether the profile was activated as a result:

Property  File  OS   Result   Expected
     T           T      -         T                T
     T           F      -         F                F
     F           T      -         T                F
     F           F      -         F                F
     T           -      T         T                T
     T           -      F         F                F
     F           -      T         T                F
     F           -      F         F                F
     F           F     T         T                F 
     T           T      F        F                F


-- 
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

        

[jira] Updated: (MNG-3106) Multiple profile activation conditions broken

Posted by "Brett Porter (JIRA)" <ji...@codehaus.org>.
     [ http://jira.codehaus.org/browse/MNG-3106?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Brett Porter updated MNG-3106:
------------------------------

    Fix Version/s: 2.0.x

> Multiple profile activation conditions broken
> ---------------------------------------------
>
>                 Key: MNG-3106
>                 URL: http://jira.codehaus.org/browse/MNG-3106
>             Project: Maven 2
>          Issue Type: Bug
>          Components: Profiles
>    Affects Versions: 2.0.4
>            Reporter: Andy Bryant
>             Fix For: 2.0.x
>
>
> Having multiple profile activation conditions behaves in an unexpected manner. It doesn't cause a build failure, but the actual algorithm for activating a profile is very different from expected. My expectation was that if you include multiple conditions, they are ANDed together. However what appears to happen is that the conditions overwrite each other.
> If an <os> condition is added, it overrides any <property> or <file> conditions regardless of their results.
> If a <file> condition is added, it overrides any <property> condition regardless of results
> The following table gives a sample of conditions matched, and whether the profile was activated as a result:
> Property  File  OS   Result   Expected
>      T           T      -         T                T
>      T           F      -         F                F
>      F           T      -         T                F
>      F           F      -         F                F
>      T           -      T         T                T
>      T           -      F         F                F
>      F           -      T         T                F
>      F           -      F         F                F
>      F           F     T         T                F 
>      T           T      F        F                F

-- 
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

        

[jira] Commented: (MNG-3106) Multiple profile activation conditions broken

Posted by "Bryan Kate (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MNG-3106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_104853 ] 

Bryan Kate commented on MNG-3106:
---------------------------------

This bug is severely limiting, especially since the online documentation indicates an AND operation.

> Multiple profile activation conditions broken
> ---------------------------------------------
>
>                 Key: MNG-3106
>                 URL: http://jira.codehaus.org/browse/MNG-3106
>             Project: Maven 2
>          Issue Type: Bug
>          Components: Profiles
>    Affects Versions: 2.0.4
>            Reporter: Andy Bryant
>
> Having multiple profile activation conditions behaves in an unexpected manner. It doesn't cause a build failure, but the actual algorithm for activating a profile is very different from expected. My expectation was that if you include multiple conditions, they are ANDed together. However what appears to happen is that the conditions overwrite each other.
> If an <os> condition is added, it overrides any <property> or <file> conditions regardless of their results.
> If a <file> condition is added, it overrides any <property> condition regardless of results
> The following table gives a sample of conditions matched, and whether the profile was activated as a result:
> Property  File  OS   Result   Expected
>      T           T      -         T                T
>      T           F      -         F                F
>      F           T      -         T                F
>      F           F      -         F                F
>      T           -      T         T                T
>      T           -      F         F                F
>      F           -      T         T                F
>      F           -      F         F                F
>      F           F     T         T                F 
>      T           T      F        F                F

-- 
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

        

[jira] Commented: (MNG-3106) Multiple profile activation conditions broken

Posted by "Andy Bryant (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MNG-3106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_102141 ] 

Andy Bryant commented on MNG-3106:
----------------------------------

If the intention is that multiple conditions are not supported currently for maven activation, it would be much better to fail with an error message rather than current behaviour.

> Multiple profile activation conditions broken
> ---------------------------------------------
>
>                 Key: MNG-3106
>                 URL: http://jira.codehaus.org/browse/MNG-3106
>             Project: Maven 2
>          Issue Type: Bug
>          Components: Profiles
>    Affects Versions: 2.0.4
>            Reporter: Andy Bryant
>
> Having multiple profile activation conditions behaves in an unexpected manner. It doesn't cause a build failure, but the actual algorithm for activating a profile is very different from expected. My expectation was that if you include multiple conditions, they are ANDed together. However what appears to happen is that the conditions overwrite each other.
> If an <os> condition is added, it overrides any <property> or <file> conditions regardless of their results.
> If a <file> condition is added, it overrides any <property> condition regardless of results
> The following table gives a sample of conditions matched, and whether the profile was activated as a result:
> Property  File  OS   Result   Expected
>      T           T      -         T                T
>      T           F      -         F                F
>      F           T      -         T                F
>      F           F      -         F                F
>      T           -      T         T                T
>      T           -      F         F                F
>      F           -      T         T                F
>      F           -      F         F                F
>      F           F     T         T                F 
>      T           T      F        F                F

-- 
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

        

[jira] Updated: (MNG-3106) Multiple profile activation conditions broken

Posted by "Paul Gier (JIRA)" <ji...@codehaus.org>.
     [ http://jira.codehaus.org/browse/MNG-3106?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Gier updated MNG-3106:
---------------------------

    Fix Version/s:     (was: 2.0.x)
                   2.1-alpha-1
                   2.0.10

> Multiple profile activation conditions broken
> ---------------------------------------------
>
>                 Key: MNG-3106
>                 URL: http://jira.codehaus.org/browse/MNG-3106
>             Project: Maven 2
>          Issue Type: Bug
>          Components: Profiles
>    Affects Versions: 2.0.4
>            Reporter: Andy Bryant
>            Assignee: Paul Gier
>             Fix For: 2.0.10, 2.1-alpha-1
>
>
> Having multiple profile activation conditions behaves in an unexpected manner. It doesn't cause a build failure, but the actual algorithm for activating a profile is very different from expected. My expectation was that if you include multiple conditions, they are ANDed together. However what appears to happen is that the conditions overwrite each other.
> If an <os> condition is added, it overrides any <property> or <file> conditions regardless of their results.
> If a <file> condition is added, it overrides any <property> condition regardless of results
> The following table gives a sample of conditions matched, and whether the profile was activated as a result:
> Property  File  OS   Result   Expected
>      T           T      -         T                T
>      T           F      -         F                F
>      F           T      -         T                F
>      F           F      -         F                F
>      T           -      T         T                T
>      T           -      F         F                F
>      F           -      T         T                F
>      F           -      F         F                F
>      F           F     T         T                F 
>      T           T      F        F                F

-- 
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

        

[jira] Closed: (MNG-3106) Multiple profile activation conditions broken

Posted by "Paul Gier (JIRA)" <ji...@codehaus.org>.
     [ http://jira.codehaus.org/browse/MNG-3106?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Gier closed MNG-3106.
--------------------------

    Resolution: Fixed

This is now fixed in the 2.0.x branch and trunk.
The new behaviour is that the profile will be activated if any of the activators returns true (i.e. an "or" operation).

> Multiple profile activation conditions broken
> ---------------------------------------------
>
>                 Key: MNG-3106
>                 URL: http://jira.codehaus.org/browse/MNG-3106
>             Project: Maven 2
>          Issue Type: Bug
>          Components: Profiles
>    Affects Versions: 2.0.4
>            Reporter: Andy Bryant
>            Assignee: Paul Gier
>             Fix For: 2.0.10, 2.1-alpha-1
>
>
> Having multiple profile activation conditions behaves in an unexpected manner. It doesn't cause a build failure, but the actual algorithm for activating a profile is very different from expected. My expectation was that if you include multiple conditions, they are ANDed together. However what appears to happen is that the conditions overwrite each other.
> If an <os> condition is added, it overrides any <property> or <file> conditions regardless of their results.
> If a <file> condition is added, it overrides any <property> condition regardless of results
> The following table gives a sample of conditions matched, and whether the profile was activated as a result:
> Property  File  OS   Result   Expected
>      T           T      -         T                T
>      T           F      -         F                F
>      F           T      -         T                F
>      F           F      -         F                F
>      T           -      T         T                T
>      T           -      F         F                F
>      F           -      T         T                F
>      F           -      F         F                F
>      F           F     T         T                F 
>      T           T      F        F                F

-- 
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

        

[jira] Commented: (MNG-3106) Multiple profile activation conditions broken

Posted by "Eric Pabst (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MNG-3106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=264312#action_264312 ] 

Eric Pabst commented on MNG-3106:
---------------------------------

I have a fix for this here that doesn't modify the pom schema at all and simply switches it from an OR to and AND:
https://github.com/epabst/maven-3/tree/MNG-4516

> Multiple profile activation conditions broken
> ---------------------------------------------
>
>                 Key: MNG-3106
>                 URL: http://jira.codehaus.org/browse/MNG-3106
>             Project: Maven 2 & 3
>          Issue Type: Bug
>          Components: Profiles
>    Affects Versions: 2.0.4
>            Reporter: Andy Bryant
>            Assignee: Paul Gier
>             Fix For: 2.0.10, 2.1.0-M1
>
>
> Having multiple profile activation conditions behaves in an unexpected manner. It doesn't cause a build failure, but the actual algorithm for activating a profile is very different from expected. My expectation was that if you include multiple conditions, they are ANDed together. However what appears to happen is that the conditions overwrite each other.
> If an <os> condition is added, it overrides any <property> or <file> conditions regardless of their results.
> If a <file> condition is added, it overrides any <property> condition regardless of results
> The following table gives a sample of conditions matched, and whether the profile was activated as a result:
> Property  File  OS   Result   Expected
>      T           T      -         T                T
>      T           F      -         F                F
>      F           T      -         T                F
>      F           F      -         F                F
>      T           -      T         T                T
>      T           -      F         F                F
>      F           -      T         T                F
>      F           -      F         F                F
>      F           F     T         T                F 
>      T           T      F        F                F

-- 
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

        

[jira] Commented: (MNG-3106) Multiple profile activation conditions broken

Posted by "Andy Bryant (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MNG-3106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_112045 ] 

Andy Bryant commented on MNG-3106:
----------------------------------

Something like the following should do the trick. This modifies the DefaultProfileManager isActive method so that:
- if no activator matches return false (current behaviour)
- if any activators match, they ALL must consider the profile to be active

Index: DefaultProfileManager.java
===================================================================
--- DefaultProfileManager.java  (revision 590008)
+++ DefaultProfileManager.java  (working copy)
@@ -254,17 +254,27 @@
         {
             activators = container.lookupList( ProfileActivator.ROLE );

+            boolean matchedActivator = false;
+            boolean activate = true;
+
             for ( Iterator activatorIterator = activators.iterator(); activatorIterator.hasNext(); )
             {
                 ProfileActivator activator = (ProfileActivator) activatorIterator.next();

                 if ( activator.canDetermineActivation( profile ) )
                 {
-                    return activator.isActive( profile );
+                    matchedActivator = true;
+                    activate &= activator.isActive( profile );
                 }
             }
-
-            return false;
+            if (!matchedActivator)
+            {
+                return false;
+            }
+            else
+            {
+                return activate;
+            }
         }
         catch ( ComponentLookupException e )
         {


> Multiple profile activation conditions broken
> ---------------------------------------------
>
>                 Key: MNG-3106
>                 URL: http://jira.codehaus.org/browse/MNG-3106
>             Project: Maven 2
>          Issue Type: Bug
>          Components: Profiles
>    Affects Versions: 2.0.4
>            Reporter: Andy Bryant
>             Fix For: 2.0.x
>
>
> Having multiple profile activation conditions behaves in an unexpected manner. It doesn't cause a build failure, but the actual algorithm for activating a profile is very different from expected. My expectation was that if you include multiple conditions, they are ANDed together. However what appears to happen is that the conditions overwrite each other.
> If an <os> condition is added, it overrides any <property> or <file> conditions regardless of their results.
> If a <file> condition is added, it overrides any <property> condition regardless of results
> The following table gives a sample of conditions matched, and whether the profile was activated as a result:
> Property  File  OS   Result   Expected
>      T           T      -         T                T
>      T           F      -         F                F
>      F           T      -         T                F
>      F           F      -         F                F
>      T           -      T         T                T
>      T           -      F         F                F
>      F           -      T         T                F
>      F           -      F         F                F
>      F           F     T         T                F 
>      T           T      F        F                F

-- 
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