diff --git a/maven-compat/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java b/maven-compat/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java index 740c2cd93a..bfade80b94 100644 --- a/maven-compat/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java +++ b/maven-compat/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java @@ -141,9 +141,9 @@ public class DefaultProfileManager */ public void explicitlyActivate( List profileIds ) { - for ( Iterator it = profileIds.iterator(); it.hasNext(); ) + for ( Object profileId1 : profileIds ) { - String profileId = (String) it.next(); + String profileId = (String) profileId1; explicitlyActivate( profileId ); } @@ -167,9 +167,9 @@ public class DefaultProfileManager */ public void explicitlyDeactivate( List profileIds ) { - for ( Iterator it = profileIds.iterator(); it.hasNext(); ) + for ( Object profileId1 : profileIds ) { - String profileId = (String) it.next(); + String profileId = (String) profileId1; explicitlyDeactivate( profileId ); } @@ -215,9 +215,9 @@ public class DefaultProfileManager */ public void addProfiles( List profiles ) { - for ( Iterator it = profiles.iterator(); it.hasNext(); ) + for ( Object profile1 : profiles ) { - Profile profile = (Profile) it.next(); + Profile profile = (Profile) profile1; addProfile( profile ); } diff --git a/maven-compat/src/main/java/org/apache/maven/profiles/ProfilesConversionUtils.java b/maven-compat/src/main/java/org/apache/maven/profiles/ProfilesConversionUtils.java index 8abe1de58b..041a9bb446 100644 --- a/maven-compat/src/main/java/org/apache/maven/profiles/ProfilesConversionUtils.java +++ b/maven-compat/src/main/java/org/apache/maven/profiles/ProfilesConversionUtils.java @@ -100,21 +100,19 @@ public class ProfilesConversionUtils List repos = profileXmlProfile.getRepositories(); if ( repos != null ) { - for ( Iterator it = repos.iterator(); it.hasNext(); ) + for ( Object repo : repos ) { - profile - .addRepository( - convertFromProfileXmlRepository( (org.apache.maven.profiles.Repository) it.next() ) ); + profile.addRepository( convertFromProfileXmlRepository( (org.apache.maven.profiles.Repository) repo ) ); } } List pluginRepos = profileXmlProfile.getPluginRepositories(); if ( pluginRepos != null ) { - for ( Iterator it = pluginRepos.iterator(); it.hasNext(); ) + for ( Object pluginRepo : pluginRepos ) { - profile.addPluginRepository( convertFromProfileXmlRepository( (org.apache.maven.profiles.Repository) it - .next() ) ); + profile.addPluginRepository( + convertFromProfileXmlRepository( (org.apache.maven.profiles.Repository) pluginRepo ) ); } } diff --git a/maven-compat/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java b/maven-compat/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java index 85f75268e1..ec04f34a43 100644 --- a/maven-compat/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java +++ b/maven-compat/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java @@ -323,15 +323,13 @@ public class DefaultModelInheritanceAssembler List childDeps = childDepMgmt.getDependencies(); Map mappedChildDeps = new TreeMap(); - for ( Iterator it = childDeps.iterator(); it.hasNext(); ) + for ( Dependency dep : childDeps ) { - Dependency dep = it.next(); mappedChildDeps.put( dep.getManagementKey(), dep ); } - for ( Iterator it = parentDepMgmt.getDependencies().iterator(); it.hasNext(); ) + for ( Dependency dep : parentDepMgmt.getDependencies() ) { - Dependency dep = it.next(); if ( !mappedChildDeps.containsKey( dep.getManagementKey() ) ) { childDepMgmt.addDependency( dep ); @@ -382,14 +380,13 @@ public class DefaultModelInheritanceAssembler Map childPlugins = child.getReportPluginsAsMap(); - for ( Iterator it = parentPlugins.iterator(); it.hasNext(); ) + for ( Object parentPlugin1 : parentPlugins ) { - ReportPlugin parentPlugin = (ReportPlugin) it.next(); + ReportPlugin parentPlugin = (ReportPlugin) parentPlugin1; String parentInherited = parentPlugin.getInherited(); - if ( !handleAsInheritance || ( parentInherited == null ) - || Boolean.valueOf( parentInherited ) ) + if ( !handleAsInheritance || ( parentInherited == null ) || Boolean.valueOf( parentInherited ) ) { ReportPlugin assembledPlugin = parentPlugin; diff --git a/maven-compat/src/main/java/org/apache/maven/project/interpolation/StringSearchModelInterpolator.java b/maven-compat/src/main/java/org/apache/maven/project/interpolation/StringSearchModelInterpolator.java index 1ef5579e00..dcb8e2bdce 100644 --- a/maven-compat/src/main/java/org/apache/maven/project/interpolation/StringSearchModelInterpolator.java +++ b/maven-compat/src/main/java/org/apache/maven/project/interpolation/StringSearchModelInterpolator.java @@ -168,33 +168,35 @@ public class StringSearchModelInterpolator fieldsByClass.put( cls, fields ); } - for ( int i = 0; i < fields.length; i++ ) + for ( Field field : fields ) { - Class type = fields[i].getType(); - if ( isQualifiedForInterpolation( fields[i], type ) ) + Class type = field.getType(); + if ( isQualifiedForInterpolation( field, type ) ) { - boolean isAccessible = fields[i].isAccessible(); - fields[i].setAccessible( true ); + boolean isAccessible = field.isAccessible(); + field.setAccessible( true ); try { try { if ( String.class == type ) { - String value = (String) fields[i].get( target ); + String value = (String) field.get( target ); if ( value != null ) { - String interpolated = modelInterpolator.interpolateInternal( value, valueSources, postProcessors, debugEnabled ); + String interpolated = + modelInterpolator.interpolateInternal( value, valueSources, postProcessors, + debugEnabled ); if ( !interpolated.equals( value ) ) { - fields[i].set( target, interpolated ); + field.set( target, interpolated ); } } } else if ( Collection.class.isAssignableFrom( type ) ) { - Collection c = (Collection) fields[i].get( target ); + Collection c = (Collection) field.get( target ); if ( c != null && !c.isEmpty() ) { List originalValues = new ArrayList( c ); @@ -206,8 +208,9 @@ public class StringSearchModelInterpolator { if ( debugEnabled && logger != null ) { - logger.debug( "Skipping interpolation of field: " + fields[i] + " in: " - + cls.getName() + "; it is an unmodifiable collection." ); + logger.debug( "Skipping interpolation of field: " + field + " in: " + + cls.getName() + + "; it is an unmodifiable collection." ); } continue; } @@ -256,7 +259,7 @@ public class StringSearchModelInterpolator } else if ( Map.class.isAssignableFrom( type ) ) { - Map m = (Map) fields[i].get( target ); + Map m = (Map) field.get( target ); if ( m != null && !m.isEmpty() ) { for ( Map.Entry entry : m.entrySet() ) @@ -283,10 +286,11 @@ public class StringSearchModelInterpolator { if ( debugEnabled && logger != null ) { - logger.debug( "Skipping interpolation of field: " - + fields[i] + " (key: " + entry.getKey() + ") in: " - + cls.getName() - + "; it is an unmodifiable collection." ); + logger.debug( + "Skipping interpolation of field: " + field + + " (key: " + entry.getKey() + ") in: " + + cls.getName() + + "; it is an unmodifiable collection." ); } } } @@ -308,10 +312,10 @@ public class StringSearchModelInterpolator } else { - Object value = fields[i].get( target ); + Object value = field.get( target ); if ( value != null ) { - if ( fields[i].getType().isArray() ) + if ( field.getType().isArray() ) { evaluateArray( value ); } @@ -324,18 +328,18 @@ public class StringSearchModelInterpolator } catch ( IllegalArgumentException e ) { - throw new ModelInterpolationException( "Failed to interpolate field: " + fields[i] - + " on class: " + cls.getName(), e ); + throw new ModelInterpolationException( + "Failed to interpolate field: " + field + " on class: " + cls.getName(), e ); } catch ( IllegalAccessException e ) { - throw new ModelInterpolationException( "Failed to interpolate field: " + fields[i] - + " on class: " + cls.getName(), e ); + throw new ModelInterpolationException( + "Failed to interpolate field: " + field + " on class: " + cls.getName(), e ); } } finally { - fields[i].setAccessible( isAccessible ); + field.setAccessible( isAccessible ); } } } diff --git a/maven-compat/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java b/maven-compat/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java index 020b652650..ece7c397f4 100644 --- a/maven-compat/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java +++ b/maven-compat/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java @@ -125,9 +125,9 @@ public class DefaultPathTranslator if ( s != null ) { String basedirExpr = null; - for ( int i = 0; i < BASEDIR_EXPRESSIONS.length; i++ ) + for ( String BASEDIR_EXPRESSION : BASEDIR_EXPRESSIONS ) { - basedirExpr = BASEDIR_EXPRESSIONS[i]; + basedirExpr = BASEDIR_EXPRESSION; if ( s.startsWith( basedirExpr ) ) { break; diff --git a/maven-compat/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumenter.java b/maven-compat/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumenter.java index e0192ca0a2..9a4569fb1d 100644 --- a/maven-compat/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumenter.java +++ b/maven-compat/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumenter.java @@ -55,13 +55,13 @@ public class ExpressionDocumenter ClassLoader docLoader = initializeDocLoader(); - for ( int i = 0; i < EXPRESSION_ROOTS.length; i++ ) + for ( String EXPRESSION_ROOT : EXPRESSION_ROOTS ) { InputStream docStream = null; try { - docStream = docLoader - .getResourceAsStream( EXPRESSION_DOCO_ROOTPATH + EXPRESSION_ROOTS[i] + ".paramdoc.xml" ); + docStream = + docLoader.getResourceAsStream( EXPRESSION_DOCO_ROOTPATH + EXPRESSION_ROOT + ".paramdoc.xml" ); if ( docStream != null ) { @@ -72,13 +72,13 @@ public class ExpressionDocumenter } catch ( IOException e ) { - throw new ExpressionDocumentationException( "Failed to read documentation for expression root: " - + EXPRESSION_ROOTS[i], e ); + throw new ExpressionDocumentationException( + "Failed to read documentation for expression root: " + EXPRESSION_ROOT, e ); } catch ( XmlPullParserException e ) { - throw new ExpressionDocumentationException( "Failed to parse documentation for expression root: " - + EXPRESSION_ROOTS[i], e ); + throw new ExpressionDocumentationException( + "Failed to parse documentation for expression root: " + EXPRESSION_ROOT, e ); } finally { @@ -130,9 +130,9 @@ public class ExpressionDocumenter if ( expressions != null && !expressions.isEmpty() ) { - for ( Iterator it = expressions.iterator(); it.hasNext(); ) + for ( Object expression : expressions ) { - Expression expr = (Expression) it.next(); + Expression expr = (Expression) expression; bySyntax.put( expr.getSyntax(), expr ); } diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/testutils/MockManager.java b/maven-compat/src/test/java/org/apache/maven/artifact/testutils/MockManager.java index 342af15b21..4b6f637bc7 100644 --- a/maven-compat/src/test/java/org/apache/maven/artifact/testutils/MockManager.java +++ b/maven-compat/src/test/java/org/apache/maven/artifact/testutils/MockManager.java @@ -37,20 +37,20 @@ public class MockManager public void replayAll() { - for ( Iterator it = mockControls.iterator(); it.hasNext(); ) + for ( Object mockControl : mockControls ) { - MockControl control = ( MockControl ) it.next(); - + MockControl control = (MockControl) mockControl; + control.replay(); } } public void verifyAll() { - for ( Iterator it = mockControls.iterator(); it.hasNext(); ) + for ( Object mockControl : mockControls ) { - MockControl control = ( MockControl ) it.next(); - + MockControl control = (MockControl) mockControl; + control.verify(); } } diff --git a/maven-compat/src/test/java/org/apache/maven/project/ModelUtilsTest.java b/maven-compat/src/test/java/org/apache/maven/project/ModelUtilsTest.java index d2c44a1944..06b2e1d149 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/ModelUtilsTest.java +++ b/maven-compat/src/test/java/org/apache/maven/project/ModelUtilsTest.java @@ -157,9 +157,9 @@ public class ModelUtilsTest if( configuration != null ) { - for ( Iterator it = configuration.entrySet().iterator(); it.hasNext(); ) + for ( Object o : configuration.entrySet() ) { - Map.Entry entry = (Map.Entry) it.next(); + Map.Entry entry = (Map.Entry) o; Xpp3Dom param = new Xpp3Dom( String.valueOf( entry.getKey() ) ); param.setValue( String.valueOf( entry.getValue() ) ); diff --git a/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java b/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java index 01a128b5ae..f696675b25 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java +++ b/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java @@ -133,9 +133,8 @@ public class ProjectClasspathTest private Artifact getArtifact( MavenProject project, String groupId, String artifactId ) { System.out.println( "[ Looking for " + groupId + ":" + artifactId + " ]" ); - for ( Iterator i = project.getArtifacts().iterator(); i.hasNext(); ) + for ( Artifact a : project.getArtifacts() ) { - Artifact a = i.next(); System.out.println( a.toString() ); if ( artifactId.equals( a.getArtifactId() ) && a.getGroupId().equals( groupId ) ) { diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheritanceTest.java index bb103cca73..e24262f1a3 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheritanceTest.java +++ b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheritanceTest.java @@ -70,12 +70,14 @@ public class ProjectInheritanceTest assertTrue( "No Artifacts", set.size() > 0 ); assertTrue( "Set size should be 3, is " + set.size(), set.size() == 3 ); - Iterator iter = set.iterator(); - while ( iter.hasNext() ) + for ( Object aSet : set ) { - Artifact artifact = (Artifact) iter.next(); - System.out.println( "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() - + " Optional=" + ( artifact.isOptional() ? "true" : "false" ) ); + Artifact artifact = (Artifact) aSet; + System.out.println( + "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Optional=" + ( + artifact.isOptional() + ? "true" + : "false" ) ); assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(), artifact.getVersion().equals( "1.0" ) ); } diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t05/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t05/ProjectInheritanceTest.java index 6007b64502..1d2bd182f4 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t05/ProjectInheritanceTest.java +++ b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t05/ProjectInheritanceTest.java @@ -64,14 +64,15 @@ public class ProjectInheritanceTest Set set = project1.getArtifacts(); assertNotNull( "No artifacts", set ); assertTrue( "No Artifacts", set.size() > 0 ); - Iterator iter = set.iterator(); - while ( iter.hasNext() ) + for ( Object aSet : set ) { - Artifact artifact = (Artifact) iter.next(); - System.out.println( "Artifact: " + artifact.getDependencyConflictId() + " " - + artifact.getVersion() + " Scope: " + artifact.getScope() ); - assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(), artifact.getVersion().equals( "1.0" ) ); + Artifact artifact = (Artifact) aSet; + System.out.println( + "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Scope: " + + artifact.getScope() ); + assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(), + artifact.getVersion().equals( "1.0" ) ); } } diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java index 9512ee744b..68586aafb7 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java +++ b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java @@ -66,14 +66,17 @@ public class ProjectInheritanceTest assertTrue("No Artifacts", set.size() > 0); assertTrue("Set size should be 3, is " + set.size(), set.size() == 3 ); - Iterator iter = set.iterator(); - - while (iter.hasNext()) + for ( Object aSet : set ) { - Artifact artifact = (Artifact)iter.next(); + Artifact artifact = (Artifact) aSet; assertFalse( "", artifact.getArtifactId().equals( "t07-d" ) ); - System.out.println("Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Optional=" + (artifact.isOptional() ? "true" : "false")); - assertTrue("Incorrect version for " + artifact.getDependencyConflictId(), artifact.getVersion().equals("1.0")); + System.out.println( + "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Optional=" + ( + artifact.isOptional() + ? "true" + : "false" ) ); + assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(), + artifact.getVersion().equals( "1.0" ) ); } } } diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java index 7c48507df2..f8fe1a3e11 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java @@ -719,9 +719,9 @@ public class DefaultArtifactCollectorTest private Artifact getArtifact( String id, Set artifacts ) { - for ( Iterator i = artifacts.iterator(); i.hasNext(); ) + for ( Object artifact : artifacts ) { - Artifact a = (Artifact) i.next(); + Artifact a = (Artifact) artifact; if ( a.getArtifactId().equals( id ) && a.getGroupId().equals( GROUP_ID ) ) { return a; @@ -886,9 +886,9 @@ public class DefaultArtifactCollectorTest { Set projectArtifacts = new HashSet(); - for ( Iterator i = dependencies.iterator(); i.hasNext(); ) + for ( Object dependency : dependencies ) { - Artifact d = (Artifact) i.next(); + Artifact d = (Artifact) dependency; VersionRange versionRange; if ( d.getVersionRange() != null ) @@ -904,8 +904,8 @@ public class DefaultArtifactCollectorTest { /* don't call createDependencyArtifact as it'll ignore test and provided scopes */ artifact = - artifactFactory.createArtifact( d.getGroupId(), d.getArtifactId(), d.getVersion(), - d.getScope(), d.getType() ); + artifactFactory.createArtifact( d.getGroupId(), d.getArtifactId(), d.getVersion(), d.getScope(), + d.getType() ); } else { diff --git a/maven-core/src/main/java/org/apache/maven/execution/ReactorManager.java b/maven-core/src/main/java/org/apache/maven/execution/ReactorManager.java index 6cbc133517..97d5857b32 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/ReactorManager.java +++ b/maven-core/src/main/java/org/apache/maven/execution/ReactorManager.java @@ -127,12 +127,12 @@ public class ReactorManager if ( dependents != null && !dependents.isEmpty() ) { - for ( Iterator it = dependents.iterator(); it.hasNext(); ) + for ( Object dependent : dependents ) { - String dependentId = (String) it.next(); + String dependentId = (String) dependent; - if ( !buildSuccessesByProject.containsKey( dependentId ) - && !buildFailuresByProject.containsKey( dependentId ) ) + if ( !buildSuccessesByProject.containsKey( dependentId ) && !buildFailuresByProject.containsKey( + dependentId ) ) { blackList( dependentId ); } diff --git a/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java b/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java index 46aeb0b6af..c3b3753c77 100644 --- a/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java +++ b/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java @@ -110,18 +110,16 @@ public class DefaultLifecycleBindingsInjector Map merged = new LinkedHashMap( ( src.size() + tgt.size() ) * 2 ); - for ( Iterator it = tgt.iterator(); it.hasNext(); ) + for ( Plugin element : tgt ) { - Plugin element = it.next(); Object key = getPluginKey( element ); merged.put( key, element ); } Map unmanaged = new LinkedHashMap(); - for ( Iterator it = src.iterator(); it.hasNext(); ) + for ( Plugin element : src ) { - Plugin element = it.next(); Object key = getPluginKey( element ); Plugin existing = merged.get( key ); if ( existing != null ) @@ -140,9 +138,8 @@ public class DefaultLifecycleBindingsInjector PluginManagement pluginMgmt = (PluginManagement) context.get( PLUGIN_MANAGEMENT ); if ( pluginMgmt != null ) { - for ( Iterator it = pluginMgmt.getPlugins().iterator(); it.hasNext(); ) + for ( Plugin managedPlugin : pluginMgmt.getPlugins() ) { - Plugin managedPlugin = it.next(); Object key = getPluginKey( managedPlugin ); Plugin unmanagedPlugin = unmanaged.get( key ); if ( unmanagedPlugin != null ) diff --git a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java index c3f214f4c3..d6f308fe81 100644 --- a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java +++ b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java @@ -291,9 +291,8 @@ public class MavenProject List modules = getModules(); if ( modules != null ) { - for ( Iterator it = modules.iterator(); it.hasNext(); ) + for ( String modulePath : modules ) { - String modulePath = it.next(); String moduleName = modulePath; if ( moduleName.endsWith( "/" ) || moduleName.endsWith( "\\" ) ) @@ -1248,10 +1247,8 @@ public class MavenProject List extensions = getBuildExtensions(); if ( extensions != null ) { - for ( Iterator i = extensions.iterator(); i.hasNext(); ) + for ( Extension ext : extensions ) { - Extension ext = i.next(); - String version; if ( StringUtils.isEmpty( ext.getVersion() ) ) { @@ -1262,7 +1259,8 @@ public class MavenProject version = ext.getVersion(); } - Artifact artifact = repositorySystem.createArtifact( ext.getGroupId(), ext.getArtifactId(), version, null, "jar" ); + Artifact artifact = + repositorySystem.createArtifact( ext.getGroupId(), ext.getArtifactId(), version, null, "jar" ); if ( artifact != null ) { @@ -1556,10 +1554,8 @@ public class MavenProject if ( getReportPlugins() != null ) { - for ( Iterator iterator = getReportPlugins().iterator(); iterator.hasNext(); ) + for ( ReportPlugin plugin : getReportPlugins() ) { - ReportPlugin plugin = iterator.next(); - if ( pluginGroupId.equals( plugin.getGroupId() ) && pluginArtifactId.equals( plugin.getArtifactId() ) ) { dom = (Xpp3Dom) plugin.getConfiguration(); @@ -1668,10 +1664,8 @@ public class MavenProject if ( ( dependencyManagement != null ) && ( ( deps = dependencyManagement.getDependencies() ) != null ) && ( deps.size() > 0 ) ) { map = new HashMap(); - for ( Iterator i = dependencyManagement.getDependencies().iterator(); i.hasNext(); ) + for ( Dependency d : dependencyManagement.getDependencies() ) { - Dependency d = i.next(); - Artifact artifact = repositorySystem.createDependencyArtifact( d ); if ( artifact == null ) diff --git a/maven-core/src/main/java/org/apache/maven/toolchain/java/DefaultJavaToolchainFactory.java b/maven-core/src/main/java/org/apache/maven/toolchain/java/DefaultJavaToolchainFactory.java index 776f314562..6a8e7f650a 100644 --- a/maven-core/src/main/java/org/apache/maven/toolchain/java/DefaultJavaToolchainFactory.java +++ b/maven-core/src/main/java/org/apache/maven/toolchain/java/DefaultJavaToolchainFactory.java @@ -78,23 +78,22 @@ public class DefaultJavaToolchainFactory //TODO possibly move at least parts to a utility method or abstract implementation. dom = (Xpp3Dom) model.getProvides(); Xpp3Dom[] provides = dom.getChildren(); - for ( int i = 0; i < provides.length; i++ ) + for ( Xpp3Dom provide : provides ) { - String key = provides[i].getName(); - String value = provides[i].getValue(); + String key = provide.getName(); + String value = provide.getValue(); if ( value == null ) { - throw new MisconfiguredToolchainException( "Provides token '" + key + "' doesn't have any value configured." ); + throw new MisconfiguredToolchainException( + "Provides token '" + key + "' doesn't have any value configured." ); } if ( "version".equals( key ) ) { - jtc.addProvideToken( key, - RequirementMatcherFactory.createVersionMatcher( value ) ); + jtc.addProvideToken( key, RequirementMatcherFactory.createVersionMatcher( value ) ); } else { - jtc.addProvideToken( key, - RequirementMatcherFactory.createExactMatcher( value ) ); + jtc.addProvideToken( key, RequirementMatcherFactory.createExactMatcher( value ) ); } } return jtc; diff --git a/maven-core/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java b/maven-core/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java index 15dbed8139..7f1cef776b 100644 --- a/maven-core/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java +++ b/maven-core/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java @@ -59,10 +59,8 @@ public class DefaultMavenProjectBuilderTest if ( !filesToDelete.isEmpty() ) { - for ( Iterator it = filesToDelete.iterator(); it.hasNext(); ) + for ( File file : filesToDelete ) { - File file = it.next(); - if ( file.exists() ) { if ( file.isDirectory() ) diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java b/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java index 73a906ab0d..5ca56d8af0 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java @@ -161,10 +161,8 @@ public class CLIManager StringBuilder currentArg = null; - for ( int i = 0; i < args.length; i++ ) + for ( String arg : args ) { - String arg = args[i]; - boolean addedToBuffer = false; if ( arg.startsWith( "\"" ) ) diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java index 004f264a04..1c142c4ec9 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java @@ -865,9 +865,9 @@ public class MavenCli String[] profileOptionValues = commandLine.getOptionValues( CLIManager.ACTIVATE_PROFILES ); if ( profileOptionValues != null ) { - for ( int i = 0; i < profileOptionValues.length; ++i ) + for ( String profileOptionValue : profileOptionValues ) { - StringTokenizer profileTokens = new StringTokenizer( profileOptionValues[i], "," ); + StringTokenizer profileTokens = new StringTokenizer( profileOptionValue, "," ); while ( profileTokens.hasMoreTokens() ) { @@ -978,9 +978,9 @@ public class MavenCli { String[] values = commandLine.getOptionValues( CLIManager.PROJECT_LIST ); List projects = new ArrayList(); - for ( int i = 0; i < values.length; i++ ) + for ( String value : values ) { - String[] tmp = StringUtils.split( values[i], "," ); + String[] tmp = StringUtils.split( value, "," ); projects.addAll( Arrays.asList( tmp ) ); } request.setSelectedProjects( projects ); @@ -1076,9 +1076,9 @@ public class MavenCli if ( defStrs != null ) { - for ( int i = 0; i < defStrs.length; ++i ) + for ( String defStr : defStrs ) { - setCliProperty( defStrs[i], userProperties ); + setCliProperty( defStr, userProperties ); } } }