Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-4516

Contradiction between the documentation and Maven's behavior related to profile-activation with multiple criteria

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Incomplete
    • 2.2.1
    • None
    • Profiles
    • None

    Description

      The chapter 5.3.1 of the Maven Complete Reference (edition 0.2.1, Novemeber 2009) speaks unambiguously about considering a logical "AND" between more activation-conditions of a profile (cit.: "A profile is activated when all activation criteria has been satisfied. For example, a profile could list an Operating System family of Windows, and a JDK version of 1.4, this profile will only be activated when the build is executed on a Windows machine running Java 1.4.").
      Suprisingly, Maven's real behavior suggests, that the logical "OR" operator is used. The attached demo project contains a profile with two activation-criteria: a property and the existence of a file. As the output shows (attachement output.txt), the fulfillment of a single criterion is enough for activating the profile. Also the corresponding implementation in the Maven core expresses the intention to use an "OR" logic (maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java r813685 (branch 2.2.x), line 268):

      for ( Iterator activatorIterator = activators.iterator(); activatorIterator.hasNext(); )
      {
      ProfileActivator activator = (ProfileActivator) activatorIterator.next();

      if ( activator.canDetermineActivation( profile ) )
      {
      if ( activator.isActive( profile ) )

      { return true; }

      }
      }

      return false;

      As I'm considering the documentation's variant more reasonable, I'm reporting this as a bug instead of a documentation-issue.

      Attachments

        1. pom.xml
          2 kB
          Barnabas Bodnar
        2. output.txt
          3 kB
          Barnabas Bodnar
        3. debug_output.txt
          13 kB
          Barnabas Bodnar
        4. example2.zip
          6 kB
          Barnabas Bodnar

        Issue Links

          Activity

            People

              Unassigned Unassigned
              bbodnar Barnabas Bodnar
              Votes:
              12 Vote for this issue
              Watchers:
              14 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: