Maven
  1. Maven
  2. MNG-3328

Allow multiple profile activation properties.

    Details

    • Type: Improvement Improvement
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0.8
    • Fix Version/s: 3.x / Backlog
    • Component/s: Profiles
    • Labels:
      None
    • Number of attachments :
      0

      Description

      The pom model should be changed to allow multiple properties to activate a profile. So the profile activation section could look something like this:

      <activation>
        <properties>
          <my-prop-1>some-value</my-prop-1>
          <my-prop-2>another-value</my-prop-2>
        </properties>
      </activation>
      

      This would provide more flexibility in profile activation.

        Issue Links

          Activity

          Hide
          Elifarley Callado Coelho added a comment -

          Maybe adding support for boolean operators would be nice. Here is an example:


          <activation>

          <and>
          <property><name>prop-1</name></property>

          <property><name>prop-2</name></property>

          <property><name>prop-3</name></property>

          <or>
          <property><name>prop-4</name></property>

          <not>
          <property><name>prop-5</name></property>
          </not>

          <property><name>prop-6</name></property>

          <os>MacOS</os>

          </or>

          </and>

          </activation>

          Show
          Elifarley Callado Coelho added a comment - Maybe adding support for boolean operators would be nice. Here is an example: — <activation> <and> <property><name>prop-1</name></property> <property><name>prop-2</name></property> <property><name>prop-3</name></property> <or> <property><name>prop-4</name></property> <not> <property><name>prop-5</name></property> </not> <property><name>prop-6</name></property> <os>MacOS</os> </or> </and> </activation> —
          Hide
          Paul Gier added a comment -

          For better compatibility with the current maven model, the syntax for this should look more like this:

          <activation>
            <property>
              <name>my-prop-1</name>
              <value>some-value</value>
            </property>
            <property>
              <name>my-prop-2</name>
              <value>another-value</value>
            </property>
          </activation>
          

          If either of these properties match the given value, the profile should be activated.
          In addition, the other activators (os, jvm, file, etc) should also be allowed to have multiple values.

          Show
          Paul Gier added a comment - For better compatibility with the current maven model, the syntax for this should look more like this: <activation> <property> <name>my-prop-1</name> <value>some-value</value> </property> <property> <name>my-prop-2</name> <value>another-value</value> </property> </activation> If either of these properties match the given value, the profile should be activated. In addition, the other activators (os, jvm, file, etc) should also be allowed to have multiple values.
          Hide
          Marco Sandrini added a comment - - edited

          boolean operators could be achieved with the following syntax (let's assume with want to express the condition ((a && b) || (c && d)) )

          <activations>
            <activation>
              <properties>
                <property>
                  <name>my-prop-A</name>
                  <value>valueA</value>
                </property>
                <property>
                  <name>my-prop-B</name>
                  <value>valueB</value>
                </property>
              </properties>
            </activation>
            <activation>
              <properties>
                <property>
                  <name>my-prop-C</name>
                  <value>valueC</value>
                </property>
                <property>
                  <name>my-prop-D</name>
                  <value>valueD</value>
                </property>
             </properties>
            </activation>
          </activations> 
          

          so all the conditions within one activation are considered as an AND and the different activation elements are considered as an OR. The downside of this proposal is of course that it would break the current POM model.

          Show
          Marco Sandrini added a comment - - edited boolean operators could be achieved with the following syntax (let's assume with want to express the condition ((a && b) || (c && d)) ) <activations> <activation> <properties> <property> <name> my-prop-A </name> <value> valueA </value> </property> <property> <name> my-prop-B </name> <value> valueB </value> </property> </properties> </activation> <activation> <properties> <property> <name> my-prop-C </name> <value> valueC </value> </property> <property> <name> my-prop-D </name> <value> valueD </value> </property> </properties> </activation> </activations> so all the conditions within one activation are considered as an AND and the different activation elements are considered as an OR. The downside of this proposal is of course that it would break the current POM model.
          Hide
          Alejandro Guizar added a comment -

          Activating a profile based on EITHER property matching the given values is already possible, just copy the profile. If you want to avoid duplication simply use XML entities. What is not currently possible is to activate a profile based on ALL properties matching the given values.

          I would like that the following snippet meant "if all properties match the given values, the profile should be activated".

          <activation>
            <property>
              <name>my-prop-1</name>
              <value>some-value</value>
            </property>
            <property>
              <name>my-prop-2</name>
              <value>another-value</value>
            </property>
          </activation>
          
          Show
          Alejandro Guizar added a comment - Activating a profile based on EITHER property matching the given values is already possible, just copy the profile. If you want to avoid duplication simply use XML entities. What is not currently possible is to activate a profile based on ALL properties matching the given values. I would like that the following snippet meant "if all properties match the given values, the profile should be activated". <activation> <property> <name> my-prop-1 </name> <value> some-value </value> </property> <property> <name> my-prop-2 </name> <value> another-value </value> </property> </activation>
          Hide
          gary fry added a comment - - edited

          Would be great if you could marry OS and Properties as an AND condition.

          For example,

             <activation>
               <os>
                 <family>unix</family>
               </os>
               <property>
                 <name>my-prop-2</name>
                 <value>another-value</value>
               </property>
             </activation>
           

          Currently, Maven2 looks for the first condition that is true, and the profile is activated. However, this is not very useful if the build needs to run in both Windows and Unix environments and you need to do something slightly different on each OS, where activation is also determined by a property being set at buld time

          Show
          gary fry added a comment - - edited Would be great if you could marry OS and Properties as an AND condition. For example, <activation> <os> <family> unix </family> </os> <property> <name> my-prop-2 </name> <value> another-value </value> </property> </activation> Currently, Maven2 looks for the first condition that is true, and the profile is activated. However, this is not very useful if the build needs to run in both Windows and Unix environments and you need to do something slightly different on each OS, where activation is also determined by a property being set at buld time
          Hide
          Ondrej Zizka added a comment -

          +1 to Elifarley Callado Coelho for boolean logic,
          -1 to Marco Sandrini for too verbose syntax.

          Show
          Ondrej Zizka added a comment - +1 to Elifarley Callado Coelho for boolean logic, -1 to Marco Sandrini for too verbose syntax.
          Hide
          Michael Heuer added a comment -

          This issue makes our cross-platform build a mess, tracked as

          Maven profiles appear not to be able to fully discriminate MacOSX 10.6.x, Apple JDK 1.6.x, x86_64
          http://code.google.com/p/piccolo2d/issues/detail?id=151

          Show
          Michael Heuer added a comment - This issue makes our cross-platform build a mess, tracked as Maven profiles appear not to be able to fully discriminate MacOSX 10.6.x, Apple JDK 1.6.x, x86_64 http://code.google.com/p/piccolo2d/issues/detail?id=151
          Hide
          Julien Nicoulaud added a comment -

          +1 for Marco Sandrini's syntax.

          @Alejandro Guizar: sorry for being offtopic, but what do you mean by "If you want to avoid duplication simply use XML entities" ? Would you have an example ?

          Show
          Julien Nicoulaud added a comment - +1 for Marco Sandrini's syntax. @Alejandro Guizar: sorry for being offtopic, but what do you mean by "If you want to avoid duplication simply use XML entities" ? Would you have an example ?
          Hide
          Pulkit Singhal added a comment -

          Why is an enhancement with this many votes being ignored? What is the reason that this is not being considered or scheduled in the pipeline?

          Show
          Pulkit Singhal added a comment - Why is an enhancement with this many votes being ignored? What is the reason that this is not being considered or scheduled in the pipeline?
          Hide
          Sebastian Koske added a comment -

          This request was first entered 3 years ago, when will it ever be honored? I think this is something many developers are waiting for...

          Show
          Sebastian Koske added a comment - This request was first entered 3 years ago, when will it ever be honored? I think this is something many developers are waiting for...
          Hide
          Eric Pabst added a comment - - edited

          I posted a fix for MNG-4516, which is related.

          Show
          Eric Pabst added a comment - - edited I posted a fix for MNG-4516 , which is related.
          Hide
          Darren Bell added a comment -

          So, will this one be any time soon?

          Show
          Darren Bell added a comment - So, will this one be any time soon?
          Hide
          Benjamin Haag added a comment -

          Same problem here!
          Costs me days now, to find a workaround, if that is possible.

          What sense does that AND condition make? You could do every AND with several profiles.
          But tell me, is there ANY chance to do an OR condition, as it is described in MNG-4516?

          Bug was for 2.0.8, I'm using 2.2.1 and 3.0.3 and nothing got better ...

          Show
          Benjamin Haag added a comment - Same problem here! Costs me days now, to find a workaround, if that is possible. What sense does that AND condition make? You could do every AND with several profiles. But tell me, is there ANY chance to do an OR condition, as it is described in MNG-4516 ? Bug was for 2.0.8, I'm using 2.2.1 and 3.0.3 and nothing got better ...
          Hide
          Matthew Adams added a comment -

          +1 for conditional operators, especially OR. I could really use this!

          Show
          Matthew Adams added a comment - +1 for conditional operators, especially OR. I could really use this!
          Hide
          Matthew Adams added a comment -

          Just noticed that, as of this writing, this issue is #5 in popularity:
          http://jira.codehaus.org/browse/MNG#selectedTab=com.atlassian.jira.plugin.system.project%3Apopularissues-panel

          Can the project get this resourced?

          Show
          Matthew Adams added a comment - Just noticed that, as of this writing, this issue is #5 in popularity: http://jira.codehaus.org/browse/MNG#selectedTab=com.atlassian.jira.plugin.system.project%3Apopularissues-panel Can the project get this resourced?
          Hide
          Pala Gabriel added a comment -

          Guys this defect is 5 years old now. What the hell are you waiting for ?

          Show
          Pala Gabriel added a comment - Guys this defect is 5 years old now. What the hell are you waiting for ?
          Show
          Gábor Lipták added a comment - try this: https://github.com/kpiwko/el-profile-activator-extension
          Hide
          Richard Calmbach added a comment -

          Full support for boolean expressions for activation conditions would be really useful. At a minimum, multiple properties should be treated as "AND", the way it was always intended. You can do "OR" by duplicating a profile (ugly but at least possible), but currently, there is no way to do "AND" - a serious limitation.

          Show
          Richard Calmbach added a comment - Full support for boolean expressions for activation conditions would be really useful. At a minimum, multiple properties should be treated as "AND", the way it was always intended. You can do "OR" by duplicating a profile (ugly but at least possible ), but currently, there is no way to do "AND" - a serious limitation.

            People

            • Assignee:
              Unassigned
              Reporter:
              Paul Gier
            • Votes:
              88 Vote for this issue
              Watchers:
              72 Start watching this issue

              Dates

              • Created:
                Updated: