PR: MNG-326

take plugins, reports and extensions into account when sorting modules for reactor build

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@225717 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-07-28 06:52:04 +00:00
parent 6ab4f5ac99
commit 85b30cf43d
1 changed files with 50 additions and 0 deletions

View File

@ -17,6 +17,8 @@ package org.apache.maven.project;
*/
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Extension;
import org.apache.maven.model.Plugin;
import org.codehaus.plexus.util.dag.CycleDetectedException;
import org.codehaus.plexus.util.dag.DAG;
import org.codehaus.plexus.util.dag.TopologicalSorter;
@ -96,6 +98,44 @@ public class ProjectSorter
dag.addEdge( id, parentId );
}
}
List buildPlugins = project.getBuildPlugins();
if ( buildPlugins != null )
{
for ( Iterator j = buildPlugins.iterator(); j.hasNext(); )
{
Plugin plugin = (Plugin) j.next();
String pluginId = getPluginId( plugin );
if ( dag.getVertex( pluginId ) != null )
{
dag.addEdge( id, pluginId );
}
}
}
List reportPlugins = project.getReportPlugins();
if ( reportPlugins != null )
{
for ( Iterator j = reportPlugins.iterator(); j.hasNext(); )
{
Plugin plugin = (Plugin) j.next();
String pluginId = getPluginId( plugin );
if ( dag.getVertex( pluginId ) != null )
{
dag.addEdge( id, pluginId );
}
}
}
for ( Iterator j = project.getBuildExtensions().iterator(); j.hasNext(); )
{
Extension extension = (Extension) j.next();
String extensionId = getExtensionId( extension );
if ( dag.getVertex( extensionId ) != null )
{
dag.addEdge( id, extensionId );
}
}
}
List sortedProjects = new ArrayList();
@ -110,6 +150,16 @@ public class ProjectSorter
return sortedProjects;
}
private static String getExtensionId( Extension extension )
{
return extension.getGroupId() + ":" + extension.getArtifactId();
}
private static String getPluginId( Plugin plugin )
{
return plugin.getGroupId() + ":" + plugin.getArtifactId();
}
private static String getDependencyId( Dependency dependency )
{
return dependency.getGroupId() + ":" + dependency.getArtifactId();