List buildPlugins = project.getBuildPlugins();
if ( buildPlugins != null )
{
for ( Iterator j = buildPlugins.iterator(); j.hasNext(); )
{
Plugin plugin = (Plugin) j.next();
String pluginId = ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() );
if ( dag.getVertex( pluginId ) != null && !pluginId.equals( id ) )
{
addEdgeWithParentCheck( projectMap, pluginId, project, id );
}
if ( !pluginId.equals( id ) ) {
for ( Iterator k = plugin.getDependencies().iterator(); k.hasNext(); )
{
Dependency dependency = (Dependency) k.next();
String dependencyId = ArtifactUtils
.versionlessKey( dependency.getGroupId(), dependency.getArtifactId() );
if ( dag.getVertex( dependencyId ) != null )
{
// If the plugin in which this dependency is listed is actually used here,
// it will probably be stuck using an older version of this project that
// already exists in the local repository. If not yet installed, it is
// likely that we'll get an ArtifactNotFoundException when this plugin
// is executed to build this project.
//
// If the plugin is NOT actually used here, it may actually belong in the
// pluginManagement section.
if ( !id.equals( dependencyId ) )
{
project.addProjectReference( (MavenProject) projectMap.get( dependencyId ) );
addEdgeWithParentCheck( projectMap, dependencyId, project, id );
// TODO: Shouldn't we add an edge between the plugin and its dependency?
// Note that doing this may result in cycles...run
// ProjectSorterTest.testPluginDependenciesInfluenceSorting_DeclarationInParent()
// for more information, if you change this:
// dag.addEdge( pluginId, dependencyId );
}
}
}
}
}
}
List reportPlugins = project.getReportPlugins();
if ( reportPlugins != null )
{
for ( Iterator j = reportPlugins.iterator(); j.hasNext(); )
{
ReportPlugin plugin = (ReportPlugin) j.next();
String pluginId = ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() );
if ( dag.getVertex( pluginId ) != null && !pluginId.equals( id ) )
{
addEdgeWithParentCheck( projectMap, pluginId, project, id );
}
}