Author: dennisl
Date: Sun Nov 11 15:39:58 2007
New Revision: 593993

URL: http://svn.apache.org/viewvc?rev=593993&view=rev
Log:
[MPH-16] help:active-profiles doesn't include profiles derived from the parent 
pom.
Submitted by: David Boden
Reviewed by: Dennis Lundberg

Modified:
    
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/ActiveProfilesMojo.java

Modified: 
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/ActiveProfilesMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/ActiveProfilesMojo.java?rev=593993&r1=593992&r2=593993&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/ActiveProfilesMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/ActiveProfilesMojo.java
 Sun Nov 11 15:39:58 2007
@@ -143,7 +143,7 @@
      */
     private void getActiveProfileStatement( MavenProject project, StringBuffer 
message )
     {
-        List profiles = project.getActiveProfiles();
+        List profiles = collectActiveProfiles( project );
         
         message.append( "\n" );
         
@@ -170,6 +170,25 @@
         }
         
         message.append( "\n" );
+    }
+
+    /**
+     * Recurses into the project's parent poms to find the active
+     * profiles of the specified project and all its parents.
+     *
+     * @param project The project to start with
+     * @return A list of active profiles
+     */
+    private List collectActiveProfiles( MavenProject project )
+    {
+        List profiles = project.getActiveProfiles();
+
+        if ( project.hasParent() )
+        {
+            profiles.addAll( collectActiveProfiles( project.getParent() ) );
+        }
+
+        return profiles;
     }
 
     /**


Reply via email to