Maven Project Web Site
  1. Maven Project Web Site
  2. MNGSITE-86

Document usage of negation symbol for profile activation (undocumented feature)

    Details

    • Type: Task Task
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Labels:
      None
    • Environment:
      *
    • Testcase included:
      yes
    • Number of attachments :
      0

      Description

      Please, document that the negation symbol "!" can be used for profile activation not only to test the absence of a property. This is currently not documented on this page:
      http://maven.apache.org/guides/introduction/introduction-to-profiles.html

      This request goes back to a thread on the Maven user list, cf.
      http://www.nabble.com/Undocumented-Feature%3A-Usage-of-negation-for-profile-activation-td23446509.html

      In the following I basically quote the original message posted to the forum; with some extensions to the example. The example can be almost directly added to the page to document and illustrate how this feature can be used:

      Hello,

      I just found a--to my best knowledge--undocumented feature and thought I should share it with the community in the hope that it will made its way into the Maven documentation.

      The feature is that you can use the negation symbol "!" within a profile activation specifification not only to test the absence of a property but also within the <os> tag, for instance, to express something like "activate the profile if the OS family name is not xyz". The following example illustrates this:

      <profiles> 
              <profile> 
                      <id>tools-jar-windows</id> 
                      <activation> 
                              <os> 
                                      <family>windows</family> 
                              </os> 
                      </activation> 
                      <properties>
      			<toolsJAR>${java.home}/../lib/tools.jar</toolsJAR>
      		</properties> 
              </profile> 
              <profile> 
                      <id>tools-jar-unix</id> 
                      <activation> 
                              <os> 
                                      <!-- We need to exclude Mac OS X since it is in family 'unix' --> 
                                      <family>unix</family> 
                                      <name>!mac os x</name> 
                              </os> 
                      </activation> 
                      <properties>
      			<toolsJAR>${java.home}/../lib/tools.jar</toolsJAR>
      		</properties>
              </profile> 
              <profile><!-- Mac OSX Java JDK doesn't has separate tools.jar. --> 
                      <id>tools-jar-mac</id> 
                      <activation> 
                              <os> 
                                      <!-- We can not only use 'family' discriminator since Mac also has 'family = unix' --> 
                                      <family>unix</family> 
                                      <name>mac os x</name> 
                              </os> 
                      </activation> 
                      <properties>
      			<toolsJAR>${java.home}/../Classes/classes.jar</toolsJAR>
      		</properties> 
              </profile> 
      <profiles>

      So in this example I use <name>!mac os x</name> to specify that the profile <id>tools-jar-unix</id> should be applied to all UNIX family operating systems except Mac OS X.

      This example was tested with Maven 2.0.9, 2.0.10, 2.1.0 on Windows XP, Linux (Ubuntu 8.10), and Mac OS X 10.5.6 and it works for all of them. Nice

      Cheers,
      Thorsten

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Thorsten Möller
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: