diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java index 1cb1c695c8..fa262c89aa 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java @@ -196,11 +196,12 @@ public class DefaultModelValidator + "' is invalid. Aggregator projects " + "require 'pom' as packaging." ); } - for ( String module : model.getModules() ) + for ( int i = 0, n = model.getModules().size(); i < n; i++ ) { + String module = model.getModules().get( i ); if ( StringUtils.isBlank( module ) ) { - addViolation( problems, Severity.WARNING, "modules.module", null, + addViolation( problems, Severity.WARNING, "modules.module[" + i + "]", null, "has been specified without a path to the project directory." ); } } @@ -221,12 +222,13 @@ public class DefaultModelValidator if ( request.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 ) { Set modules = new HashSet(); - for ( String module : model.getModules() ) + for ( int i = 0, n = model.getModules().size(); i < n; i++ ) { + String module = model.getModules().get( i ); if ( !modules.add( module ) ) { - addViolation( problems, Severity.ERROR, "modules.module", null, "specifies duplicate child module " - + module ); + addViolation( problems, Severity.ERROR, "modules.module[" + i + "]", null, + "specifies duplicate child module " + module ); } } diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java index 76297c6e41..456d46ebad 100644 --- a/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java +++ b/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java @@ -420,7 +420,7 @@ public class DefaultModelValidatorTest assertViolations( result, 0, 0, 1 ); - assertTrue( result.getWarnings().get( 0 ).contains( "'modules.module' has been specified without a path" ) ); + assertTrue( result.getWarnings().get( 0 ).contains( "'modules.module[0]' has been specified without a path" ) ); } public void testDuplicatePlugin()