You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Jon Paynter <ki...@gmail.com> on 2010/10/26 23:42:50 UTC

profile activation confusion

Im trying to setup some build profiles for our various build environments
(dev, qa, prod, etc).  but I cant get the 'dev' profile to be active. The
envType property is set to a default value of 'dev' in my top level pom, but
it will sometimes be given on the command line, and in that case, activate
the appropiate profile for qa, or production.  The problem is I cant get the
dev profile to activate by just setting property values inside my pom.

Fragment from my pom:
<properties>
    <envType>dev</envType>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <fwVersion>SFP401</fwVersion>
</properties>

and then the profiles:
<profile>
    <id>dev</id>
    <activation>
      <property>
        <name>envType</name>
        <value>dev</value>
    </property>
    </activation>

based on the documentation I would think the dev profile would be active all
the time.  but when I run 'mvn help:active-profiles'  I see:
Active Profiles for Project 'myCompoany:app:pom:2.1':

The following profiles are active:

- nexus (source: settings.xml)

however if I run:  'mvn help:active-profiles -DenvType=dev'  then I see:
Active Profiles for Project 'myCompany:app:pom:2.1':

The following profiles are active:

- nexus (source: settings.xml)
 - dev (source: settings.xml)


what am I missing here?

Re: profile activation confusion

Posted by Jon Paynter <ki...@gmail.com>.
On Wed, Oct 27, 2010 at 11:41 AM, Anders Hammar <an...@hammar.net> wrote:

> You either need to separate the configuration from the binaries, or have
> different artifacts.
>
The configuration is separated from the binaries for the most part. however
some artifacts (like a war file) have environment specific class path names
in them.  But an integral part of our build process is to generate the
config files read by the binary artifacts at runtime.  Add to that some of
the "almost source" files like wsdl endup having server names embedded in
them (compliments of oracle).

But what do you mean by different artifacts?  Its not practical to have the
build create artifacts for every environment due to our parallel releases
process.  if Im testing the 3.0 release in the QA2 environment, thats all I
want to build.  Creating artifacts for an environment that will never be
used is a waste of time and resources.


>
> Your current solution does not work if you do deploys to a repo and adhere
> to the very important Maven rule that a release may NEVER be altered.
>
Unfortunately I cant change that.  The only thing that doesnt change between
environments is the source code.

Re: profile activation confusion

Posted by Anders Hammar <an...@hammar.net>.
You either need to separate the configuration from the binaries, or have
different artifacts.

Your current solution does not work if you do deploys to a repo and adhere
to the very important Maven rule that a release may NEVER be altered.

/Anders
On Wed, Oct 27, 2010 at 18:52, Jon Paynter <ki...@gmail.com> wrote:

> On Wed, Oct 27, 2010 at 5:51 AM, Jörg Schaible <joerg.schaible@gmx.de
> >wrote:
>
> > Anders Hammar wrote:
> >
> > > You need Maven 3.0 to be able to activate profiles in the pom by
> > > properties set in a profile in settings.xml.
> >
> > The point is that this functionality is superfluous. If you want a
> profile
> > be activated based on properties in settings.xml, you may as well simply
> > add
> >  it there to your activeProfiles section. Works also for M2.
>
> im using maven 3.0.  I ended up defining a property inside an already
> alwaysActive profile in the settings.xml.  Rather a kludge - but it works.
>
>
> On Wed, Oct 27, 2010 at 5:44 AM, Ron Wheeler <
> rwheeler@artifact-software.com
> > wrote:
>
> > On 27/10/2010 1:51 AM, Anders Hammar wrote:
> >
> >> While on the topic, I'd like to mention that having a different build
> >> (through profiles for example) for each environment is not good. In
> Maven,
> >> there can only be one flavor of a released artifact. So if you build
> v1.0
> >> of
> >> your war, cannot rebuild it with a different content.
> >>
> >> What you should do is build different artifacts for each environment.
> Use
> >> classifiers or, in my opinion even better, different Maven projects.
> This
> >> have been discussed several times on this list about a month ago or so.
> >>
> >>  And should be in the "Best Practices" section of the documentation so
> > that people know that this is settled law.
>
>
> I need something that supports parallel releases.  We have 3 QA
> environments, 1 or more of which can have a release that is being tested to
> go into production.  So for example: QA1 would have v3.0 currently under
> test with a scheduled release date in september, and then QA2 would have
> v3.1 under test with a scheduled release date in November.  Currently each
> environment has a properties fie containing environment specific values and
> the build.  So based on the target environment for a given build, the
> appropiate properties file is used for filtering.  While this doesnt seem
> to
> fit well with the maven way - it works for us.
>
> What would you suggest as an alternative?
>

Re: profile activation confusion

Posted by Jon Paynter <ki...@gmail.com>.
On Wed, Oct 27, 2010 at 5:51 AM, Jörg Schaible <jo...@gmx.de>wrote:

> Anders Hammar wrote:
>
> > You need Maven 3.0 to be able to activate profiles in the pom by
> > properties set in a profile in settings.xml.
>
> The point is that this functionality is superfluous. If you want a profile
> be activated based on properties in settings.xml, you may as well simply
> add
>  it there to your activeProfiles section. Works also for M2.

im using maven 3.0.  I ended up defining a property inside an already
alwaysActive profile in the settings.xml.  Rather a kludge - but it works.


On Wed, Oct 27, 2010 at 5:44 AM, Ron Wheeler <rwheeler@artifact-software.com
> wrote:

> On 27/10/2010 1:51 AM, Anders Hammar wrote:
>
>> While on the topic, I'd like to mention that having a different build
>> (through profiles for example) for each environment is not good. In Maven,
>> there can only be one flavor of a released artifact. So if you build v1.0
>> of
>> your war, cannot rebuild it with a different content.
>>
>> What you should do is build different artifacts for each environment. Use
>> classifiers or, in my opinion even better, different Maven projects. This
>> have been discussed several times on this list about a month ago or so.
>>
>>  And should be in the "Best Practices" section of the documentation so
> that people know that this is settled law.


I need something that supports parallel releases.  We have 3 QA
environments, 1 or more of which can have a release that is being tested to
go into production.  So for example: QA1 would have v3.0 currently under
test with a scheduled release date in september, and then QA2 would have
v3.1 under test with a scheduled release date in November.  Currently each
environment has a properties fie containing environment specific values and
the build.  So based on the target environment for a given build, the
appropiate properties file is used for filtering.  While this doesnt seem to
fit well with the maven way - it works for us.

What would you suggest as an alternative?

Re: profile activation confusion

Posted by Ron Wheeler <rw...@artifact-software.com>.
On 27/10/2010 1:51 AM, Anders Hammar wrote:
> While on the topic, I'd like to mention that having a different build
> (through profiles for example) for each environment is not good. In Maven,
> there can only be one flavor of a released artifact. So if you build v1.0 of
> your war, cannot rebuild it with a different content.
>
> What you should do is build different artifacts for each environment. Use
> classifiers or, in my opinion even better, different Maven projects. This
> have been discussed several times on this list about a month ago or so.
>
And should be in the "Best Practices" section of the documentation so 
that people know that this is settled law.
> /Anders
> On Tue, Oct 26, 2010 at 23:42, Jon Paynter<ki...@gmail.com>  wrote:
>
>> Im trying to setup some build profiles for our various build environments
>> (dev, qa, prod, etc).  but I cant get the 'dev' profile to be active. The
>> envType property is set to a default value of 'dev' in my top level pom,
>> but
>> it will sometimes be given on the command line, and in that case, activate
>> the appropiate profile for qa, or production.  The problem is I cant get
>> the
>> dev profile to activate by just setting property values inside my pom.
>>
>> Fragment from my pom:
>> <properties>
>>     <envType>dev</envType>
>>     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>>
>> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
>>     <fwVersion>SFP401</fwVersion>
>> </properties>
>>
>> and then the profiles:
>> <profile>
>>     <id>dev</id>
>>     <activation>
>>       <property>
>>         <name>envType</name>
>>         <value>dev</value>
>>     </property>
>>     </activation>
>>
>> based on the documentation I would think the dev profile would be active
>> all
>> the time.  but when I run 'mvn help:active-profiles'  I see:
>> Active Profiles for Project 'myCompoany:app:pom:2.1':
>>
>> The following profiles are active:
>>
>> - nexus (source: settings.xml)
>>
>> however if I run:  'mvn help:active-profiles -DenvType=dev'  then I see:
>> Active Profiles for Project 'myCompany:app:pom:2.1':
>>
>> The following profiles are active:
>>
>> - nexus (source: settings.xml)
>>   - dev (source: settings.xml)
>>
>>
>> what am I missing here?
>>


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


Re: profile activation confusion

Posted by Anders Hammar <an...@hammar.net>.
While on the topic, I'd like to mention that having a different build
(through profiles for example) for each environment is not good. In Maven,
there can only be one flavor of a released artifact. So if you build v1.0 of
your war, cannot rebuild it with a different content.

What you should do is build different artifacts for each environment. Use
classifiers or, in my opinion even better, different Maven projects. This
have been discussed several times on this list about a month ago or so.

/Anders
On Tue, Oct 26, 2010 at 23:42, Jon Paynter <ki...@gmail.com> wrote:

> Im trying to setup some build profiles for our various build environments
> (dev, qa, prod, etc).  but I cant get the 'dev' profile to be active. The
> envType property is set to a default value of 'dev' in my top level pom,
> but
> it will sometimes be given on the command line, and in that case, activate
> the appropiate profile for qa, or production.  The problem is I cant get
> the
> dev profile to activate by just setting property values inside my pom.
>
> Fragment from my pom:
> <properties>
>    <envType>dev</envType>
>    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>
> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
>    <fwVersion>SFP401</fwVersion>
> </properties>
>
> and then the profiles:
> <profile>
>    <id>dev</id>
>    <activation>
>      <property>
>        <name>envType</name>
>        <value>dev</value>
>    </property>
>    </activation>
>
> based on the documentation I would think the dev profile would be active
> all
> the time.  but when I run 'mvn help:active-profiles'  I see:
> Active Profiles for Project 'myCompoany:app:pom:2.1':
>
> The following profiles are active:
>
> - nexus (source: settings.xml)
>
> however if I run:  'mvn help:active-profiles -DenvType=dev'  then I see:
> Active Profiles for Project 'myCompany:app:pom:2.1':
>
> The following profiles are active:
>
> - nexus (source: settings.xml)
>  - dev (source: settings.xml)
>
>
> what am I missing here?
>

Re: profile activation confusion

Posted by Jörg Schaible <jo...@gmx.de>.
Anders Hammar wrote:

> You need Maven 3.0 to be able to activate profiles in the pom by
> properties set in a profile in settings.xml.

The point is that this functionality is superfluous. If you want a profile 
be activated based on properties in settings.xml, you may as well simply add 
it there to your activeProfiles section. Works also for M2.

- Jörg

> 
> /Anders
> 
> On Wed, Oct 27, 2010 at 01:44, Jörg Schaible <jo...@gmx.de>
> wrote:
> 
>> Jon Paynter wrote:
>>
>> > On Tue, Oct 26, 2010 at 4:12 PM, Jörg Schaible
>> > <jo...@gmx.de>wrote:
>> >
>> >> Hi Jon,
>> >>
>> >>
>> >> > what am I missing here?
>> >>
>> >> It does simply not work this way. You cannot activate a profile by a
>> >> property defined in the current or parent POM. Profiles are resolved
>> >> first to build the final POM in use. See help:effective-pom.
>> >>
>> >> - Jörg
>> >>
>> >> Well that explains the source of my confusion.  I'll just find another
>> >> way
>> > to accomplish the same thing.
>>
>> You can set system properties calling Maven or define properties in your
>> settings.xml (IIRC). Those are respected for the profile activation.
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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: profile activation confusion

Posted by Anders Hammar <an...@hammar.net>.
You need Maven 3.0 to be able to activate profiles in the pom by properties
set in a profile in settings.xml.

/Anders

On Wed, Oct 27, 2010 at 01:44, Jörg Schaible <jo...@gmx.de> wrote:

> Jon Paynter wrote:
>
> > On Tue, Oct 26, 2010 at 4:12 PM, Jörg Schaible
> > <jo...@gmx.de>wrote:
> >
> >> Hi Jon,
> >>
> >>
> >> > what am I missing here?
> >>
> >> It does simply not work this way. You cannot activate a profile by a
> >> property defined in the current or parent POM. Profiles are resolved
> >> first to build the final POM in use. See help:effective-pom.
> >>
> >> - Jörg
> >>
> >> Well that explains the source of my confusion.  I'll just find another
> >> way
> > to accomplish the same thing.
>
> You can set system properties calling Maven or define properties in your
> settings.xml (IIRC). Those are respected for the profile activation.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: profile activation confusion

Posted by Jörg Schaible <jo...@gmx.de>.
Jon Paynter wrote:

> On Tue, Oct 26, 2010 at 4:12 PM, Jörg Schaible
> <jo...@gmx.de>wrote:
> 
>> Hi Jon,
>>
>>
>> > what am I missing here?
>>
>> It does simply not work this way. You cannot activate a profile by a
>> property defined in the current or parent POM. Profiles are resolved
>> first to build the final POM in use. See help:effective-pom.
>>
>> - Jörg
>>
>> Well that explains the source of my confusion.  I'll just find another
>> way
> to accomplish the same thing.

You can set system properties calling Maven or define properties in your 
settings.xml (IIRC). Those are respected for the profile activation.



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


Re: profile activation confusion

Posted by Jon Paynter <ki...@gmail.com>.
On Tue, Oct 26, 2010 at 4:12 PM, Jörg Schaible <jo...@gmx.de>wrote:

> Hi Jon,
>
>
> > what am I missing here?
>
> It does simply not work this way. You cannot activate a profile by a
> property defined in the current or parent POM. Profiles are resolved first
> to build the final POM in use. See help:effective-pom.
>
> - Jörg
>
> Well that explains the source of my confusion.  I'll just find another way
to accomplish the same thing.

Re: profile activation confusion

Posted by Jörg Schaible <jo...@gmx.de>.
Hi Jon,

Jon Paynter wrote:

> Im trying to setup some build profiles for our various build environments
> (dev, qa, prod, etc).  but I cant get the 'dev' profile to be active. The
> envType property is set to a default value of 'dev' in my top level pom,
> but it will sometimes be given on the command line, and in that case,
> activate
> the appropiate profile for qa, or production.  The problem is I cant get
> the dev profile to activate by just setting property values inside my pom.
> 
> Fragment from my pom:
> <properties>
>     <envType>dev</envType>
>     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> 
> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
>     <fwVersion>SFP401</fwVersion>
> </properties>
> 
> and then the profiles:
> <profile>
>     <id>dev</id>
>     <activation>
>       <property>
>         <name>envType</name>
>         <value>dev</value>
>     </property>
>     </activation>
> 
> based on the documentation I would think the dev profile would be active
> all
> the time.  but when I run 'mvn help:active-profiles'  I see:
> Active Profiles for Project 'myCompoany:app:pom:2.1':
> 
> The following profiles are active:
> 
> - nexus (source: settings.xml)
> 
> however if I run:  'mvn help:active-profiles -DenvType=dev'  then I see:
> Active Profiles for Project 'myCompany:app:pom:2.1':
> 
> The following profiles are active:
> 
> - nexus (source: settings.xml)
>  - dev (source: settings.xml)
> 
> 
> what am I missing here?

It does simply not work this way. You cannot activate a profile by a 
property defined in the current or parent POM. Profiles are resolved first 
to build the final POM in use. See help:effective-pom.

- Jörg



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