You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Morris Jones <mo...@whiteoaks.com> on 2007/10/25 20:01:28 UTC
How to override an activeByDefault profile?
Say I have a settings.xml file with three profiles, "dev" "qa" and
"production". The active profile will set variables that determine
which database to use and things like that.
I have activations so that I can use -Denv=qa or -Denv=dev to get the
right profile. But I'd like to have one of the profiles to be the
default _in case another one isn't selected_. That way I'm not always
having to type -Denv=dev when I do a dev built.
So I put an <activeByDefault>true</activeByDefault> tag in the dev
profile, and false on the others.
Now mvn help:active-profiles reports:
The following profiles are active:
- env-dev (source: settings.xml)
- env-dev (source: settings.xml)
(Twice?)
And if I do mvn -Denv=qa help:active-profiles I get:
The following profiles are active:
- env-dev (source: settings.xml)
- env-qa (source: settings.xml)
- env-dev (source: settings.xml)
And my app is built with the dev profile.
In other words, I can't override the activeByDefault setting, no matter
what I specify. I get the same thing if I say "mvn -P env-qa
help:active-profiles".
What is it I'm missing here?
Mojo
--
Morris Jones
Monrovia, CA
http://www.whiteoaks.com
Old Town Astronomers http://www.otastro.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: How to override an activeByDefault profile?
Posted by Morris Jones <mo...@whiteoaks.com>.
Hi Ian, thanks. Yes, I've tried that. It has the same effect as
specifying a different profile on the command line. In this case, the
one set in activeProfiles is _always_ active, and can't be overridden at
all. :(
Mojo
Ian Springer wrote:
> I recall reading somewhere in the Maven docs or wiki that
> activeByDefault has higher precedence than even properties specified on
> the command line. Have you tried using:
>
> <settings>
> ...
> <activeProfiles>
> <activeProfile>dev</activeProfile>
> </activeProfiles>
> ...
> </settings>
>
> ?
>
> Nick Stolwijk wrote:
>> I thought I had a solution, but it didn't work. I think it should
>> work, but I'm not certain. This could be a bug. This is what I had:
>>
>> <properties>
>> <dev-active>true</dev-active>
>> </properties>
>>
>> <profiles>
>> <profile>
>> <id>dev</id>
>> <activation>
>> <property>
>> <name>dev-active</name>
>> <value>true</value>
>> </property>
>> </activation>
>> </profile>
>> <profile>
>> <id>prod</id>
>> <activation>
>> <property>
>> <name>env</name>
>> <value>prod</value>
>> </property>
>> </activation>
>> <properties>
>> <dev-active>false</dev-active>
>> </properties>
>> </profile>
>> <profile>
>> <id>qa</id>
>> <activation>
>> <property>
>> <name>env</name>
>> <value>qa</value>
>> </property>
>> </activation>
>> <properties>
>> <dev-active>false</dev-active>
>> </properties>
>> </profile>
>> </profiles>
>>
>> In short, only activate dev when the property is true. When activating
>> another profile, set the property to false. Unfortunately, it ain't
>> working. Somebody has a better idea?
>>
>> Hth,
>>
>> Nick Stolwijk
>>
>> Morris Jones wrote:
>>> Say I have a settings.xml file with three profiles, "dev" "qa" and
>>> "production". The active profile will set variables that determine
>>> which database to use and things like that.
>>>
>>> I have activations so that I can use -Denv=qa or -Denv=dev to get the
>>> right profile. But I'd like to have one of the profiles to be the
>>> default _in case another one isn't selected_. That way I'm not
>>> always having to type -Denv=dev when I do a dev built.
>>>
>>> So I put an <activeByDefault>true</activeByDefault> tag in the dev
>>> profile, and false on the others.
>>>
>>> Now mvn help:active-profiles reports:
>>>
>>> The following profiles are active:
>>>
>>> - env-dev (source: settings.xml)
>>> - env-dev (source: settings.xml)
>>>
>>> (Twice?)
>>>
>>> And if I do mvn -Denv=qa help:active-profiles I get:
>>>
>>> The following profiles are active:
>>>
>>> - env-dev (source: settings.xml)
>>> - env-qa (source: settings.xml)
>>> - env-dev (source: settings.xml)
>>>
>>> And my app is built with the dev profile.
>>>
>>> In other words, I can't override the activeByDefault setting, no
>>> matter what I specify. I get the same thing if I say "mvn -P env-qa
>>> help:active-profiles".
>>>
>>> What is it I'm missing here?
>>>
>>> Mojo
>>
>>
>> ---------------------------------------------------------------------
>> 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
--
Morris Jones
Monrovia, CA
http://www.whiteoaks.com
Old Town Astronomers http://www.otastro.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: How to override an activeByDefault profile?
Posted by Ian Springer <ia...@redhat.com>.
I recall reading somewhere in the Maven docs or wiki that
activeByDefault has higher precedence than even properties specified on
the command line. Have you tried using:
<settings>
...
<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>
...
</settings>
?
Nick Stolwijk wrote:
> I thought I had a solution, but it didn't work. I think it should
> work, but I'm not certain. This could be a bug. This is what I had:
>
> <properties>
> <dev-active>true</dev-active>
> </properties>
>
> <profiles>
> <profile>
> <id>dev</id>
> <activation>
> <property>
> <name>dev-active</name>
> <value>true</value>
> </property>
> </activation>
> </profile>
> <profile>
> <id>prod</id>
> <activation>
> <property>
> <name>env</name>
> <value>prod</value>
> </property>
> </activation>
> <properties>
> <dev-active>false</dev-active>
> </properties>
> </profile>
> <profile>
> <id>qa</id>
> <activation>
> <property>
> <name>env</name>
> <value>qa</value>
> </property>
> </activation>
> <properties>
> <dev-active>false</dev-active>
> </properties>
> </profile>
> </profiles>
>
> In short, only activate dev when the property is true. When activating
> another profile, set the property to false. Unfortunately, it ain't
> working. Somebody has a better idea?
>
> Hth,
>
> Nick Stolwijk
>
> Morris Jones wrote:
>> Say I have a settings.xml file with three profiles, "dev" "qa" and
>> "production". The active profile will set variables that determine
>> which database to use and things like that.
>>
>> I have activations so that I can use -Denv=qa or -Denv=dev to get the
>> right profile. But I'd like to have one of the profiles to be the
>> default _in case another one isn't selected_. That way I'm not
>> always having to type -Denv=dev when I do a dev built.
>>
>> So I put an <activeByDefault>true</activeByDefault> tag in the dev
>> profile, and false on the others.
>>
>> Now mvn help:active-profiles reports:
>>
>> The following profiles are active:
>>
>> - env-dev (source: settings.xml)
>> - env-dev (source: settings.xml)
>>
>> (Twice?)
>>
>> And if I do mvn -Denv=qa help:active-profiles I get:
>>
>> The following profiles are active:
>>
>> - env-dev (source: settings.xml)
>> - env-qa (source: settings.xml)
>> - env-dev (source: settings.xml)
>>
>> And my app is built with the dev profile.
>>
>> In other words, I can't override the activeByDefault setting, no
>> matter what I specify. I get the same thing if I say "mvn -P env-qa
>> help:active-profiles".
>>
>> What is it I'm missing here?
>>
>> Mojo
>
>
> ---------------------------------------------------------------------
> 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: How to override an activeByDefault profile?
Posted by Nick Stolwijk <ni...@planet.nl>.
I thought I had a solution, but it didn't work. I think it should work,
but I'm not certain. This could be a bug. This is what I had:
<properties>
<dev-active>true</dev-active>
</properties>
<profiles>
<profile>
<id>dev</id>
<activation>
<property>
<name>dev-active</name>
<value>true</value>
</property>
</activation>
</profile>
<profile>
<id>prod</id>
<activation>
<property>
<name>env</name>
<value>prod</value>
</property>
</activation>
<properties>
<dev-active>false</dev-active>
</properties>
</profile>
<profile>
<id>qa</id>
<activation>
<property>
<name>env</name>
<value>qa</value>
</property>
</activation>
<properties>
<dev-active>false</dev-active>
</properties>
</profile>
</profiles>
In short, only activate dev when the property is true. When activating
another profile, set the property to false. Unfortunately, it ain't
working. Somebody has a better idea?
Hth,
Nick Stolwijk
Morris Jones wrote:
> Say I have a settings.xml file with three profiles, "dev" "qa" and
> "production". The active profile will set variables that determine
> which database to use and things like that.
>
> I have activations so that I can use -Denv=qa or -Denv=dev to get the
> right profile. But I'd like to have one of the profiles to be the
> default _in case another one isn't selected_. That way I'm not always
> having to type -Denv=dev when I do a dev built.
>
> So I put an <activeByDefault>true</activeByDefault> tag in the dev
> profile, and false on the others.
>
> Now mvn help:active-profiles reports:
>
> The following profiles are active:
>
> - env-dev (source: settings.xml)
> - env-dev (source: settings.xml)
>
> (Twice?)
>
> And if I do mvn -Denv=qa help:active-profiles I get:
>
> The following profiles are active:
>
> - env-dev (source: settings.xml)
> - env-qa (source: settings.xml)
> - env-dev (source: settings.xml)
>
> And my app is built with the dev profile.
>
> In other words, I can't override the activeByDefault setting, no
> matter what I specify. I get the same thing if I say "mvn -P env-qa
> help:active-profiles".
>
> What is it I'm missing here?
>
> Mojo
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: How to override an activeByDefault profile?
Posted by Greg Morgan <dr...@cox.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Morris Jones wrote:
> Say I have a settings.xml file with three profiles, "dev" "qa" and
> "production". The active profile will set variables that determine
> which database to use and things like that.
I have a sense that you are almost there. I would rather that you
create all of your profiles in the pom.xml file. Use a corresponding
key in your settings.xml file for password data. I believe what you are
experiencing is that all the profiles are active because there is no tie
to the pom.xml file.
http://www.devx.com/Java/Article/32386/0/page/2
"Environmental Portability with Profiles
As a general rule, try to make one profile per environment. Unless you
are building on more than five or so environment types, I suggest
putting the profile in the POM. Then you may activate the desired
profile via the -P argument on the command line. You can test which
profiles are currently active with the "help" plugin, like this:
mvn help:active-profiles
It sounds like you are trying to do all this in your settings.xml file.
HTH,
Greg
>
> I have activations so that I can use -Denv=qa or -Denv=dev to get the
> right profile. But I'd like to have one of the profiles to be the
> default _in case another one isn't selected_. That way I'm not always
> having to type -Denv=dev when I do a dev built.
>
> So I put an <activeByDefault>true</activeByDefault> tag in the dev
> profile, and false on the others.
>
> Now mvn help:active-profiles reports:
>
> The following profiles are active:
>
> - env-dev (source: settings.xml)
> - env-dev (source: settings.xml)
>
> (Twice?)
>
> And if I do mvn -Denv=qa help:active-profiles I get:
>
> The following profiles are active:
>
> - env-dev (source: settings.xml)
> - env-qa (source: settings.xml)
> - env-dev (source: settings.xml)
>
> And my app is built with the dev profile.
>
> In other words, I can't override the activeByDefault setting, no matter
> what I specify. I get the same thing if I say "mvn -P env-qa
> help:active-profiles".
>
> What is it I'm missing here?
>
> Mojo
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iD8DBQFHJRcRxyxe5L6mr7IRAh1zAKCWIOU1Ev96KVQM2t9KS0t8PJeFjwCgiAap
MRyDqy4k/95XH/PD8462Dzg=
=2Xcz
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org