You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Lara Brian <la...@yahoo.com> on 2007/06/28 19:08:38 UTC

Deactivate one profile when activating another

Hi All,
I have couple of profiles, one of which is activeByDefault. I want to
activate another one by using properties, but that should deactivate the
other one? IS this possible in maven now?

Here is the section from settings.xml

<profile>
   <id>debug</id>
   <activation>
    <activeByDefault>true</activeByDefault>
    <property>
     <name>BV</name>
     <value>debug</value>
    </property>
   </activation>
   <properties>
    <build.variant>debug</build.variant>
   </properties>
  </profile>
  <profile>
   <id>optimize</id>
   <activation>
    <activeByDefault>false</activeByDefault>
    <property>
     <name>BV</name>
     <value>optimize</value>
    </property>
   </activation>
   <properties>
    <build.variant>optimize</build.variant>
   </properties>
  </profile>

What i want is to use the "build.variant" property for "optimize" profile
when it is activated by,
mvn -DBV=optimize install

if none is specified by,
mvn install
want to use the "build.variant" of "debug" profile.

No matter what i do, the debug "build.variant" is all iam getting.
Is it possible to deactivate "debug" by activating "optimize"?

I don't want to make it mandatory for the user to specify which profile he
wants to activate all the time (want debug by default, but when specified as
optimize, deactivate debug and activate optimize)

Any help or pointers in this regard is highly appreciated.
Thanks,
Shankar.
-- 
View this message in context: http://www.nabble.com/Deactivate-one-profile-when-activating-another-tf3995531s177.html#a11346995
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Deactivate one profile when activating another

Posted by Julien Stern <ju...@cryptolog.com>.
On Thu, Jun 28, 2007 at 10:08:38AM -0700, Lara Brian wrote:
> 
> Hi All,
> I have couple of profiles, one of which is activeByDefault. I want to
> activate another one by using properties, but that should deactivate the
> other one? IS this possible in maven now?

A profile declared as "activeByDefault" is simply deactivated as soon
as an other profile is activated when you declare it in your pom.xml.
Maybe you should put it in there.

Otherwise, if you want to keep it in your settings.xml, there is a
very nice undocumented feature which is to put a bang ("!") to
negate an expression in the activation. e.g.

<property>
  <name>!BV</name>
<property>

means "when BV is not defined"

and

<property>
  <name>BV</name>
  <value>!optimize</value>
<property>

means "when BV is not equal to optimize.

--
Julien

> Here is the section from settings.xml
> 
> <profile>
>    <id>debug</id>
>    <activation>
>     <activeByDefault>true</activeByDefault>
>     <property>
>      <name>BV</name>
>      <value>debug</value>
>     </property>
>    </activation>
>    <properties>
>     <build.variant>debug</build.variant>
>    </properties>
>   </profile>
>   <profile>
>    <id>optimize</id>
>    <activation>
>     <activeByDefault>false</activeByDefault>
>     <property>
>      <name>BV</name>
>      <value>optimize</value>
>     </property>
>    </activation>
>    <properties>
>     <build.variant>optimize</build.variant>
>    </properties>
>   </profile>
> 
> What i want is to use the "build.variant" property for "optimize" profile
> when it is activated by,
> mvn -DBV=optimize install
> 
> if none is specified by,
> mvn install
> want to use the "build.variant" of "debug" profile.
> 
> No matter what i do, the debug "build.variant" is all iam getting.
> Is it possible to deactivate "debug" by activating "optimize"?
> 
> I don't want to make it mandatory for the user to specify which profile he
> wants to activate all the time (want debug by default, but when specified as
> optimize, deactivate debug and activate optimize)
> 
> Any help or pointers in this regard is highly appreciated.
> Thanks,
> Shankar.
> -- 
> View this message in context: http://www.nabble.com/Deactivate-one-profile-when-activating-another-tf3995531s177.html#a11346995
> Sent from the Maven - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 

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