Hello,

I just found a---to my best knowledge---undocumented feature and though 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>
                <!-- ... -->
        </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>
                <!-- ... -->
        </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>
                <!-- ... -->
        </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, Linux,
and Mac OS X and it works for all of them. Nice :-)

Cheers,
Thorsten
-- 
View this message in context: 
http://www.nabble.com/Undocumented-Feature%3A-Usage-of-negation-for-profile-activation-tp23446509p23446509.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to