You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Laurie Harper <la...@holoweb.net> on 2006/08/01 01:39:01 UTC

Aggregate profiles

Is it possible to activate multiple profiles at once, as in 'mvn 
-Pprofile1 -Pprofile2', and have one profile override properties in the 
other? I'm trying to make it easy to enable p6spy, something like

   <profiles>
     <profile>
       <id>hsql</id>
       <activation>
         <activeByDefault>true</activeByDefault>
       </activation>
       <properties>
         <databaseType>hsqldb</databaseType>
         <databaseDriver>org.hsqldb.jdbcDriver</databaseDriver>
         ...
       </properties>
     </profile>
     <profile>
       <id>postgres</id>
       <properties>
         <databaseType>postgresql</databaseType>
         <databaseDriver>org.postgresql.Driver</databaseDriver>
         ...
       </properties>
     </profile>
     <profile>
       <id>p6spy</id>
       <properties>
         <databaseDriver>...P6SpyDriver</databaseDriver>
       </properties>
     </profile>
   </profiles>

the idea being that you can switch databases with '-Ppostgres' and 
enable P6Spy for either database with, for example, '-Ppostgres -Pp6spy'.

Unfortunately, it seems that Maven only sets the properties defined in 
*one* of the two profiles. Is there a way to get both?

Alternatively, is there another way to conditionally set properties in M2?

L.


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


Re: Aggregate profiles

Posted by Roland Asmann <Ro...@cfc.at>.
That is true, but for my project I have sort of a profile pre-requisite list...
I am looking for a way to have profile A automatically activated when I
activate B, which in turn is needed when I run C.
The thing is that I do not want to build profile A into B and C, and profile
B into C, which makes my POM very long and hard to maintain (since I
have more than the 3 profiles mentioned here as an example).
With the solution I wrote below, it is at least possible to have a sort of
profile-dependency, but it only helps with 2 profiles...
Might be that I'm lazy, but I find it somewhat like the life-cycle (run
'install' and all previous phases are run as well) and therefor would like
to see something like this implemented or at least explained as how
this might work...

Roland



On Tuesday 01 August 2006 10:24, Alexis Midon wrote:
> you can activate many profiles with -Pprofile1,profile2,profile3 etc. as
> explained in "mvn -h":
> -P,--activate-profiles        Comma-delimited list of profiles to activate
>
> On 8/1/06, Roland Asmann <Ro...@cfc.at> wrote:
> > I've been looking for something similar and found that it is possible,
> > but atm only for
> > a maximum of 2 profiles.
> > Use the property-activation for your profiles and activate 'p6spy' when
> > the property
> > is set. Then activate one of the other profiles when this property is set
> > to a specific
> > value:
> >
> > <profile>
> >         <id>p6spy</id>
> >         <activation>
> >                 <property>
> >                         <name>db</name>
> >                 </property>
> >         </activation>
> >         ........
> > </profile>
> > <profile>
> >         <id>hsql</id>
> >         <activation>
> >                 <property>
> >                         <name>db</name>
> >                         <value>hsql</value>
> >                 </property>
> >         </activation>
> >         ........
> > </profile>
> > <profile>
> >         <id>postgres</id>
> >         <activation>
> >                 <property>
> >                         <name>db</name>
> >                         <value>postgres</value>
> >                 </property>
> >         </activation>
> >         ........
> > </profile>
> >
> > Now, if you run 'mvn -Ddb=postgres' or '-Ddb=hsql' p6spy is ALWAYS
> > activated.
> >
> > Hope this helped.
> >
> > Roland
> >
> > On Tuesday 01 August 2006 01:39, Laurie Harper wrote:
> > > Is it possible to activate multiple profiles at once, as in 'mvn
> > > -Pprofile1 -Pprofile2', and have one profile override properties in the
> > > other? I'm trying to make it easy to enable p6spy, something like
> > >
> > >    <profiles>
> > >      <profile>
> > >        <id>hsql</id>
> > >        <activation>
> > >          <activeByDefault>true</activeByDefault>
> > >        </activation>
> > >        <properties>
> > >          <databaseType>hsqldb</databaseType>
> > >          <databaseDriver>org.hsqldb.jdbcDriver</databaseDriver>
> > >          ...
> > >        </properties>
> > >      </profile>
> > >      <profile>
> > >        <id>postgres</id>
> > >        <properties>
> > >          <databaseType>postgresql</databaseType>
> > >          <databaseDriver>org.postgresql.Driver</databaseDriver>
> > >          ...
> > >        </properties>
> > >      </profile>
> > >      <profile>
> > >        <id>p6spy</id>
> > >        <properties>
> > >          <databaseDriver>...P6SpyDriver</databaseDriver>
> > >        </properties>
> > >      </profile>
> > >    </profiles>
> > >
> > > the idea being that you can switch databases with '-Ppostgres' and
> > > enable P6Spy for either database with, for example, '-Ppostgres
> >
> > -Pp6spy'.
> >
> > > Unfortunately, it seems that Maven only sets the properties defined in
> > > *one* of the two profiles. Is there a way to get both?
> > >
> > > Alternatively, is there another way to conditionally set properties in
> >
> > M2?
> >
> > > L.
> > >
> > >
> > > ---------------------------------------------------------------------
> > > 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


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


Re: Aggregate profiles

Posted by Wendy Smoak <ws...@gmail.com>.
On 8/1/06, Laurie Harper <la...@holoweb.net> wrote:
> Hmm, using a comma-delimitted list of values with -P does get multiple
> profiles activated, but the value of databaseDriver isn't reset when the
> p6spy profile is included. The order the profiles are listed doesn't
> seem to have any effect; databaseDriver ends up set to the same thing
> with either -Phsql,p6spy or -Pp6spy,hsql.
>
> Any other suggestions?

I think you need to split the profiles up, and have one set that
controls which driver to use, then another set for the
database-specific configuration.

I would probably activate them with system properties (-D rather than
-P) because the configuration is more flexible.

For the driver, you need exactly one of them active (right?) so you can say
        <profile>
            <id>driver-p6spy</id>
            <activation>
                <property>
                    <name>driver</name>
                    <value>p6spy</value>
                </property>
            </activation>
            ...
and repeat for the others.  Activate with -Ddriver=p6spy (or -Ddriver=hsql.)

HTH,
-- 
Wendy

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


Re: Aggregate profiles

Posted by Laurie Harper <la...@holoweb.net>.
Hmm, using a comma-delimitted list of values with -P does get multiple 
profiles activated, but the value of databaseDriver isn't reset when the 
p6spy profile is included. The order the profiles are listed doesn't 
seem to have any effect; databaseDriver ends up set to the same thing 
with either -Phsql,p6spy or -Pp6spy,hsql.

Any other suggestions?

L.

Alexis Midon wrote:
> you can activate many profiles with -Pprofile1,profile2,profile3 etc. as
> explained in "mvn -h":
> -P,--activate-profiles        Comma-delimited list of profiles to activate
> 
> On 8/1/06, Roland Asmann <Ro...@cfc.at> wrote:
>>
>> I've been looking for something similar and found that it is possible, 
>> but
>> atm only for
>> a maximum of 2 profiles.
>> Use the property-activation for your profiles and activate 'p6spy' when
>> the property
>> is set. Then activate one of the other profiles when this property is set
>> to a specific
>> value:
>>
>> <profile>
>>         <id>p6spy</id>
>>         <activation>
>>                 <property>
>>                         <name>db</name>
>>                 </property>
>>         </activation>
>>         ........
>> </profile>
>> <profile>
>>         <id>hsql</id>
>>         <activation>
>>                 <property>
>>                         <name>db</name>
>>                         <value>hsql</value>
>>                 </property>
>>         </activation>
>>         ........
>> </profile>
>> <profile>
>>         <id>postgres</id>
>>         <activation>
>>                 <property>
>>                         <name>db</name>
>>                         <value>postgres</value>
>>                 </property>
>>         </activation>
>>         ........
>> </profile>
>>
>> Now, if you run 'mvn -Ddb=postgres' or '-Ddb=hsql' p6spy is ALWAYS
>> activated.
>>
>> Hope this helped.
>>
>> Roland
>>
>>
>>
>>
>> On Tuesday 01 August 2006 01:39, Laurie Harper wrote:
>> > Is it possible to activate multiple profiles at once, as in 'mvn
>> > -Pprofile1 -Pprofile2', and have one profile override properties in the
>> > other? I'm trying to make it easy to enable p6spy, something like
>> >
>> >    <profiles>
>> >      <profile>
>> >        <id>hsql</id>
>> >        <activation>
>> >          <activeByDefault>true</activeByDefault>
>> >        </activation>
>> >        <properties>
>> >          <databaseType>hsqldb</databaseType>
>> >          <databaseDriver>org.hsqldb.jdbcDriver</databaseDriver>
>> >          ...
>> >        </properties>
>> >      </profile>
>> >      <profile>
>> >        <id>postgres</id>
>> >        <properties>
>> >          <databaseType>postgresql</databaseType>
>> >          <databaseDriver>org.postgresql.Driver</databaseDriver>
>> >          ...
>> >        </properties>
>> >      </profile>
>> >      <profile>
>> >        <id>p6spy</id>
>> >        <properties>
>> >          <databaseDriver>...P6SpyDriver</databaseDriver>
>> >        </properties>
>> >      </profile>
>> >    </profiles>
>> >
>> > the idea being that you can switch databases with '-Ppostgres' and
>> > enable P6Spy for either database with, for example, '-Ppostgres
>> -Pp6spy'.
>> >
>> > Unfortunately, it seems that Maven only sets the properties defined in
>> > *one* of the two profiles. Is there a way to get both?
>> >
>> > Alternatively, is there another way to conditionally set properties in
>> M2?
>> >
>> > L.
>> >
>> >
>> > ---------------------------------------------------------------------
>> > 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
>>
>>
> 


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


Re: Aggregate profiles

Posted by Alexis Midon <al...@gmail.com>.
you can activate many profiles with -Pprofile1,profile2,profile3 etc. as
explained in "mvn -h":
-P,--activate-profiles        Comma-delimited list of profiles to activate

On 8/1/06, Roland Asmann <Ro...@cfc.at> wrote:
>
> I've been looking for something similar and found that it is possible, but
> atm only for
> a maximum of 2 profiles.
> Use the property-activation for your profiles and activate 'p6spy' when
> the property
> is set. Then activate one of the other profiles when this property is set
> to a specific
> value:
>
> <profile>
>         <id>p6spy</id>
>         <activation>
>                 <property>
>                         <name>db</name>
>                 </property>
>         </activation>
>         ........
> </profile>
> <profile>
>         <id>hsql</id>
>         <activation>
>                 <property>
>                         <name>db</name>
>                         <value>hsql</value>
>                 </property>
>         </activation>
>         ........
> </profile>
> <profile>
>         <id>postgres</id>
>         <activation>
>                 <property>
>                         <name>db</name>
>                         <value>postgres</value>
>                 </property>
>         </activation>
>         ........
> </profile>
>
> Now, if you run 'mvn -Ddb=postgres' or '-Ddb=hsql' p6spy is ALWAYS
> activated.
>
> Hope this helped.
>
> Roland
>
>
>
>
> On Tuesday 01 August 2006 01:39, Laurie Harper wrote:
> > Is it possible to activate multiple profiles at once, as in 'mvn
> > -Pprofile1 -Pprofile2', and have one profile override properties in the
> > other? I'm trying to make it easy to enable p6spy, something like
> >
> >    <profiles>
> >      <profile>
> >        <id>hsql</id>
> >        <activation>
> >          <activeByDefault>true</activeByDefault>
> >        </activation>
> >        <properties>
> >          <databaseType>hsqldb</databaseType>
> >          <databaseDriver>org.hsqldb.jdbcDriver</databaseDriver>
> >          ...
> >        </properties>
> >      </profile>
> >      <profile>
> >        <id>postgres</id>
> >        <properties>
> >          <databaseType>postgresql</databaseType>
> >          <databaseDriver>org.postgresql.Driver</databaseDriver>
> >          ...
> >        </properties>
> >      </profile>
> >      <profile>
> >        <id>p6spy</id>
> >        <properties>
> >          <databaseDriver>...P6SpyDriver</databaseDriver>
> >        </properties>
> >      </profile>
> >    </profiles>
> >
> > the idea being that you can switch databases with '-Ppostgres' and
> > enable P6Spy for either database with, for example, '-Ppostgres
> -Pp6spy'.
> >
> > Unfortunately, it seems that Maven only sets the properties defined in
> > *one* of the two profiles. Is there a way to get both?
> >
> > Alternatively, is there another way to conditionally set properties in
> M2?
> >
> > L.
> >
> >
> > ---------------------------------------------------------------------
> > 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
>
>

Re: Aggregate profiles

Posted by Roland Asmann <Ro...@cfc.at>.
I've been looking for something similar and found that it is possible, but atm only for
a maximum of 2 profiles.
Use the property-activation for your profiles and activate 'p6spy' when the property
is set. Then activate one of the other profiles when this property is set to a specific
value:

<profile>
	<id>p6spy</id>
	<activation>
		<property>
			<name>db</name>
		</property>
	</activation>
	........
</profile>
<profile>
	<id>hsql</id>
	<activation>
		<property>
			<name>db</name>
			<value>hsql</value>
		</property>
	</activation>
	........
</profile>
<profile>
	<id>postgres</id>
	<activation>
		<property>
			<name>db</name>
			<value>postgres</value>
		</property>
	</activation>
	........
</profile>

Now, if you run 'mvn -Ddb=postgres' or '-Ddb=hsql' p6spy is ALWAYS activated.

Hope this helped.

Roland




On Tuesday 01 August 2006 01:39, Laurie Harper wrote:
> Is it possible to activate multiple profiles at once, as in 'mvn
> -Pprofile1 -Pprofile2', and have one profile override properties in the
> other? I'm trying to make it easy to enable p6spy, something like
>
>    <profiles>
>      <profile>
>        <id>hsql</id>
>        <activation>
>          <activeByDefault>true</activeByDefault>
>        </activation>
>        <properties>
>          <databaseType>hsqldb</databaseType>
>          <databaseDriver>org.hsqldb.jdbcDriver</databaseDriver>
>          ...
>        </properties>
>      </profile>
>      <profile>
>        <id>postgres</id>
>        <properties>
>          <databaseType>postgresql</databaseType>
>          <databaseDriver>org.postgresql.Driver</databaseDriver>
>          ...
>        </properties>
>      </profile>
>      <profile>
>        <id>p6spy</id>
>        <properties>
>          <databaseDriver>...P6SpyDriver</databaseDriver>
>        </properties>
>      </profile>
>    </profiles>
>
> the idea being that you can switch databases with '-Ppostgres' and
> enable P6Spy for either database with, for example, '-Ppostgres -Pp6spy'.
>
> Unfortunately, it seems that Maven only sets the properties defined in
> *one* of the two profiles. Is there a way to get both?
>
> Alternatively, is there another way to conditionally set properties in M2?
>
> L.
>
>
> ---------------------------------------------------------------------
> 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