Maven 2 & 3
  1. Maven 2 & 3
  2. MNG-2363

<profile><activation><file><exists/> does not work in a multi-project build

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0-alpha-3
    • Component/s: Profiles
    • Labels:
      None
    • Complexity:
      Intermediate
    • Number of attachments :
      5

      Description

      I would expect each subproject to have the profile turned on or off depending on whether ${basedir}/file-to-check-for exists.

      Instead, during a multi-project build the profile is either on or off depending on whether the file exists relative to the aggregator pom. The decision is made once.

      Variable substitution doesn't work, so I can't explicitly use <exists>${basedir}/file-to-check-for</exists> or any variation on this theme to workaround the bug.

      Some background to my particular problem. I have 10 modules to build. Some of them are GUI modules and contain a file called plugin.xml in the subproject directory. I want to package these up specially and sign them, ready for deployment to webstart. The other modules are shared and server code and I don't want these packaged in the same way. So, I've got a dependency in my parent pom file which activates a profile called "guibundle" if a plugin.xml file exists in the subproject directory.

        Issue Links

          Activity

          Hide
          Denis Cabasson added a comment -

          Any plan on fixing that on the 2.2.x branch as well? Having the fix in 3.0-alpha means it won't actually work before the first stable release of 3.0. I hope we could expect a quicker release of a 2.2.x version with that bug fixed. I has already a significant number of votes, and would get my life and the life of a few other people easier

          Show
          Denis Cabasson added a comment - Any plan on fixing that on the 2.2.x branch as well? Having the fix in 3.0-alpha means it won't actually work before the first stable release of 3.0. I hope we could expect a quicker release of a 2.2.x version with that bug fixed. I has already a significant number of votes, and would get my life and the life of a few other people easier
          Hide
          David Biesack added a comment -

          Can someone identify which released version (of what plugin) this is fixed?
          I still see this bug (however, I do not have a multi-project config); just a pom.xml and a parent pom.
          In my <profiles> in the project pom.xml I have

          <profile>
          <id>cobertura.off</id>
          <activation>
          <file>
          <exists>$

          {basedir}/cobertura.off</exists>
          </file>
          </activation>
          <properties>
          <skip.cobertura>true</skip.cobertura>
          </properties>
          </profile>
          <profile>
          <id>cobertura.on</id>
          <activation>
          <file>
          <missing>${basedir}

          /cobertura.off</missing>
          </file>
          </activation>
          <properties>
          <skip.cobertura>false</skip.cobertura>
          </properties>
          </profile>

          but even if the file cobertura.off exists (same dir as pom.xml), mvn help:active-profiles shows that cobertura.on is active and cobertura.off is not active.

          This does work if I use <exists>cobertura.off</exists> and <missing>cobertura.off</missing> respectively

          Thus the doc at http://maven.apache.org/pom.html#Activation is (still) wrong as it shows use of $

          {basedir}

          /

          I'm using apache-maven-2.2.1

          Show
          David Biesack added a comment - Can someone identify which released version (of what plugin) this is fixed? I still see this bug (however, I do not have a multi-project config); just a pom.xml and a parent pom. In my <profiles> in the project pom.xml I have <profile> <id>cobertura.off</id> <activation> <file> <exists>$ {basedir}/cobertura.off</exists> </file> </activation> <properties> <skip.cobertura>true</skip.cobertura> </properties> </profile> <profile> <id>cobertura.on</id> <activation> <file> <missing>${basedir} /cobertura.off</missing> </file> </activation> <properties> <skip.cobertura>false</skip.cobertura> </properties> </profile> but even if the file cobertura.off exists (same dir as pom.xml), mvn help:active-profiles shows that cobertura.on is active and cobertura.off is not active. This does work if I use <exists>cobertura.off</exists> and <missing>cobertura.off</missing> respectively Thus the doc at http://maven.apache.org/pom.html#Activation is (still) wrong as it shows use of $ {basedir} / I'm using apache-maven-2.2.1
          Hide
          Jörg Schaible added a comment -

          Works for inherited profiles in Maven 3 only.

          Show
          Jörg Schaible added a comment - Works for inherited profiles in Maven 3 only.
          Hide
          Bill Riemers added a comment -

          While this bug has been fixed, most of the bugs that are marked as duplicates of this bug have not been... As the only thing that has been fixed is the usage of $

          {basedir}

          . Other properties still have problems, and the documentation still does not list this limitation.

          Show
          Bill Riemers added a comment - While this bug has been fixed, most of the bugs that are marked as duplicates of this bug have not been... As the only thing that has been fixed is the usage of $ {basedir} . Other properties still have problems, and the documentation still does not list this limitation.
          Hide
          Olivier Lamy added a comment -

          doesn't work anymore with 3.0.x
          see https://jira.codehaus.org/browse/MNG-5418

          Show
          Olivier Lamy added a comment - doesn't work anymore with 3.0.x see https://jira.codehaus.org/browse/MNG-5418

            People

            • Assignee:
              Benjamin Bentmann
              Reporter:
              David Boden
            • Votes:
              19 Vote for this issue
              Watchers:
              28 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: