Hi Rafael,

Rafael Vanderlei wrote:

[snip]

> Now that you know the problem I had with M2Eclipse, it comes the issue I´m
> having with Maven itself, that occurred when I tried a solution to that
> problem with M2Eclipse. Maven has lots of ways to activate profiles and so
> I tried to combine 2 of them: specifying the profile on the command line
> and using property. Basically, what I did was:
> 
> 1. On the pom.xml of that module with 30 profiles, I configured activation
> by properties like "name: activate.profile1 / value: true", "name:
> activate.profile2 / value: true" and so on...
> 2. On the major pom.xml, I created a profile (with the option
> "activatedByDefault" set to true) that combines the intern module
> profiles, i.e, I created a "major.profile" which sets the properties
> "activate.profile1=true", "activate.profile5=true",
> "activate.profile10=true", "activate.profile15=true" and so on...
> 
> As the profile is activatedByDefault, I would not need to tell M2Eclipse
> which profile I want to activate (so I would not have any repeated list of
> profiles to configure on all the projects). I was happy with the solution
> (as, in theory, it should work) until I tried to build with it... I
> thought that running on the command line mvn -Pmajor.profile package would
> set all the properties I defined on that profile and on cascade by doing
> so I would activate all the profiles defined on the internal module. But
> it did not work. It seems that Maven activation by properties doesn´t work
> the way I thought.. it seems it works only if you specify the property on
> the command line.

Profiles do simply not work this way. A profile is always "local" to the pom 
where it is defined, profile activation is not inherited i.e. if a profile 
is activated in the parent, the activation is not propagated to the child 
pom, even if it defines a profile with the same name.

Profiles cannot be activated by Maven properties, simply because Maven has 
to activate the proper profiles before it can build the effective pom - 
which defines the properties.

You can activate a profile with a special id globally by activating it in 
the settings.xml, from command line or by using an activation that evauates 
to true before the effective pom is built.

[snip]

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to