maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rfscho...@apache.org
Subject svn commit: r1481385 - /maven/shared/trunk/maven-project-utils/src/main/java/org/apache/maven/shared/project/utils/ProjectUtils.java
Date Sat, 11 May 2013 17:54:30 GMT
Author: rfscholte
Date: Sat May 11 17:54:29 2013
New Revision: 1481385

URL: http://svn.apache.org/r1481385
Log: (empty)

Modified:
    maven/shared/trunk/maven-project-utils/src/main/java/org/apache/maven/shared/project/utils/ProjectUtils.java

Modified: maven/shared/trunk/maven-project-utils/src/main/java/org/apache/maven/shared/project/utils/ProjectUtils.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-project-utils/src/main/java/org/apache/maven/shared/project/utils/ProjectUtils.java?rev=1481385&r1=1481384&r2=1481385&view=diff
==============================================================================
--- maven/shared/trunk/maven-project-utils/src/main/java/org/apache/maven/shared/project/utils/ProjectUtils.java
(original)
+++ maven/shared/trunk/maven-project-utils/src/main/java/org/apache/maven/shared/project/utils/ProjectUtils.java
Sat May 11 17:54:29 2013
@@ -1,7 +1,11 @@
 package org.apache.maven.shared.project.utils;
 
+import java.util.Collections;
+import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Map;
 
+import org.apache.maven.model.Profile;
 import org.apache.maven.project.MavenProject;
 
 /*
@@ -59,13 +63,11 @@ public final class ProjectUtils
                 }
             }
         }
-        else
+        
+        if ( parent.getModules().size() > 0 )
         {
-            if ( parent.getModules().size() > 0 )
-            {
-                // problem: parent has modules, but they aren't collected (ie not in the
reactor)
-                // can't really tell if current project is root or not
-            }
+            // problem: parent has modules, but they aren't collected (ie not in the reactor)
+            // can't really tell if current project is root or not
         }
 
         // project isn't a module of its parent
@@ -116,4 +118,30 @@ public final class ProjectUtils
         }
         return true;
     }
+    
+    /**
+     * Returns all modules of a project, including does specified in profiles, both active
and inactive.
+     * The key of the returned Map is the name of the module, the value is the source of
the module (the project or a specific profile). 
+     * 
+     * @param project
+     * @return
+     */
+    public static Map<String, String> getAllModules( MavenProject project )
+    {
+        Map<String, String> modules = new LinkedHashMap<String, String>();
+
+        for ( String module : project.getModel().getModules() )
+        {
+            modules.put( module, "project" ); // id?
+        }
+
+        for ( Profile profile : project.getModel().getProfiles() )
+        {
+            for ( String module : profile.getModules() )
+            {
+                modules.put( module, "profile(id:" + profile.getId() + ")" );
+            }
+        }
+        return Collections.unmodifiableMap( modules );
+    }
 }



Mime
View raw message