Maven
  1. Maven
  2. MNG-4741

Priority for profiles activated by property or -P unclear

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Cannot Reproduce
    • Affects Version/s: 2.0.9
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      I could not find the situation documented somewhere, but the current behaviour is against my excpectation, hence a low priority bug report. In my pom, I have two profiles. One is activated by the -P command line option, the other by an environment variable. In variation of the example in MNG-2309:

      <profile>
        <id>default</id>
        <activation>
          <property>
            <name>env.WORKSPACE</name>
          </property>
        </activation>
        <properties>
          <test>DEFAULT</test>
        </properties>
      </profile>
      
      <profile>
        <id>override</id>
        <properties>
          <test>OVERRIDE</test>
        </properties>
      </profile>
      

      env.WORKSPACE is set by Hudson, when the build is executed. When Hudson runs "mvn -P override" I would expect test set to override. As I said, this is my expectation, and I don't know if it was a consious design decision to make the priority of profile activation differently.

      1. pom.xml
        1 kB
        Benjamin Bentmann

        Issue Links

          Activity

          Andreas Ebbert-Karroum created issue -
          Benjamin Bentmann made changes -
          Field Original Value New Value
          Link This issue is related to MNG-2309 [ MNG-2309 ]
          Hide
          Benjamin Bentmann added a comment -

          Running mvn validate -P override on the attached POM yields:

          [INFO] Scanning for projects...
          [INFO] ------------------------------------------------------------------------
          [INFO] Building Maven Integration Test :: MNG-4741 - OVERRIDE
          

          i.e. the property test used in the project name evalutes to OVERRIDE as you expect and it should (i.e. active profiles are injected in order of declaration, last in wins).

          Since you mentioned Hudson, I can only suggest to double-check the unexpected behavior is not caused by Hudson's Maven integration. Using a stock Maven 2.0.9 distribution (and all later versions), I cannot reproduce the issue.

          Show
          Benjamin Bentmann added a comment - Running mvn validate -P override on the attached POM yields: [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building Maven Integration Test :: MNG-4741 - OVERRIDE i.e. the property test used in the project name evalutes to OVERRIDE as you expect and it should (i.e. active profiles are injected in order of declaration, last in wins). Since you mentioned Hudson, I can only suggest to double-check the unexpected behavior is not caused by Hudson's Maven integration. Using a stock Maven 2.0.9 distribution (and all later versions), I cannot reproduce the issue.
          Benjamin Bentmann made changes -
          Attachment pom.xml [ 50340 ]
          Benjamin Bentmann made changes -
          Assignee Benjamin Bentmann [ bentmann ]
          Status Open [ 1 ] Closed [ 6 ]
          Resolution Cannot Reproduce [ 5 ]
          Ondra Žižka made changes -
          Link This issue relates to MNG-4946 [ MNG-4946 ]
          Mark Thomas made changes -
          Project Import Sun Apr 05 08:49:45 UTC 2015 [ 1428223785911 ]
          Mark Thomas made changes -
          Workflow jira [ 12715017 ] Default workflow, editable Closed status [ 12754656 ]
          Mark Thomas made changes -
          Project Import Sun Apr 05 21:45:26 UTC 2015 [ 1428270326204 ]
          Mark Thomas made changes -
          Workflow jira [ 12953121 ] Default workflow, editable Closed status [ 12989006 ]
          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Closed Closed
          2h 22m 1 Benjamin Bentmann 27/Jul/10 14:37

            People

            • Assignee:
              Benjamin Bentmann
              Reporter:
              Andreas Ebbert-Karroum
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development