profile activation based on environment variables

View: New views
4 Messages — Rating Filter:   Alert me  

profile activation based on environment variables

by Haroon Rafique :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm using maven 2.0.4 on a Gentoo Linux machine. Does anyone have
experience in activating profiles based on environment variables? I figure
using the env prefix would do the trick. So, far I have tried:

         <profile>
             <id>haroon-workstation</id>
             <activation>
                 <property>
                     <name>env.BLAH</name>
                     <value>blah</value>
                 </property>
             </activation>
             <properties>
                 <user.install.root>/www/tomcat</user.install.root>
             </properties>
         </profile>

After setting:
  export BLAH=blah
and execuging:
  mvn help:active-profile
I still get:

[INFO] [help:active-profiles]
[INFO]
Active Profiles for Project 'ca.utoronto.sis:sws:war:1.0':

There are no active profiles.

On an aside, the only way I can activate that profile is to use !env.BLAH:

         <profile>
             <id>haroon-workstation</id>
             <activation>
                 <property>
                     <name>!env.BLAH</name>
                 </property>
             </activation>
             <properties>
                 <user.install.root>/www/tomcat</user.install.root>
             </properties>
         </profile>

Is this a bug? Should I raise a jira issue?

What I'm eventually trying to do is to do some per host profile
activation, so I was thinking of using env.HOSTNAME as the activation. Any
ideas to do something similar?

Thanks,
--
Haroon Rafique
<haroon.rafique@...>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: profile activation based on environment variables

by Arnaud Bailly :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Haroon Rafique <haroon.rafique@...> writes:

> Hi,
>
> I'm using maven 2.0.4 on a Gentoo Linux machine. Does anyone have
> experience in activating profiles based on environment variables? I
> figure using the env prefix would do the trick. So, far I have tried:
>
>         <profile>
>             <id>haroon-workstation</id>
>             <activation>
>                 <property>
>                     <name>env.BLAH</name>
>                     <value>blah</value>
>                 </property>
>             </activation>
>             <properties>
>                 <user.install.root>/www/tomcat</user.install.root>
>             </properties>
>         </profile>
>
> After setting:
> export BLAH=blah
> and execuging:
> mvn help:active-profile
> I still get:

Not sure but I think that what you call environment variables are
actually system properties set on maven's cli: Try

<activation>
    <property>
        <name>BLAH</name>
        <value>blah</value>
    </property>
</activation>

mvn -DBLAH=blah help:active-profile


HTH


--
OQube < software engineering \ génie logiciel >
Arnaud Bailly, Dr.
\web> http://www.oqube.com


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: profile activation based on environment variables

by Haroon Rafique :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Today at 11:07am, AB=>Arnaud Bailly <abailly@...> wrote:

AB> [..snip..]
AB>
AB> Not sure but I think that what you call environment variables are
AB> actually system properties set on maven's cli: Try
AB>
AB> <activation>
AB>     <property>
AB>         <name>BLAH</name>
AB>         <value>blah</value>
AB>     </property>
AB> </activation>
AB>
AB> mvn -DBLAH=blah help:active-profile
AB>
AB>
AB> HTH

Hi Arnaud,

Thanks for the reply, but I'm positive I want environment variables and
not system properties. From http://maven.apache.org/settings.html

env.X: Prefixing a variable with "env." will return the shell's
environment variable. For example, ${env.PATH} contains the $path
environment variable (%PATH% in Windows).

I believe this has been in maven since 2.0.1+ (was implemented via MNG-1525).
http://jira.codehaus.org/browse/MNG-1525

Any more insight would be helpful.

Regards,
--
Haroon Rafique
<haroon.rafique@...>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: profile activation based on environment variables

by Arnaud Bailly :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Haroon Rafique <haroon.rafique@...> writes:

>
> Hi Arnaud,
>
> Thanks for the reply, but I'm positive I want environment variables and
> not system properties. From http://maven.apache.org/settings.html
>
> env.X: Prefixing a variable with "env." will return the shell's
> environment variable. For example, ${env.PATH} contains the $path
> environment variable (%PATH% in Windows).
>
> I believe this has been in maven since 2.0.1+ (was implemented via MNG-1525).
> http://jira.codehaus.org/browse/MNG-1525
>
> Any more insight would be helpful.

Sorry for the noise :-(

--
OQube < software engineering \ génie logiciel >
Arnaud Bailly, Dr.
\web> http://www.oqube.com


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...