mirror of https://github.com/apache/maven.git
Use for each
This commit is contained in:
parent
3480789f18
commit
71f73b29fa
|
@ -20,6 +20,7 @@ package org.apache.maven.project.inheritance;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
@ -372,18 +373,16 @@ public class DefaultModelInheritanceAssembler
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List parentPlugins = parent.getPlugins();
|
List<ReportPlugin> parentPlugins = parent.getPlugins();
|
||||||
|
|
||||||
if ( ( parentPlugins != null ) && !parentPlugins.isEmpty() )
|
if ( ( parentPlugins != null ) && !parentPlugins.isEmpty() )
|
||||||
{
|
{
|
||||||
Map assembledPlugins = new TreeMap();
|
Map<String, ReportPlugin> assembledPlugins = new TreeMap<String, ReportPlugin>();
|
||||||
|
|
||||||
Map childPlugins = child.getReportPluginsAsMap();
|
Map<String, ReportPlugin> childPlugins = child.getReportPluginsAsMap();
|
||||||
|
|
||||||
for ( Object parentPlugin1 : parentPlugins )
|
for ( ReportPlugin parentPlugin : parentPlugins )
|
||||||
{
|
{
|
||||||
ReportPlugin parentPlugin = (ReportPlugin) parentPlugin1;
|
|
||||||
|
|
||||||
String parentInherited = parentPlugin.getInherited();
|
String parentInherited = parentPlugin.getInherited();
|
||||||
|
|
||||||
if ( !handleAsInheritance || ( parentInherited == null ) || Boolean.valueOf( parentInherited ) )
|
if ( !handleAsInheritance || ( parentInherited == null ) || Boolean.valueOf( parentInherited ) )
|
||||||
|
@ -391,7 +390,7 @@ public class DefaultModelInheritanceAssembler
|
||||||
|
|
||||||
ReportPlugin assembledPlugin = parentPlugin;
|
ReportPlugin assembledPlugin = parentPlugin;
|
||||||
|
|
||||||
ReportPlugin childPlugin = (ReportPlugin) childPlugins.get( parentPlugin.getKey() );
|
ReportPlugin childPlugin = childPlugins.get( parentPlugin.getKey() );
|
||||||
|
|
||||||
if ( childPlugin != null )
|
if ( childPlugin != null )
|
||||||
{
|
{
|
||||||
|
@ -409,17 +408,15 @@ public class DefaultModelInheritanceAssembler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( Iterator it = childPlugins.values().iterator(); it.hasNext(); )
|
for ( ReportPlugin childPlugin : childPlugins.values() )
|
||||||
{
|
{
|
||||||
ReportPlugin childPlugin = (ReportPlugin) it.next();
|
|
||||||
|
|
||||||
if ( !assembledPlugins.containsKey( childPlugin.getKey() ) )
|
if ( !assembledPlugins.containsKey( childPlugin.getKey() ) )
|
||||||
{
|
{
|
||||||
assembledPlugins.put( childPlugin.getKey(), childPlugin );
|
assembledPlugins.put( childPlugin.getKey(), childPlugin );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
child.setPlugins( new ArrayList( assembledPlugins.values() ) );
|
child.setPlugins( new ArrayList<ReportPlugin>( assembledPlugins.values() ) );
|
||||||
|
|
||||||
child.flushReportPluginMap();
|
child.flushReportPluginMap();
|
||||||
}
|
}
|
||||||
|
@ -427,10 +424,10 @@ public class DefaultModelInheritanceAssembler
|
||||||
|
|
||||||
private static void mergeReportSetDefinitions( ReportSet child, ReportSet parent )
|
private static void mergeReportSetDefinitions( ReportSet child, ReportSet parent )
|
||||||
{
|
{
|
||||||
List parentReports = parent.getReports();
|
List<String> parentReports = parent.getReports();
|
||||||
List childReports = child.getReports();
|
List<String> childReports = child.getReports();
|
||||||
|
|
||||||
List reports = new ArrayList();
|
List<String> reports = new ArrayList<String>();
|
||||||
|
|
||||||
if ( ( childReports != null ) && !childReports.isEmpty() )
|
if ( ( childReports != null ) && !childReports.isEmpty() )
|
||||||
{
|
{
|
||||||
|
@ -439,10 +436,8 @@ public class DefaultModelInheritanceAssembler
|
||||||
|
|
||||||
if ( parentReports != null )
|
if ( parentReports != null )
|
||||||
{
|
{
|
||||||
for ( Iterator i = parentReports.iterator(); i.hasNext(); )
|
for ( String report : parentReports )
|
||||||
{
|
{
|
||||||
String report = (String) i.next();
|
|
||||||
|
|
||||||
if ( !reports.contains( report ) )
|
if ( !reports.contains( report ) )
|
||||||
{
|
{
|
||||||
reports.add( report );
|
reports.add( report );
|
||||||
|
@ -480,23 +475,23 @@ public class DefaultModelInheritanceAssembler
|
||||||
|
|
||||||
boolean parentIsInherited = ( parentInherited == null ) || Boolean.valueOf( parentInherited );
|
boolean parentIsInherited = ( parentInherited == null ) || Boolean.valueOf( parentInherited );
|
||||||
|
|
||||||
List parentReportSets = parent.getReportSets();
|
List<ReportSet> parentReportSets = parent.getReportSets();
|
||||||
|
|
||||||
if ( ( parentReportSets != null ) && !parentReportSets.isEmpty() )
|
if ( ( parentReportSets != null ) && !parentReportSets.isEmpty() )
|
||||||
{
|
{
|
||||||
Map assembledReportSets = new TreeMap();
|
Map<String, ReportSet> assembledReportSets = new TreeMap<String, ReportSet>();
|
||||||
|
|
||||||
Map childReportSets = child.getReportSetsAsMap();
|
Map<String, ReportSet> childReportSets = child.getReportSetsAsMap();
|
||||||
|
|
||||||
for ( Iterator it = parentReportSets.iterator(); it.hasNext(); )
|
for ( Object parentReportSet1 : parentReportSets )
|
||||||
{
|
{
|
||||||
ReportSet parentReportSet = (ReportSet) it.next();
|
ReportSet parentReportSet = (ReportSet) parentReportSet1;
|
||||||
|
|
||||||
if ( !handleAsInheritance || parentIsInherited )
|
if ( !handleAsInheritance || parentIsInherited )
|
||||||
{
|
{
|
||||||
ReportSet assembledReportSet = parentReportSet;
|
ReportSet assembledReportSet = parentReportSet;
|
||||||
|
|
||||||
ReportSet childReportSet = (ReportSet) childReportSets.get( parentReportSet.getId() );
|
ReportSet childReportSet = childReportSets.get( parentReportSet.getId() );
|
||||||
|
|
||||||
if ( childReportSet != null )
|
if ( childReportSet != null )
|
||||||
{
|
{
|
||||||
|
@ -513,11 +508,9 @@ public class DefaultModelInheritanceAssembler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( Iterator it = childReportSets.entrySet().iterator(); it.hasNext(); )
|
for ( Map.Entry<String, ReportSet> entry : childReportSets.entrySet() )
|
||||||
{
|
{
|
||||||
Map.Entry entry = (Map.Entry) it.next();
|
String id = entry.getKey();
|
||||||
|
|
||||||
String id = (String) entry.getKey();
|
|
||||||
|
|
||||||
if ( !assembledReportSets.containsKey( id ) )
|
if ( !assembledReportSets.containsKey( id ) )
|
||||||
{
|
{
|
||||||
|
@ -525,7 +518,7 @@ public class DefaultModelInheritanceAssembler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
child.setReportSets( new ArrayList( assembledReportSets.values() ) );
|
child.setReportSets( new ArrayList<ReportSet>( assembledReportSets.values() ) );
|
||||||
|
|
||||||
child.flushReportSetMap();
|
child.flushReportSetMap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,16 +78,16 @@ public class DefaultArtifactResolverTest
|
||||||
|
|
||||||
boolean seen = false;
|
boolean seen = false;
|
||||||
|
|
||||||
for ( int i = 0; i < tgList.length; i++ )
|
for ( ThreadGroup aTgList : tgList )
|
||||||
{
|
{
|
||||||
if ( !tgList[i].getName().equals( DaemonThreadCreator.THREADGROUP_NAME ) )
|
if ( !aTgList.getName().equals( DaemonThreadCreator.THREADGROUP_NAME ) )
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
seen = true;
|
seen = true;
|
||||||
|
|
||||||
tg = tgList[i];
|
tg = aTgList;
|
||||||
Thread[] ts = new Thread[tg.activeCount()];
|
Thread[] ts = new Thread[tg.activeCount()];
|
||||||
tg.enumerate( ts );
|
tg.enumerate( ts );
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ public class ProjectInheritanceTest
|
||||||
assertEquals( "4.0.0", project4.getModelVersion() );
|
assertEquals( "4.0.0", project4.getModelVersion() );
|
||||||
|
|
||||||
Build build = project4.getBuild();
|
Build build = project4.getBuild();
|
||||||
List plugins = build.getPlugins();
|
List<Plugin> plugins = build.getPlugins();
|
||||||
|
|
||||||
Map validPluginCounts = new HashMap();
|
Map validPluginCounts = new HashMap();
|
||||||
|
|
||||||
|
@ -131,13 +131,11 @@ public class ProjectInheritanceTest
|
||||||
validPluginCounts.put( "maven-source-plugin", 0 );
|
validPluginCounts.put( "maven-source-plugin", 0 );
|
||||||
|
|
||||||
Plugin testPlugin = null;
|
Plugin testPlugin = null;
|
||||||
|
|
||||||
for ( Iterator it = plugins.iterator(); it.hasNext(); )
|
for ( Plugin plugin : plugins )
|
||||||
{
|
{
|
||||||
Plugin plugin = (Plugin) it.next();
|
|
||||||
|
|
||||||
String pluginArtifactId = plugin.getArtifactId();
|
String pluginArtifactId = plugin.getArtifactId();
|
||||||
|
|
||||||
if ( !validPluginCounts.containsKey( pluginArtifactId ) )
|
if ( !validPluginCounts.containsKey( pluginArtifactId ) )
|
||||||
{
|
{
|
||||||
fail( "Illegal plugin found: " + pluginArtifactId );
|
fail( "Illegal plugin found: " + pluginArtifactId );
|
||||||
|
@ -148,9 +146,9 @@ public class ProjectInheritanceTest
|
||||||
{
|
{
|
||||||
testPlugin = plugin;
|
testPlugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer count = (Integer) validPluginCounts.get( pluginArtifactId );
|
Integer count = (Integer) validPluginCounts.get( pluginArtifactId );
|
||||||
|
|
||||||
if ( count.intValue() > 0 )
|
if ( count.intValue() > 0 )
|
||||||
{
|
{
|
||||||
fail( "Multiple copies of plugin: " + pluginArtifactId + " found in POM." );
|
fail( "Multiple copies of plugin: " + pluginArtifactId + " found in POM." );
|
||||||
|
@ -158,7 +156,7 @@ public class ProjectInheritanceTest
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
count = count.intValue() + 1;
|
count = count.intValue() + 1;
|
||||||
|
|
||||||
validPluginCounts.put( pluginArtifactId, count );
|
validPluginCounts.put( pluginArtifactId, count );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue