Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Cannot Reproduce
-
Affects Version/s: 2.0.7
-
Fix Version/s: 2.1.0
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
The goal is to activate a maven profile based on OS user name.
When I create a standalone project with a profile activation, it works,
however, when I define the profile in a "parent" pom, it is never activated.
this works:
...
<profile>
<id>TONY</id>
<activation>
<property>
<name>user.name</name>
<value>WINTONY</value>
</property>
</activation>
<properties>
</properties>
So in this case, my profile is activated based on my OS user name
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'help'.
[INFO] ----------------------------------------------------------------------------
[INFO] Building Proj1
[INFO] task-segment: [help:active-profiles] (aggregator-style)
[INFO] ----------------------------------------------------------------------------
[INFO] [help:active-profiles]
[INFO]
Active Profiles for Project 'com.capgemini.be.proj1:parent:pom:4.0.2':
The following profiles are active:
- TONY (source: pom)
------------------
However, if I now have the profiles definition in the "parent" pom, it doesn't work when I build a child project
So the child project references the parent pom containing the profiles and the activation, but when it is built,
the profile is not activated
PARENT POM:
...
<profiles>
<profile>
<id>TONY</id>
<activation>
<property>
<name>user.name</name>
<value>WINTONY</value>
</property>
</activation>
<properties>
...
CHILD POM (the one being built)
<project>
<parent>
<groupId>com.capgemini.be.proj1</groupId>
<artifactId>parent</artifactId>
<version>4.0.2</version>
</parent>
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'help'.
[INFO] ----------------------------------------------------------------------------
[INFO] Building Proj1 Application
[INFO] task-segment: [help:active-profiles] (aggregator-style)
[INFO] ----------------------------------------------------------------------------
[INFO] [help:active-profiles]
[INFO]
Active Profiles for Project 'com.capgemini.be.proj1:proj1-webapp:jar:4.0.2':
There are no active profiles.
I fear "this behavior is by design". According to John Casey's post at http://www.nabble.com/Profile-inheritance-tf2953156s177.html#a8260582 and some docs at http://docs.codehaus.org/display/MAVEN/Build+Profiles, profiles by themselves are not inherited at all but only their effects after being applied to the POM. Now, when a profile is not inherited, its activation is not inherited, neither.
Nevertheless, I would consider profile inheritance useful, too. To name a further use-case, imagine one wants to overwrite certain aspects of a profile for a module POM that inherits from a parent POM. For example, slightly change a plugin configuration that is inherited when the profile is activated. Currently, one needs to redefine the <activation> element in the module POM for such a thing to work. But as we all know, copy&paste is bad.