maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aherit...@apache.org
Subject [32/50] git commit: Code cleanup - Maven requires Java 5+ : Replace for and while loops by for each
Date Mon, 15 Jul 2013 22:26:30 GMT
Code cleanup - Maven requires Java 5+ : Replace for and while loops by for each


Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/d92746dc
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/d92746dc
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/d92746dc

Branch: refs/heads/slf4j-logback
Commit: d92746dc25bdce073571cf6fd8f78d6573fe75f0
Parents: 1f84f8f
Author: Arnaud Héritier <aheritier@apache.org>
Authored: Tue Jun 11 22:21:54 2013 +0200
Committer: Arnaud Héritier <aheritier@apache.org>
Committed: Tue Jun 11 22:21:54 2013 +0200

----------------------------------------------------------------------
 .../maven/profiles/DefaultProfileManager.java   | 12 ++---
 .../maven/profiles/ProfilesConversionUtils.java | 12 ++---
 .../DefaultModelInheritanceAssembler.java       | 13 ++---
 .../StringSearchModelInterpolator.java          | 50 +++++++++++---------
 .../project/path/DefaultPathTranslator.java     |  4 +-
 .../usability/plugin/ExpressionDocumenter.java  | 18 +++----
 .../maven/artifact/testutils/MockManager.java   | 12 ++---
 .../apache/maven/project/ModelUtilsTest.java    |  4 +-
 .../maven/project/ProjectClasspathTest.java     |  3 +-
 .../inheritance/t04/ProjectInheritanceTest.java | 12 +++--
 .../inheritance/t05/ProjectInheritanceTest.java | 13 ++---
 .../inheritance/t07/ProjectInheritanceTest.java | 15 +++---
 .../resolver/DefaultArtifactCollectorTest.java  | 12 ++---
 .../apache/maven/execution/ReactorManager.java  |  8 ++--
 .../DefaultLifecycleBindingsInjector.java       |  9 ++--
 .../org/apache/maven/project/MavenProject.java  | 18 +++----
 .../java/DefaultJavaToolchainFactory.java       | 15 +++---
 .../project/DefaultMavenProjectBuilderTest.java |  4 +-
 .../java/org/apache/maven/cli/CLIManager.java   |  4 +-
 .../java/org/apache/maven/cli/MavenCli.java     | 12 ++---
 20 files changed, 120 insertions(+), 130 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/d92746dc/maven-compat/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java
----------------------------------------------------------------------
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 740c2cd..bfade80 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 );
         }

http://git-wip-us.apache.org/repos/asf/maven/blob/d92746dc/maven-compat/src/main/java/org/apache/maven/profiles/ProfilesConversionUtils.java
----------------------------------------------------------------------
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 8abe1de..041a9bb 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 ) );
             }
         }
 

http://git-wip-us.apache.org/repos/asf/maven/blob/d92746dc/maven-compat/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java
----------------------------------------------------------------------
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 85f7526..ec04f34 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<Dependency> childDeps = childDepMgmt.getDependencies();
 
                 Map<String, Dependency> mappedChildDeps = new TreeMap<String, Dependency>();
-                for ( Iterator<Dependency> it = childDeps.iterator(); it.hasNext();
)
+                for ( Dependency dep : childDeps )
                 {
-                    Dependency dep = it.next();
                     mappedChildDeps.put( dep.getManagementKey(), dep );
                 }
 
-                for ( Iterator<Dependency> 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;

http://git-wip-us.apache.org/repos/asf/maven/blob/d92746dc/maven-compat/src/main/java/org/apache/maven/project/interpolation/StringSearchModelInterpolator.java
----------------------------------------------------------------------
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 1ef5579..dcb8e2b 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<Object> c = (Collection<Object>)
fields[i].get( target );
+                                    Collection<Object> c = (Collection<Object>)
field.get( target );
                                     if ( c != null && !c.isEmpty() )
                                     {
                                         List<Object> originalValues = new ArrayList<Object>(
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<Object, Object> m = (Map<Object, Object>)
fields[i].get( target );
+                                    Map<Object, Object> m = (Map<Object, Object>)
field.get( target );
                                     if ( m != null && !m.isEmpty() )
                                     {
                                         for ( Map.Entry<Object, Object> 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 );
                         }
                     }
                 }

http://git-wip-us.apache.org/repos/asf/maven/blob/d92746dc/maven-compat/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java
----------------------------------------------------------------------
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 020b652..ece7c39 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;

http://git-wip-us.apache.org/repos/asf/maven/blob/d92746dc/maven-compat/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumenter.java
----------------------------------------------------------------------
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 e0192ca..9a4569f 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 );
             }

http://git-wip-us.apache.org/repos/asf/maven/blob/d92746dc/maven-compat/src/test/java/org/apache/maven/artifact/testutils/MockManager.java
----------------------------------------------------------------------
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 342af15..4b6f637 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();
         }
     }

http://git-wip-us.apache.org/repos/asf/maven/blob/d92746dc/maven-compat/src/test/java/org/apache/maven/project/ModelUtilsTest.java
----------------------------------------------------------------------
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 d2c44a1..06b2e1d 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() ) );

http://git-wip-us.apache.org/repos/asf/maven/blob/d92746dc/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java
----------------------------------------------------------------------
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 01a128b..f696675 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<Artifact> 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 ) )
             {

http://git-wip-us.apache.org/repos/asf/maven/blob/d92746dc/maven-compat/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheritanceTest.java
----------------------------------------------------------------------
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 bb103cc..e24262f 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" ) );
         }

http://git-wip-us.apache.org/repos/asf/maven/blob/d92746dc/maven-compat/src/test/java/org/apache/maven/project/inheritance/t05/ProjectInheritanceTest.java
----------------------------------------------------------------------
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 6007b64..1d2bd18 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" ) );
         }
 
     }

http://git-wip-us.apache.org/repos/asf/maven/blob/d92746dc/maven-compat/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java
----------------------------------------------------------------------
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 9512ee7..68586aa 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" ) );
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/maven/blob/d92746dc/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java
----------------------------------------------------------------------
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 7c48507..f8fe1a3 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
                 {

http://git-wip-us.apache.org/repos/asf/maven/blob/d92746dc/maven-core/src/main/java/org/apache/maven/execution/ReactorManager.java
----------------------------------------------------------------------
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 6cbc133..97d5857 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 );
                     }

http://git-wip-us.apache.org/repos/asf/maven/blob/d92746dc/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java
----------------------------------------------------------------------
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 46aeb0b..c3b3753 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<Object, Plugin> merged = new LinkedHashMap<Object, Plugin>(
( src.size() + tgt.size() ) * 2 );
 
-                for ( Iterator<Plugin> it = tgt.iterator(); it.hasNext(); )
+                for ( Plugin element : tgt )
                 {
-                    Plugin element = it.next();
                     Object key = getPluginKey( element );
                     merged.put( key, element );
                 }
 
                 Map<Object, Plugin> unmanaged = new LinkedHashMap<Object, Plugin>();
 
-                for ( Iterator<Plugin> 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<Plugin> 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 )

http://git-wip-us.apache.org/repos/asf/maven/blob/d92746dc/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
----------------------------------------------------------------------
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 c3f214f..d6f308f 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<String> modules = getModules();
             if ( modules != null )
             {
-                for ( Iterator<String> 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<Extension> extensions = getBuildExtensions();
         if ( extensions != null )
         {
-            for ( Iterator<Extension> 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<ReportPlugin> 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<String, Artifact>();
-                for ( Iterator<Dependency> i = dependencyManagement.getDependencies().iterator();
i.hasNext(); )
+                for ( Dependency d : dependencyManagement.getDependencies() )
                 {
-                    Dependency d = i.next();
-
                     Artifact artifact = repositorySystem.createDependencyArtifact( d );
 
                     if ( artifact == null )

http://git-wip-us.apache.org/repos/asf/maven/blob/d92746dc/maven-core/src/main/java/org/apache/maven/toolchain/java/DefaultJavaToolchainFactory.java
----------------------------------------------------------------------
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 776f314..6a8e7f6 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;

http://git-wip-us.apache.org/repos/asf/maven/blob/d92746dc/maven-core/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java
----------------------------------------------------------------------
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 15dbed8..7f1cef7 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<File> it = filesToDelete.iterator(); it.hasNext(); )
+            for ( File file : filesToDelete )
             {
-                File file = it.next();
-
                 if ( file.exists() )
                 {
                     if ( file.isDirectory() )

http://git-wip-us.apache.org/repos/asf/maven/blob/d92746dc/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java
----------------------------------------------------------------------
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 73a906a..5ca56d8 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( "\"" ) )

http://git-wip-us.apache.org/repos/asf/maven/blob/d92746dc/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
----------------------------------------------------------------------
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 004f264..1c142c4 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<String> projects = new ArrayList<String>();
-            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 );
                 }
             }
         }


Mime
View raw message