You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Graham Leggett <mi...@sharp.fm> on 2007/02/06 19:58:17 UTC

Activating profiles based on OS doesn't seem to work right

Hi all,

I've been trying to use profile activation based on OS to work around 
maven's lack of support for exposing the OS family (you can test against 
the current OS family, you just cannot find out what the current OS 
family is using ${maven.os.family} or some equivalent, or it least it 
seems that way from the users list).

For example, the following profile doesn't match anything on MacosX:

     <profile>
       <id>activate-mac</id>
       <properties>
         <os-platform>macosx</os-platform>
         <os-arch>${os.arch}</os-arch>
       </properties>
       <activation>
         <os>
           <name>Mac OS X</name>
         </os>
       </activation>
     </profile>

The following variation does detect MacosX (using family instead of name):

     <profile>
       <id>activate-mac</id>
       <properties>
         <os-platform>macosx</os-platform>
         <os-arch>${os.arch}</os-arch>
       </properties>
       <activation>
         <os>
           <family>mac</family>
         </os>
       </activation>
     </profile>
     ...
   <properties>
     <os-arch>ppc</os-arch>
     <os-platform>macosx</os-platform>
   </properties>

But, as soon as you try and detect Linux and MacosX side by side, Linux 
is detected on MacosX, instead of MacOSX:

     <profile>
       <id>activate-linux</id>
       <properties>
         <os-platform>linux</os-platform>
         <os-arch>${os.arch}</os-arch>
       </properties>
       <activation>
         <os>
           <familylinux</family>
         </os>
       </activation>
     </profile>
     <profile>
       <id>activate-mac</id>
       <properties>
         <os-platform>macosx</os-platform>
         <os-arch>${os.arch}</os-arch>
       </properties>
       <activation>
         <os>
           <family>mac</family>
         </os>
       </activation>
     </profile>
     ...
   <properties>
     <os-platform>linux</os-platform>
     <os-arch>ppc</os-arch>
   </properties>

Similar weirdness happens when you try and mix family linux with family 
unix - linux is reported on solaris, instead of unix.

The values are being tested using mvn help:effective-pom.

The problem I am trying to solve is to obtain a filename-friendly 
version of ${os.name} ("Windows XP" and "Mac OS X" contain spaces and 
are therefore not filename friendly), to be used as a classifier.

Does anyone know what the canonical way to do this is?

Regards,
Graham
--

Re: Activating profiles based on OS doesn't seem to work right

Posted by Franz Allan Valencia See <fr...@gmail.com>.
Good day to you, Matt,

Thanks for the additional info.

Yes, plexus-utils Os.java is the one handling the comparison in the os
activation. Also, it is the reference that I use for [1] ( I placed it
under maven user since I don't have write access to the PLEXUS wiki ).

Furthermore, yes, the os.xxx are retrieved and converted to lowercase.
But I am not sure how the those are read from the xml file ( whether
modello reads those and converts in lowercase as well ). Also, os
activation does not seem to be case sensitive in my machine ( windows
xp ).

Anyway, you may want to update [1] as well :)

Thanks,
Franz

[1] http://docs.codehaus.org/display/MAVENUSER/Profiles

On 2/8/07, Matt Brozowski <br...@opennms.org> wrote:
>
> On Feb 6, 2007, at 1:58 PM, Graham Leggett wrote:
>
> > Hi all,
> >
> > I've been trying to use profile activation based on OS to work
> > around maven's lack of support for exposing the OS family (you can
> > test against the current OS family, you just cannot find out what
> > the current OS family is using ${maven.os.family} or some
> > equivalent, or it least it seems that way from the users list).
>
> <snip>
>
> > The following variation does detect MacosX (using family instead of
> > name):
> >
> >     <profile>
> >       <id>activate-mac</id>
> >       <properties>
> >         <os-platform>macosx</os-platform>
> >         <os-arch>${os.arch}</os-arch>
> >       </properties>
> >       <activation>
> >         <os>
> >           <family>mac</family>
> >         </os>
> >       </activation>
> >     </profile>
>
> <snip>
>
> > But, as soon as you try and detect Linux and MacosX side by side,
> > Linux is detected on MacosX, instead of MacOSX:
> >
> >     <profile>
> >       <id>activate-linux</id>
> >       <properties>
> >         <os-platform>linux</os-platform>
> >         <os-arch>${os.arch}</os-arch>
> >       </properties>
> >       <activation>
> >         <os>
> >           <familylinux</family>
> >         </os>
>
>
> I've done some research on this myself.  The code this is actually
> doing the checking is here is from plexus-utils.  I believe the
> version that is being used is :
>
> http://svn.plexus.codehaus.org/browse/plexus/tags/plexus-utils-1.1/
> src/main/java/org/codehaus/plexus/util/Os.java?r=3008
>
> It turns out there is no linux family, there is only a 'unix' family
> which includes Mac OS X (since the name ends with X)
>
> The by name stuff does compare case sensitive with the lower cased
> version of os.name, so you must use the all lower cased version.
>
> This has been fixed in the latest version of plexus-utils version 1.4
>
> Will maven-2.0.5 use the 1.4 version or an earlier one.
>
> To solve the problem for my self... I use <family>mac</family> and
> <name>linux<name> for the two profiles.
>
> Hope that helps!
>
> Matt Brozowski
>
>
> ________________________________________________________________________
> ___
> Matt Brozowski, OpenNMS Maintainer Main: +1 919 812 4984
> The OpenNMS Group, Inc. Fax: +1 503 961 7746
> Email: brozow@opennms.org URL: http://www.opennms.com
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Activating profiles based on OS doesn't seem to work right

Posted by Matt Brozowski <br...@opennms.org>.
On Feb 6, 2007, at 1:58 PM, Graham Leggett wrote:

> Hi all,
>
> I've been trying to use profile activation based on OS to work  
> around maven's lack of support for exposing the OS family (you can  
> test against the current OS family, you just cannot find out what  
> the current OS family is using ${maven.os.family} or some  
> equivalent, or it least it seems that way from the users list).

<snip>

> The following variation does detect MacosX (using family instead of  
> name):
>
>     <profile>
>       <id>activate-mac</id>
>       <properties>
>         <os-platform>macosx</os-platform>
>         <os-arch>${os.arch}</os-arch>
>       </properties>
>       <activation>
>         <os>
>           <family>mac</family>
>         </os>
>       </activation>
>     </profile>

<snip>

> But, as soon as you try and detect Linux and MacosX side by side,  
> Linux is detected on MacosX, instead of MacOSX:
>
>     <profile>
>       <id>activate-linux</id>
>       <properties>
>         <os-platform>linux</os-platform>
>         <os-arch>${os.arch}</os-arch>
>       </properties>
>       <activation>
>         <os>
>           <familylinux</family>
>         </os>


I've done some research on this myself.  The code this is actually  
doing the checking is here is from plexus-utils.  I believe the  
version that is being used is :

http://svn.plexus.codehaus.org/browse/plexus/tags/plexus-utils-1.1/ 
src/main/java/org/codehaus/plexus/util/Os.java?r=3008

It turns out there is no linux family, there is only a 'unix' family  
which includes Mac OS X (since the name ends with X)

The by name stuff does compare case sensitive with the lower cased  
version of os.name, so you must use the all lower cased version.

This has been fixed in the latest version of plexus-utils version 1.4

Will maven-2.0.5 use the 1.4 version or an earlier one.

To solve the problem for my self... I use <family>mac</family> and  
<name>linux<name> for the two profiles.

Hope that helps!

Matt Brozowski


________________________________________________________________________ 
___
Matt Brozowski, OpenNMS Maintainer Main: +1 919 812 4984
The OpenNMS Group, Inc. Fax: +1 503 961 7746
Email: brozow@opennms.org URL: http://www.opennms.com



Re: Activating profiles based on OS doesn't seem to work right

Posted by Vincent Massol <vi...@massol.net>.
I've had this exact same problem yesterday but I thought it was me  
doing something wrong...

It looks like a bug and I think a jira should be opened.

Thanks
-Vincent

On Feb 6, 2007, at 7:58 PM, Graham Leggett wrote:

> Hi all,
>
> I've been trying to use profile activation based on OS to work  
> around maven's lack of support for exposing the OS family (you can  
> test against the current OS family, you just cannot find out what  
> the current OS family is using ${maven.os.family} or some  
> equivalent, or it least it seems that way from the users list).
>
> For example, the following profile doesn't match anything on MacosX:
>
>     <profile>
>       <id>activate-mac</id>
>       <properties>
>         <os-platform>macosx</os-platform>
>         <os-arch>${os.arch}</os-arch>
>       </properties>
>       <activation>
>         <os>
>           <name>Mac OS X</name>
>         </os>
>       </activation>
>     </profile>
>
> The following variation does detect MacosX (using family instead of  
> name):
>
>     <profile>
>       <id>activate-mac</id>
>       <properties>
>         <os-platform>macosx</os-platform>
>         <os-arch>${os.arch}</os-arch>
>       </properties>
>       <activation>
>         <os>
>           <family>mac</family>
>         </os>
>       </activation>
>     </profile>
>     ...
>   <properties>
>     <os-arch>ppc</os-arch>
>     <os-platform>macosx</os-platform>
>   </properties>
>
> But, as soon as you try and detect Linux and MacosX side by side,  
> Linux is detected on MacosX, instead of MacOSX:
>
>     <profile>
>       <id>activate-linux</id>
>       <properties>
>         <os-platform>linux</os-platform>
>         <os-arch>${os.arch}</os-arch>
>       </properties>
>       <activation>
>         <os>
>           <familylinux</family>
>         </os>
>       </activation>
>     </profile>
>     <profile>
>       <id>activate-mac</id>
>       <properties>
>         <os-platform>macosx</os-platform>
>         <os-arch>${os.arch}</os-arch>
>       </properties>
>       <activation>
>         <os>
>           <family>mac</family>
>         </os>
>       </activation>
>     </profile>
>     ...
>   <properties>
>     <os-platform>linux</os-platform>
>     <os-arch>ppc</os-arch>
>   </properties>
>
> Similar weirdness happens when you try and mix family linux with  
> family unix - linux is reported on solaris, instead of unix.
>
> The values are being tested using mvn help:effective-pom.
>
> The problem I am trying to solve is to obtain a filename-friendly  
> version of ${os.name} ("Windows XP" and "Mac OS X" contain spaces  
> and are therefore not filename friendly), to be used as a classifier.
>
> Does anyone know what the canonical way to do this is?
>
> Regards,
> Graham
> --


	

	
		
___________________________________________________________________________ 
Yahoo! Mail r�invente le mail ! D�couvrez le nouveau Yahoo! Mail et son interface r�volutionnaire.
http://fr.mail.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Activating profiles based on OS doesn't seem to work right

Posted by Graham Leggett <mi...@sharp.fm>.
On Wed, February 7, 2007 3:46 am, Franz Allan Valencia See wrote:

> I don't know why this should not work ( and I don't have a Mac to try
> it on). Try entering the os name all in small caps ( i.e. "mac os x"
> ).

Small case works, even though when you print the value of ${os.name} the
operating system is listed capitalised, like so: "Mac OS X".

I added it to JIRA like so:

http://jira.codehaus.org/browse/MNG-2814

> I don't know why mac is not detected, but linux gets detected (
> assuming by "<familylinux</family>" you meant "<family>linux</family>"
> ) because linux is an unknown os family to maven2. And unknown os
> family always gets activated ( I have just filed an issue for this.
> see [1] )

Ok - it seems I am being bitten by the unknown os family gets activated
problem as well, which is why "linux" keeps winning.

I had already looked at the list at [2], and could have sworn linux was on
that list (on second look it isn't, you're quite correct). Need more
sleep.

Regards,
Graham
--



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Activating profiles based on OS doesn't seem to work right

Posted by Franz Allan Valencia See <fr...@gmail.com>.
Good day, Graham,

See inline comments.

On 2/6/07, Graham Leggett <mi...@sharp.fm> wrote:
> For example, the following profile doesn't match anything on MacosX:
>
>      <profile>
>        <id>activate-mac</id>
>        <properties>
>          <os-platform>macosx</os-platform>
>          <os-arch>${os.arch}</os-arch>
>        </properties>
>        <activation>
>          <os>
>            <name>Mac OS X</name>
>          </os>
>        </activation>
>      </profile>

I don't know why this should not work ( and I don't have a Mac to try
it on). Try entering the os name all in small caps ( i.e. "mac os x"
).

> But, as soon as you try and detect Linux and MacosX side by side, Linux
> is detected on MacosX, instead of MacOSX:
>
>      <profile>
>        <id>activate-linux</id>
>        <properties>
>          <os-platform>linux</os-platform>
>          <os-arch>${os.arch}</os-arch>
>        </properties>
>        <activation>
>          <os>
>            <familylinux</family>
>          </os>
>        </activation>
>      </profile>
>      <profile>
>        <id>activate-mac</id>
>        <properties>
>          <os-platform>macosx</os-platform>
>          <os-arch>${os.arch}</os-arch>
>        </properties>
>        <activation>
>          <os>
>            <family>mac</family>
>          </os>
>        </activation>
>      </profile>
>      ...
>    <properties>
>      <os-platform>linux</os-platform>
>      <os-arch>ppc</os-arch>
>    </properties>

I don't know why mac is not detected, but linux gets detected (
assuming by "<familylinux</family>" you meant "<family>linux</family>"
) because linux is an unknown os family to maven2. And unknown os
family always gets activated ( I have just filed an issue for this.
see [1] )

> Similar weirdness happens when you try and mix family linux with family
> unix - linux is reported on solaris, instead of unix.

Same as above - not sure why solaris is not detected as unix ( and I
don't know if it should be or if it's categorize as something else )
but linux gets detected because of [1].

Also, you may want to try and take a look at [2] for a list of
accepted os family activation values.

Cheers,
Franz

[1] http://jira.codehaus.org/browse/MNG-2812
[2] http://docs.codehaus.org/display/MAVENUSER/Profiles

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org