[ 
https://jira.codehaus.org/browse/MNG-5127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=304841#comment-304841
 ] 

Tony Lampada commented on MNG-5127:
-----------------------------------

Hi, 
I have attached a test case for this issue - 
[daddy.zip|http://jira.codehaus.org/secure/attachment/60738/daddy.zip]

The parent pom in this project defines 3 profiles with different plugin 
configurations: "kid", "boy" and "girl".

The 3 children want to enable different profiles:
- A kid is a kid
- A boy is a boy and a kid
- A girl is a girl and a kid

When I run "mvn help:active-profiles" I get the false hope that maven 
understands what I mean:

{code}
        Active Profiles for Project 'com.family:daddy:pom:1.0-SNAPSHOT': 
        There are no active profiles.

        Active Profiles for Project 'com.family:kid:pom:1.0-SNAPSHOT': 
        The following profiles are active:
         - kid (source: pom)

        Active Profiles for Project 'com.family:boy:pom:1.0-SNAPSHOT': 
        The following profiles are active:
         - boy (source: pom)
         - kid (source: pom)

        Active Profiles for Project 'com.family:girl:pom:1.0-SNAPSHOT': 
        The following profiles are active:
         - kid (source: pom)
         - girl (source: pom)
{code}

That is: boys will be boys, girls will be girls, and both will be kids.

But when I run "mvn validate" no messages are echoed.

{code}
        [INFO] 
------------------------------------------------------------------------
        [INFO] Building daddy 1.0-SNAPSHOT
        [INFO] 
------------------------------------------------------------------------
        [INFO]                                                                  
       
        [INFO] 
------------------------------------------------------------------------
        [INFO] Building kid 1.0-SNAPSHOT
        [INFO] 
------------------------------------------------------------------------
        [INFO]                                                                  
       
        [INFO] 
------------------------------------------------------------------------
        [INFO] Building boy 1.0-SNAPSHOT
        [INFO] 
------------------------------------------------------------------------
        [INFO]                                                                  
       
        [INFO] 
------------------------------------------------------------------------
        [INFO] Building girl 1.0-SNAPSHOT
        [INFO] 
------------------------------------------------------------------------
        [INFO] 
------------------------------------------------------------------------
        [INFO] Reactor Summary:
        [INFO] 
        [INFO] daddy ............................................. SUCCESS 
[0.001s]
        [INFO] kid ............................................... SUCCESS 
[0.001s]
        [INFO] boy ............................................... SUCCESS 
[0.000s]
        [INFO] girl .............................................. SUCCESS 
[0.000s]
        [INFO] 
------------------------------------------------------------------------
        [INFO] BUILD SUCCESS
{code}

The only way I can get any of those profiles to run is using -P on the command 
line, like "mvn validate -Pgirl"
But that would transform boys into girls and we don't want that:

{code}
        [INFO] 
------------------------------------------------------------------------
        [INFO] Building daddy 1.0-SNAPSHOT
        [INFO] 
------------------------------------------------------------------------
        [INFO] 
        [INFO] --- maven-antrun-plugin:1.7:run (default) @ daddy ---
        [INFO] Executing tasks

        main:
             [echo] @@@@@@@@@@@@ HELLO! Iam a GIRL project
        [INFO] Executed tasks
        [INFO]                                                                  
       
        [INFO] 
------------------------------------------------------------------------
        [INFO] Building kid 1.0-SNAPSHOT
        [INFO] 
------------------------------------------------------------------------
        [INFO] 
        [INFO] --- maven-antrun-plugin:1.7:run (default) @ kid ---
        [INFO] Executing tasks

        main:
             [echo] @@@@@@@@@@@@ HELLO! Iam a GIRL project
        [INFO] Executed tasks
        [INFO]                                                                  
       
        [INFO] 
------------------------------------------------------------------------
        [INFO] Building boy 1.0-SNAPSHOT
        [INFO] 
------------------------------------------------------------------------
        [INFO] 
        [INFO] --- maven-antrun-plugin:1.7:run (default) @ boy ---
        [INFO] Executing tasks

        main:
             [echo] @@@@@@@@@@@@ HELLO! Iam a GIRL project
        [INFO] Executed tasks
        [INFO]                                                                  
       
        [INFO] 
------------------------------------------------------------------------
        [INFO] Building girl 1.0-SNAPSHOT
        [INFO] 
------------------------------------------------------------------------
        [INFO] 
        [INFO] --- maven-antrun-plugin:1.7:run (default) @ girl ---
        [INFO] Executing tasks

        main:
             [echo] @@@@@@@@@@@@ HELLO! Iam a GIRL project
        [INFO] Executed tasks
        [INFO] 
------------------------------------------------------------------------
        [INFO] Reactor Summary:
        [INFO] 
        [INFO] daddy ............................................. SUCCESS 
[0.682s]
        [INFO] kid ............................................... SUCCESS 
[0.112s]
        [INFO] boy ............................................... SUCCESS 
[0.099s]
        [INFO] girl .............................................. SUCCESS 
[0.090s]
        [INFO] 
------------------------------------------------------------------------
        [INFO] BUILD SUCCESS
{code}

I think the requirement here is to be able to:
 - Define only once, what is a boy, what is a girl, and what is a kid.
 - Apply those "labels" to modules and make them *stick*, so that there's no 
need to use command line parameters.

It seems to me that this should be the main goal of maven profiles.
This unimplemented feature really gets in the way of good, DRY configuration 
and build management for big modular projects.

                
> CLONE - Maven profile activation does not work when profile is defined in 
> inherited 'parent' pom
> ------------------------------------------------------------------------------------------------
>
>                 Key: MNG-5127
>                 URL: https://jira.codehaus.org/browse/MNG-5127
>             Project: Maven 2 & 3
>          Issue Type: Bug
>            Reporter: Gilles Scokart
>            Assignee: John Casey
>         Attachments: daddy.zip
>
>
> 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. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to