This is an automated email from the ASF dual-hosted git repository. michaelo pushed a commit to branch MNG-6075 in repository https://gitbox.apache.org/repos/asf/maven.git
commit 2ffefd673ea2da6b96d37c3e60f99acdf0bf32c8 Author: Michael Osipov <micha...@apache.org> AuthorDate: Sun Mar 14 00:07:24 2021 +0100 [MNG-6075] Increase the model validation level to the next minor level version --- .../project/DefaultMavenProjectBuilderTest.java | 12 ---- .../maven/model/building/ModelBuildingRequest.java | 2 +- .../validation/DefaultModelValidatorTest.java | 70 ++++++++-------------- 3 files changed, 27 insertions(+), 57 deletions(-) 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 2bff5d0..4983494 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 @@ -88,18 +88,6 @@ public class DefaultMavenProjectBuilderTest } @Test - public void testDuplicatePluginDefinitionsMerged() - throws Exception - { - File f1 = getTestFile( "src/test/resources/projects/duplicate-plugins-merged-pom.xml" ); - - MavenProject project = getProject( f1 ); - assertEquals( 2, project.getBuildPlugins().get( 0 ).getDependencies().size() ); - assertEquals( 2, project.getBuildPlugins().get( 0 ).getExecutions().size() ); - assertEquals( "first", project.getBuildPlugins().get( 0 ).getExecutions().get( 0 ).getId() ); - } - - @Test public void testFutureModelVersion() throws Exception { diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingRequest.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingRequest.java index bbd9e8b..9cdb06c 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingRequest.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingRequest.java @@ -62,7 +62,7 @@ public interface ModelBuildingRequest /** * Denotes strict validation as recommended by the current Maven version. */ - int VALIDATION_LEVEL_STRICT = VALIDATION_LEVEL_MAVEN_3_0; + int VALIDATION_LEVEL_STRICT = VALIDATION_LEVEL_MAVEN_3_1; /** * Gets the file model to build (with profile activation). 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 5de48c4..c6f3188 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 @@ -474,21 +474,13 @@ public class DefaultModelValidatorTest { SimpleProblemCollector result = validateRaw( "hard-coded-system-path.xml" ); - assertViolations( result, 0, 0, 1 ); + assertViolations( result, 0, 0, 3 ); assertContains( result.getWarnings().get( 0 ), - "'dependencies.dependency.systemPath' for test:a:jar should use a variable instead of a hard-coded path" ); - - SimpleProblemCollector result_31 = - validateRaw( "hard-coded-system-path.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1 ); - - assertViolations( result_31, 0, 0, 3 ); - - assertContains( result_31.getWarnings().get( 0 ), "'dependencies.dependency.scope' for test:a:jar declares usage of deprecated 'system' scope" ); - assertContains( result_31.getWarnings().get( 1 ), + assertContains( result.getWarnings().get( 1 ), "'dependencies.dependency.systemPath' for test:a:jar should use a variable instead of a hard-coded path" ); - assertContains( result_31.getWarnings().get( 2 ), + assertContains( result.getWarnings().get( 2 ), "'dependencies.dependency.scope' for test:b:jar declares usage of deprecated 'system' scope" ); } @@ -510,12 +502,12 @@ public class DefaultModelValidatorTest { SimpleProblemCollector result = validateRaw( "duplicate-plugin.xml" ); - assertViolations( result, 0, 0, 4 ); + assertViolations( result, 0, 4, 0 ); - assertTrue( result.getWarnings().get( 0 ).contains( "duplicate declaration of plugin test:duplicate" ) ); - assertTrue( result.getWarnings().get( 1 ).contains( "duplicate declaration of plugin test:managed-duplicate" ) ); - assertTrue( result.getWarnings().get( 2 ).contains( "duplicate declaration of plugin profile:duplicate" ) ); - assertTrue( result.getWarnings().get( 3 ).contains( "duplicate declaration of plugin profile:managed-duplicate" ) ); + assertTrue( result.getErrors().get( 0 ).contains( "duplicate declaration of plugin test:duplicate" ) ); + assertTrue( result.getErrors().get( 1 ).contains( "duplicate declaration of plugin test:managed-duplicate" ) ); + assertTrue( result.getErrors().get( 2 ).contains( "duplicate declaration of plugin profile:duplicate" ) ); + assertTrue( result.getErrors().get( 3 ).contains( "duplicate declaration of plugin profile:managed-duplicate" ) ); } @Test @@ -538,12 +530,12 @@ public class DefaultModelValidatorTest { SimpleProblemCollector result = validate( "reserved-repository-id.xml" ); - assertViolations( result, 0, 0, 4 ); + assertViolations( result, 0, 4, 0 ); - assertContains( result.getWarnings().get( 0 ), "'repositories.repository.id'" + " must not be 'local'" ); - assertContains( result.getWarnings().get( 1 ), "'pluginRepositories.pluginRepository.id' must not be 'local'" ); - assertContains( result.getWarnings().get( 2 ), "'distributionManagement.repository.id' must not be 'local'" ); - assertContains( result.getWarnings().get( 3 ), + assertContains( result.getErrors().get( 0 ), "'repositories.repository.id'" + " must not be 'local'" ); + assertContains( result.getErrors().get( 1 ), "'pluginRepositories.pluginRepository.id' must not be 'local'" ); + assertContains( result.getErrors().get( 2 ), "'distributionManagement.repository.id' must not be 'local'" ); + assertContains( result.getErrors().get( 3 ), "'distributionManagement.snapshotRepository.id' must not be 'local'" ); } @@ -597,9 +589,9 @@ public class DefaultModelValidatorTest { SimpleProblemCollector result = validate( "bad-version.xml" ); - assertViolations( result, 0, 0, 1 ); + assertViolations( result, 0, 1, 0 ); - assertContains( result.getWarnings().get( 0 ), "'version' must not contain any of these characters" ); + assertContains( result.getErrors().get( 0 ), "'version' must not contain any of these characters" ); } @Test @@ -608,9 +600,9 @@ public class DefaultModelValidatorTest { SimpleProblemCollector result = validate( "bad-snapshot-version.xml" ); - assertViolations( result, 0, 0, 1 ); + assertViolations( result, 0, 1, 0 ); - assertContains( result.getWarnings().get( 0 ), "'version' uses an unsupported snapshot version format" ); + assertContains( result.getErrors().get( 0 ), "'version' uses an unsupported snapshot version format" ); } @Test @@ -619,15 +611,15 @@ public class DefaultModelValidatorTest { SimpleProblemCollector result = validate( "bad-repository-id.xml" ); - assertViolations( result, 0, 0, 4 ); + assertViolations( result, 0, 4, 0 ); - assertContains( result.getWarnings().get( 0 ), + assertContains( result.getErrors().get( 0 ), "'repositories.repository.id' must not contain any of these characters" ); - assertContains( result.getWarnings().get( 1 ), + assertContains( result.getErrors().get( 1 ), "'pluginRepositories.pluginRepository.id' must not contain any of these characters" ); - assertContains( result.getWarnings().get( 2 ), + assertContains( result.getErrors().get( 2 ), "'distributionManagement.repository.id' must not contain any of these characters" ); - assertContains( result.getWarnings().get( 3 ), + assertContains( result.getErrors().get( 3 ), "'distributionManagement.snapshotRepository.id' must not contain any of these characters" ); } @@ -697,25 +689,15 @@ public class DefaultModelValidatorTest { SimpleProblemCollector result = validateRaw( "basedir-system-path.xml" ); - assertViolations( result, 0, 0, 2 ); + assertViolations( result, 0, 0, 4 ); assertContains( result.getWarnings().get( 0 ), - "'dependencies.dependency.systemPath' for test:a:jar should not point at files within the project directory" ); - assertContains( result.getWarnings().get( 1 ), - "'dependencies.dependency.systemPath' for test:b:jar should not point at files within the project directory" ); - - SimpleProblemCollector result_31 = - validateRaw( "basedir-system-path.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1 ); - - assertViolations( result_31, 0, 0, 4 ); - - assertContains( result_31.getWarnings().get( 0 ), "'dependencies.dependency.scope' for test:a:jar declares usage of deprecated 'system' scope" ); - assertContains( result_31.getWarnings().get( 1 ), + assertContains( result.getWarnings().get( 1 ), "'dependencies.dependency.systemPath' for test:a:jar should not point at files within the project directory" ); - assertContains( result_31.getWarnings().get( 2 ), + assertContains( result.getWarnings().get( 2 ), "'dependencies.dependency.scope' for test:b:jar declares usage of deprecated 'system' scope" ); - assertContains( result_31.getWarnings().get( 3 ), + assertContains( result.getWarnings().get( 3 ), "'dependencies.dependency.systemPath' for test:b:jar should not point at files within the project directory" ); }