diff --git a/impl/maven-impl/src/main/java/org/apache/maven/api/services/model/ModelValidator.java b/impl/maven-impl/src/main/java/org/apache/maven/api/services/model/ModelValidator.java index 40a8e813de..3ac9d92069 100644 --- a/impl/maven-impl/src/main/java/org/apache/maven/api/services/model/ModelValidator.java +++ b/impl/maven-impl/src/main/java/org/apache/maven/api/services/model/ModelValidator.java @@ -19,7 +19,6 @@ package org.apache.maven.api.services.model; import org.apache.maven.api.model.Model; -import org.apache.maven.api.services.ModelBuilderRequest; import org.apache.maven.api.services.ModelProblemCollector; /** @@ -60,13 +59,9 @@ public interface ModelValidator { * * @param model The model to validate, must not be {@code null}. * @param validationLevel The validation level. - * @param request The model building request that holds further settings, must not be {@code null}. * @param problems The container used to collect problems that were encountered, must not be {@code null}. */ - default void validateFileModel( - Model model, int validationLevel, ModelBuilderRequest request, ModelProblemCollector problems) { - // do nothing - } + void validateFileModel(Model model, int validationLevel, ModelProblemCollector problems); /** * Checks the specified (raw) model for missing or invalid values. The raw model is the file model + buildpom filter @@ -74,11 +69,9 @@ public interface ModelValidator { * * @param model The model to validate, must not be {@code null}. * @param validationLevel The validation level. - * @param request The model building request that holds further settings, must not be {@code null}. * @param problems The container used to collect problems that were encountered, must not be {@code null}. */ - void validateRawModel( - Model model, int validationLevel, ModelBuilderRequest request, ModelProblemCollector problems); + void validateRawModel(Model model, int validationLevel, ModelProblemCollector problems); /** * Checks the specified (effective) model for missing or invalid values. The effective model is fully assembled and @@ -86,9 +79,7 @@ public interface ModelValidator { * * @param model The model to validate, must not be {@code null}. * @param validationLevel The validation level. - * @param request The model building request that holds further settings, must not be {@code null}. * @param problems The container used to collect problems that were encountered, must not be {@code null}. */ - void validateEffectiveModel( - Model model, int validationLevel, ModelBuilderRequest request, ModelProblemCollector problems); + void validateEffectiveModel(Model model, int validationLevel, ModelProblemCollector problems); } diff --git a/impl/maven-impl/src/main/java/org/apache/maven/internal/impl/model/DefaultModelBuilder.java b/impl/maven-impl/src/main/java/org/apache/maven/internal/impl/model/DefaultModelBuilder.java index 0490de64fb..64b023a4d4 100644 --- a/impl/maven-impl/src/main/java/org/apache/maven/internal/impl/model/DefaultModelBuilder.java +++ b/impl/maven-impl/src/main/java/org/apache/maven/internal/impl/model/DefaultModelBuilder.java @@ -858,7 +858,6 @@ public class DefaultModelBuilder implements ModelBuilder { modelValidator.validateEffectiveModel( resultModel, isBuildRequest() ? ModelValidator.VALIDATION_LEVEL_STRICT : ModelValidator.VALIDATION_LEVEL_MINIMAL, - request, this); if (hasErrors()) { @@ -1453,7 +1452,6 @@ public class DefaultModelBuilder implements ModelBuilder { modelValidator.validateFileModel( model, isBuildRequest() ? ModelValidator.VALIDATION_LEVEL_STRICT : ModelValidator.VALIDATION_LEVEL_MINIMAL, - request, this); if (hasFatalErrors()) { throw newModelBuilderException(); @@ -1485,7 +1483,6 @@ public class DefaultModelBuilder implements ModelBuilder { modelValidator.validateRawModel( rawModel, isBuildRequest() ? ModelValidator.VALIDATION_LEVEL_STRICT : ModelValidator.VALIDATION_LEVEL_MINIMAL, - request, this); if (hasFatalErrors()) { diff --git a/impl/maven-impl/src/main/java/org/apache/maven/internal/impl/model/DefaultModelValidator.java b/impl/maven-impl/src/main/java/org/apache/maven/internal/impl/model/DefaultModelValidator.java index a6598c5039..e67fd88717 100644 --- a/impl/maven-impl/src/main/java/org/apache/maven/internal/impl/model/DefaultModelValidator.java +++ b/impl/maven-impl/src/main/java/org/apache/maven/internal/impl/model/DefaultModelValidator.java @@ -66,7 +66,6 @@ import org.apache.maven.api.model.Repository; import org.apache.maven.api.model.Resource; import org.apache.maven.api.services.BuilderProblem.Severity; import org.apache.maven.api.services.ModelBuilder; -import org.apache.maven.api.services.ModelBuilderRequest; import org.apache.maven.api.services.ModelProblem; import org.apache.maven.api.services.ModelProblem.Version; import org.apache.maven.api.services.ModelProblemCollector; @@ -304,8 +303,7 @@ public class DefaultModelValidator implements ModelValidator { @Override @SuppressWarnings("checkstyle:MethodLength") - public void validateFileModel( - Model m, int validationLevel, ModelBuilderRequest request, ModelProblemCollector problems) { + public void validateFileModel(Model m, int validationLevel, ModelProblemCollector problems) { Parent parent = m.getParent(); if (parent != null) { @@ -443,12 +441,6 @@ public class DefaultModelValidator implements ModelValidator { Severity errOn30 = getSeverity(validationLevel, ModelValidator.VALIDATION_LEVEL_MAVEN_3_0); - // The file pom may not contain the modelVersion yet, as it may be set later by the - // ModelVersionXMLFilter. - if (m.getModelVersion() != null && !m.getModelVersion().isEmpty()) { - validateModelVersion(problems, m.getModelVersion(), m, VALID_MODEL_VERSIONS); - } - boolean isModelVersion41OrMore = !Objects.equals(ModelBuilder.MODEL_VERSION_4_0_0, m.getModelVersion()); if (isModelVersion41OrMore) { validateStringNoExpression("groupId", problems, Severity.FATAL, Version.V41, m.getGroupId(), m); @@ -489,11 +481,9 @@ public class DefaultModelValidator implements ModelValidator { "dependencies.dependency.", EMPTY, isModelVersion41OrMore, - validationLevel, - request); + validationLevel); - validate20RawDependenciesSelfReferencing( - problems, m, m.getDependencies(), "dependencies.dependency", request); + validate20RawDependenciesSelfReferencing(problems, m, m.getDependencies(), "dependencies.dependency"); if (m.getDependencyManagement() != null) { validate20RawDependencies( @@ -502,25 +492,21 @@ public class DefaultModelValidator implements ModelValidator { "dependencyManagement.dependencies.dependency.", EMPTY, isModelVersion41OrMore, - validationLevel, - request); + validationLevel); } - validateRawRepositories( - problems, m.getRepositories(), "repositories.repository.", EMPTY, validationLevel, request); + validateRawRepositories(problems, m.getRepositories(), "repositories.repository.", EMPTY, validationLevel); validateRawRepositories( problems, m.getPluginRepositories(), "pluginRepositories.pluginRepository.", EMPTY, - validationLevel, - request); + validationLevel); Build build = m.getBuild(); if (build != null) { - validate20RawPlugins( - problems, build.getPlugins(), "build.plugins.plugin.", EMPTY, validationLevel, request); + validate20RawPlugins(problems, build.getPlugins(), "build.plugins.plugin.", EMPTY, validationLevel); PluginManagement mgmt = build.getPluginManagement(); if (mgmt != null) { @@ -529,8 +515,7 @@ public class DefaultModelValidator implements ModelValidator { mgmt.getPlugins(), "build.pluginManagement.plugins.plugin.", EMPTY, - validationLevel, - request); + validationLevel); } } @@ -560,8 +545,7 @@ public class DefaultModelValidator implements ModelValidator { prefix, "dependencies.dependency.", isModelVersion41OrMore, - validationLevel, - request); + validationLevel); if (profile.getDependencyManagement() != null) { validate20RawDependencies( @@ -570,30 +554,22 @@ public class DefaultModelValidator implements ModelValidator { prefix, "dependencyManagement.dependencies.dependency.", isModelVersion41OrMore, - validationLevel, - request); + validationLevel); } validateRawRepositories( - problems, - profile.getRepositories(), - prefix, - "repositories.repository.", - validationLevel, - request); + problems, profile.getRepositories(), prefix, "repositories.repository.", validationLevel); validateRawRepositories( problems, profile.getPluginRepositories(), prefix, "pluginRepositories.pluginRepository.", - validationLevel, - request); + validationLevel); BuildBase buildBase = profile.getBuild(); if (buildBase != null) { - validate20RawPlugins( - problems, buildBase.getPlugins(), prefix, "plugins.plugin.", validationLevel, request); + validate20RawPlugins(problems, buildBase.getPlugins(), prefix, "plugins.plugin.", validationLevel); PluginManagement mgmt = buildBase.getPluginManagement(); if (mgmt != null) { @@ -602,8 +578,7 @@ public class DefaultModelValidator implements ModelValidator { mgmt.getPlugins(), prefix, "pluginManagement.plugins.plugin.", - validationLevel, - request); + validationLevel); } } } @@ -611,8 +586,7 @@ public class DefaultModelValidator implements ModelValidator { } @Override - public void validateRawModel( - Model m, int validationLevel, ModelBuilderRequest request, ModelProblemCollector problems) { + public void validateRawModel(Model m, int validationLevel, ModelProblemCollector problems) { // Check that the model version is correctly set wrt the model definition, i.e., that the // user does not use an attribute or element that is not available in the modelVersion used. String minVersion = new MavenModelVersion().getModelVersion(m); @@ -715,12 +689,7 @@ public class DefaultModelValidator implements ModelValidator { } private void validate20RawPlugins( - ModelProblemCollector problems, - List plugins, - String prefix, - String prefix2, - int validationLevel, - ModelBuilderRequest request) { + ModelProblemCollector problems, List plugins, String prefix, String prefix2, int validationLevel) { Severity errOn31 = getSeverity(validationLevel, ModelValidator.VALIDATION_LEVEL_MAVEN_3_1); Map index = new HashMap<>(); @@ -800,8 +769,7 @@ public class DefaultModelValidator implements ModelValidator { @Override @SuppressWarnings("checkstyle:MethodLength") - public void validateEffectiveModel( - Model m, int validationLevel, ModelBuilderRequest request, ModelProblemCollector problems) { + public void validateEffectiveModel(Model m, int validationLevel, ModelProblemCollector problems) { validateStringNotEmpty("modelVersion", problems, Severity.ERROR, Version.BASE, m.getModelVersion(), m); validateCoordinatesId("groupId", problems, m.getGroupId(), m); @@ -852,11 +820,11 @@ public class DefaultModelValidator implements ModelValidator { Severity errOn30 = getSeverity(validationLevel, ModelValidator.VALIDATION_LEVEL_MAVEN_3_0); - validateEffectiveDependencies(problems, m, m.getDependencies(), false, validationLevel, request); + validateEffectiveDependencies(problems, m, m.getDependencies(), false, validationLevel); DependencyManagement mgmt = m.getDependencyManagement(); if (mgmt != null) { - validateEffectiveDependencies(problems, m, mgmt.getDependencies(), true, validationLevel, request); + validateEffectiveDependencies(problems, m, mgmt.getDependencies(), true, validationLevel); } if (validationLevel >= ModelValidator.VALIDATION_LEVEL_MAVEN_2_0) { @@ -897,13 +865,7 @@ public class DefaultModelValidator implements ModelValidator { "build.plugins.plugin.groupId", problems, Severity.ERROR, Version.V20, p.getGroupId(), p); validate20PluginVersion( - "build.plugins.plugin.version", - problems, - p.getVersion(), - p.getKey(), - p, - validationLevel, - request); + "build.plugins.plugin.version", problems, p.getVersion(), p.getKey(), p, validationLevel); validateBoolean( "build.plugins.plugin.inherited", @@ -925,18 +887,13 @@ public class DefaultModelValidator implements ModelValidator { p.getKey(), p); - validate20EffectivePluginDependencies(problems, p, validationLevel, request); + validate20EffectivePluginDependencies(problems, p, validationLevel); } - validate20RawResources( - problems, build.getResources(), "build.resources.resource.", validationLevel, request); + validate20RawResources(problems, build.getResources(), "build.resources.resource.", validationLevel); validate20RawResources( - problems, - build.getTestResources(), - "build.testResources.testResource.", - validationLevel, - request); + problems, build.getTestResources(), "build.testResources.testResource.", validationLevel); } Reporting reporting = m.getReporting(); @@ -961,13 +918,12 @@ public class DefaultModelValidator implements ModelValidator { } for (Repository repository : m.getRepositories()) { - validate20EffectiveRepository( - problems, repository, "repositories.repository.", validationLevel, request); + validate20EffectiveRepository(problems, repository, "repositories.repository.", validationLevel); } for (Repository repository : m.getPluginRepositories()) { validate20EffectiveRepository( - problems, repository, "pluginRepositories.pluginRepository.", validationLevel, request); + problems, repository, "pluginRepositories.pluginRepository.", validationLevel); } DistributionManagement distMgmt = m.getDistributionManagement(); @@ -984,17 +940,12 @@ public class DefaultModelValidator implements ModelValidator { } validate20EffectiveRepository( - problems, - distMgmt.getRepository(), - "distributionManagement.repository.", - validationLevel, - request); + problems, distMgmt.getRepository(), "distributionManagement.repository.", validationLevel); validate20EffectiveRepository( problems, distMgmt.getSnapshotRepository(), "distributionManagement.snapshotRepository.", - validationLevel, - request); + validationLevel); } } } @@ -1005,8 +956,7 @@ public class DefaultModelValidator implements ModelValidator { String prefix, String prefix2, boolean is41OrBeyond, - int validationLevel, - ModelBuilderRequest request) { + int validationLevel) { Severity errOn30 = getSeverity(validationLevel, ModelValidator.VALIDATION_LEVEL_MAVEN_3_0); Severity errOn31 = getSeverity(validationLevel, ModelValidator.VALIDATION_LEVEL_MAVEN_3_1); @@ -1112,11 +1062,7 @@ public class DefaultModelValidator implements ModelValidator { } private void validate20RawDependenciesSelfReferencing( - ModelProblemCollector problems, - Model m, - List dependencies, - String prefix, - ModelBuilderRequest request) { + ModelProblemCollector problems, Model m, List dependencies, String prefix) { // We only check for groupId/artifactId/version/classifier cause if there is another // module with the same groupId/artifactId/version/classifier this will fail the build // earlier like "Project '...' is duplicated in the reactor. @@ -1147,14 +1093,13 @@ public class DefaultModelValidator implements ModelValidator { Model m, List dependencies, boolean management, - int validationLevel, - ModelBuilderRequest request) { + int validationLevel) { Severity errOn30 = getSeverity(validationLevel, ModelValidator.VALIDATION_LEVEL_MAVEN_3_0); String prefix = management ? "dependencyManagement.dependencies.dependency." : "dependencies.dependency."; for (Dependency d : dependencies) { - validateEffectiveDependency(problems, d, management, prefix, validationLevel, request); + validateEffectiveDependency(problems, d, management, prefix, validationLevel); if (validationLevel >= ModelValidator.VALIDATION_LEVEL_MAVEN_2_0) { validateBoolean( @@ -1183,7 +1128,7 @@ public class DefaultModelValidator implements ModelValidator { "test", "system"); - validateEffectiveModelAgainstDependency(prefix, problems, m, d, request); + validateEffectiveModelAgainstDependency(prefix, problems, m, d); } else { validateEnum( prefix, @@ -1206,7 +1151,7 @@ public class DefaultModelValidator implements ModelValidator { } private void validateEffectiveModelAgainstDependency( - String prefix, ModelProblemCollector problems, Model m, Dependency d, ModelBuilderRequest request) { + String prefix, ModelProblemCollector problems, Model m, Dependency d) { String key = d.getGroupId() + ":" + d.getArtifactId() + ":" + d.getVersion() + (d.getClassifier() != null ? ":" + d.getClassifier() : EMPTY); String mKey = m.getGroupId() + ":" + m.getArtifactId() + ":" + m.getVersion(); @@ -1220,7 +1165,7 @@ public class DefaultModelValidator implements ModelValidator { } private void validate20EffectivePluginDependencies( - ModelProblemCollector problems, Plugin plugin, int validationLevel, ModelBuilderRequest request) { + ModelProblemCollector problems, Plugin plugin, int validationLevel) { List dependencies = plugin.getDependencies(); if (!dependencies.isEmpty()) { @@ -1229,7 +1174,7 @@ public class DefaultModelValidator implements ModelValidator { Severity errOn30 = getSeverity(validationLevel, ModelValidator.VALIDATION_LEVEL_MAVEN_3_0); for (Dependency d : dependencies) { - validateEffectiveDependency(problems, d, false, prefix, validationLevel, request); + validateEffectiveDependency(problems, d, false, prefix, validationLevel); validateVersion( prefix, "version", problems, errOn30, Version.BASE, d.getVersion(), d.getManagementKey(), d); @@ -1251,12 +1196,7 @@ public class DefaultModelValidator implements ModelValidator { } private void validateEffectiveDependency( - ModelProblemCollector problems, - Dependency d, - boolean management, - String prefix, - int validationLevel, - ModelBuilderRequest request) { + ModelProblemCollector problems, Dependency d, boolean management, String prefix, int validationLevel) { validateCoordinatesId( prefix, "artifactId", @@ -1301,12 +1241,7 @@ public class DefaultModelValidator implements ModelValidator { "must specify an absolute path but is " + systemPath, d); } else if (!sysFile.isFile()) { - String msg = "refers to a non-existing file " + sysFile.getAbsolutePath(); - systemPath = systemPath.replace('/', File.separatorChar).replace('\\', File.separatorChar); - String jdkHome = request.getSystemProperties().get("java.home") + File.separator + ".."; - if (systemPath.startsWith(jdkHome)) { - msg += ". Please verify that you run Maven using a JDK and not just a JRE."; - } + String msg = "refers to a non-existing file " + sysFile.getAbsolutePath() + "."; addViolation( problems, Severity.WARNING, @@ -1388,8 +1323,7 @@ public class DefaultModelValidator implements ModelValidator { List repositories, String prefix, String prefix2, - int validationLevel, - ModelBuilderRequest request) { + int validationLevel) { Map index = new HashMap<>(); for (Repository repository : repositories) { @@ -1445,11 +1379,7 @@ public class DefaultModelValidator implements ModelValidator { } private void validate20EffectiveRepository( - ModelProblemCollector problems, - Repository repository, - String prefix, - int validationLevel, - ModelBuilderRequest request) { + ModelProblemCollector problems, Repository repository, String prefix, int validationLevel) { if (repository != null) { Severity errOn31 = getSeverity(validationLevel, ModelValidator.VALIDATION_LEVEL_MAVEN_3_1); @@ -1490,11 +1420,7 @@ public class DefaultModelValidator implements ModelValidator { } private void validate20RawResources( - ModelProblemCollector problems, - List resources, - String prefix, - int validationLevel, - ModelBuilderRequest request) { + ModelProblemCollector problems, List resources, String prefix, int validationLevel) { Severity errOn30 = getSeverity(validationLevel, ModelValidator.VALIDATION_LEVEL_MAVEN_3_0); for (Resource resource : resources) { @@ -1696,7 +1622,7 @@ public class DefaultModelValidator implements ModelValidator { } Matcher m = EXPRESSION_NAME_PATTERN.matcher(string.trim()); - while (m.find()) { + if (m.find()) { addViolation( problems, severity, @@ -2085,8 +2011,7 @@ public class DefaultModelValidator implements ModelValidator { String string, String sourceHint, InputLocationTracker tracker, - int validationLevel, - ModelBuilderRequest request) { + int validationLevel) { if (string == null) { addViolation( problems, diff --git a/impl/maven-impl/src/test/java/org/apache/maven/internal/impl/model/DefaultModelValidatorTest.java b/impl/maven-impl/src/test/java/org/apache/maven/internal/impl/model/DefaultModelValidatorTest.java new file mode 100644 index 0000000000..3392a86b44 --- /dev/null +++ b/impl/maven-impl/src/test/java/org/apache/maven/internal/impl/model/DefaultModelValidatorTest.java @@ -0,0 +1,864 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.internal.impl.model; + +import java.io.InputStream; +import java.util.List; + +import org.apache.maven.api.model.Model; +import org.apache.maven.api.services.model.ModelValidator; +import org.apache.maven.internal.impl.model.profile.SimpleProblemCollector; +import org.apache.maven.model.v4.MavenStaxReader; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + */ +class DefaultModelValidatorTest { + + private ModelValidator validator; + + private Model read(String pom) throws Exception { + String resource = "/poms/validation/" + pom; + try (InputStream is = getClass().getResourceAsStream(resource)) { + assertNotNull(is, "missing resource: " + resource); + return new MavenStaxReader().read(is); + } + } + + private SimpleProblemCollector validate(String pom) throws Exception { + return validateEffective(pom, ModelValidator.VALIDATION_LEVEL_STRICT); + } + + private SimpleProblemCollector validateFile(String pom) throws Exception { + return validateFile(pom, ModelValidator.VALIDATION_LEVEL_STRICT); + } + + private SimpleProblemCollector validateRaw(String pom) throws Exception { + return validateRaw(pom, ModelValidator.VALIDATION_LEVEL_STRICT); + } + + @SuppressWarnings("SameParameterValue") + private SimpleProblemCollector validateEffective(String pom, int level) throws Exception { + Model model = read(pom); + SimpleProblemCollector problems = new SimpleProblemCollector(); + validator.validateEffectiveModel(model, level, problems); + return problems; + } + + @SuppressWarnings("SameParameterValue") + private SimpleProblemCollector validateFile(String pom, int level) throws Exception { + Model model = read(pom); + SimpleProblemCollector problems = new SimpleProblemCollector(); + validator.validateFileModel(model, level, problems); + return problems; + } + + @SuppressWarnings("SameParameterValue") + private SimpleProblemCollector validateRaw(String pom, int level) throws Exception { + Model model = read(pom); + SimpleProblemCollector problems = new SimpleProblemCollector(); + validator.validateRawModel(model, level, problems); + return problems; + } + + private void assertContains(String msg, String substring) { + assertTrue(msg.contains(substring), "\"" + substring + "\" was not found in: " + msg); + } + + @BeforeEach + void setUp() throws Exception { + validator = new DefaultModelValidator(); + } + + @AfterEach + void tearDown() throws Exception { + this.validator = null; + } + + private void assertViolations(SimpleProblemCollector result, int fatals, int errors, int warnings) { + assertEquals(fatals, result.getFatals().size(), String.valueOf(result.getFatals())); + assertEquals(errors, result.getErrors().size(), String.valueOf(result.getErrors())); + assertEquals(warnings, result.getWarnings().size(), String.valueOf(result.getWarnings())); + } + + @Test + void testMissingModelVersion() throws Exception { + SimpleProblemCollector result = validate("missing-modelVersion-pom.xml"); + + assertViolations(result, 0, 1, 0); + + assertEquals("'modelVersion' is missing.", result.getErrors().get(0)); + } + + @Test + void testBadModelVersion() throws Exception { + SimpleProblemCollector result = validateFile("bad-modelVersion.xml"); + + assertViolations(result, 1, 0, 0); + + assertTrue(result.getFatals().get(0).contains("modelVersion")); + } + + @Test + void testModelVersionMessage() throws Exception { + SimpleProblemCollector result = validateFile("modelVersion-4_0.xml"); + + assertViolations(result, 0, 1, 0); + + assertTrue(result.getErrors().get(0).contains("'modelVersion' must be one of")); + } + + @Test + void testMissingArtifactId() throws Exception { + SimpleProblemCollector result = validate("missing-artifactId-pom.xml"); + + assertViolations(result, 0, 1, 0); + + assertEquals("'artifactId' is missing.", result.getErrors().get(0)); + } + + @Test + void testMissingGroupId() throws Exception { + SimpleProblemCollector result = validate("missing-groupId-pom.xml"); + + assertViolations(result, 0, 1, 0); + + assertEquals("'groupId' is missing.", result.getErrors().get(0)); + } + + @Test + void testInvalidCoordinateIds() throws Exception { + SimpleProblemCollector result = validate("invalid-coordinate-ids-pom.xml"); + + assertViolations(result, 0, 2, 0); + + assertEquals( + "'groupId' with value 'o/a/m' does not match a valid coordinate id pattern.", + result.getErrors().get(0)); + + assertEquals( + "'artifactId' with value 'm$-do$' does not match a valid coordinate id pattern.", + result.getErrors().get(1)); + } + + @Test + void testMissingType() throws Exception { + SimpleProblemCollector result = validate("missing-type-pom.xml"); + + assertViolations(result, 0, 1, 0); + + assertEquals("'packaging' is missing.", result.getErrors().get(0)); + } + + @Test + void testMissingVersion() throws Exception { + SimpleProblemCollector result = validate("missing-version-pom.xml"); + + assertViolations(result, 0, 1, 0); + + assertEquals("'version' is missing.", result.getErrors().get(0)); + } + + @Test + void testInvalidAggregatorPackaging() throws Exception { + SimpleProblemCollector result = validate("invalid-aggregator-packaging-pom.xml"); + + assertViolations(result, 0, 1, 0); + + assertTrue(result.getErrors().get(0).contains("Aggregator projects require 'pom' as packaging.")); + } + + @Test + void testMissingDependencyArtifactId() throws Exception { + SimpleProblemCollector result = validate("missing-dependency-artifactId-pom.xml"); + + assertViolations(result, 0, 1, 0); + + assertTrue(result.getErrors() + .get(0) + .contains("'dependencies.dependency.artifactId' for groupId:null:jar is missing")); + } + + @Test + void testMissingDependencyGroupId() throws Exception { + SimpleProblemCollector result = validate("missing-dependency-groupId-pom.xml"); + + assertViolations(result, 0, 1, 0); + + assertTrue(result.getErrors() + .get(0) + .contains("'dependencies.dependency.groupId' for null:artifactId:jar is missing")); + } + + @Test + void testMissingDependencyVersion() throws Exception { + SimpleProblemCollector result = validate("missing-dependency-version-pom.xml"); + + assertViolations(result, 0, 1, 0); + + assertTrue(result.getErrors() + .get(0) + .contains("'dependencies.dependency.version' for groupId:artifactId:jar is missing")); + } + + @Test + void testMissingDependencyManagementArtifactId() throws Exception { + SimpleProblemCollector result = validate("missing-dependency-mgmt-artifactId-pom.xml"); + + assertViolations(result, 0, 1, 0); + + assertTrue(result.getErrors() + .get(0) + .contains("'dependencyManagement.dependencies.dependency.artifactId' for groupId:null:jar is missing")); + } + + @Test + void testMissingDependencyManagementGroupId() throws Exception { + SimpleProblemCollector result = validate("missing-dependency-mgmt-groupId-pom.xml"); + + assertViolations(result, 0, 1, 0); + + assertTrue(result.getErrors() + .get(0) + .contains("'dependencyManagement.dependencies.dependency.groupId' for null:artifactId:jar is missing")); + } + + @Test + void testMissingAll() throws Exception { + SimpleProblemCollector result = validate("missing-1-pom.xml"); + + assertViolations(result, 0, 4, 0); + + List messages = result.getErrors(); + + assertTrue(messages.contains("'modelVersion' is missing.")); + assertTrue(messages.contains("'groupId' is missing.")); + assertTrue(messages.contains("'artifactId' is missing.")); + assertTrue(messages.contains("'version' is missing.")); + // type is inherited from the super pom + } + + @Test + void testMissingPluginArtifactId() throws Exception { + SimpleProblemCollector result = validate("missing-plugin-artifactId-pom.xml"); + + assertViolations(result, 0, 1, 0); + + assertEquals( + "'build.plugins.plugin.artifactId' is missing.", + result.getErrors().get(0)); + } + + @Test + void testEmptyPluginVersion() throws Exception { + SimpleProblemCollector result = validate("empty-plugin-version.xml"); + + assertViolations(result, 0, 1, 0); + + assertEquals( + "'build.plugins.plugin.version' for org.apache.maven.plugins:maven-it-plugin" + + " must be a valid version but is ''.", + result.getErrors().get(0)); + } + + @Test + void testMissingRepositoryId() throws Exception { + SimpleProblemCollector result = + validateFile("missing-repository-id-pom.xml", ModelValidator.VALIDATION_LEVEL_STRICT); + + assertViolations(result, 0, 4, 0); + + assertEquals( + "'repositories.repository.id' is missing.", result.getErrors().get(0)); + + assertEquals( + "'repositories.repository.[null].url' is missing.", + result.getErrors().get(1)); + + assertEquals( + "'pluginRepositories.pluginRepository.id' is missing.", + result.getErrors().get(2)); + + assertEquals( + "'pluginRepositories.pluginRepository.[null].url' is missing.", + result.getErrors().get(3)); + } + + @Test + void testMissingResourceDirectory() throws Exception { + SimpleProblemCollector result = validate("missing-resource-directory-pom.xml"); + + assertViolations(result, 0, 2, 0); + + assertEquals( + "'build.resources.resource.directory' is missing.", + result.getErrors().get(0)); + + assertEquals( + "'build.testResources.testResource.directory' is missing.", + result.getErrors().get(1)); + } + + @Test + void testBadPluginDependencyScope() throws Exception { + SimpleProblemCollector result = validate("bad-plugin-dependency-scope.xml"); + + assertViolations(result, 0, 3, 0); + + assertTrue(result.getErrors().get(0).contains("test:d")); + + assertTrue(result.getErrors().get(1).contains("test:e")); + + assertTrue(result.getErrors().get(2).contains("test:f")); + } + + @Test + void testBadDependencyScope() throws Exception { + SimpleProblemCollector result = validate("bad-dependency-scope.xml"); + + assertViolations(result, 0, 0, 2); + + assertTrue(result.getWarnings().get(0).contains("test:f")); + + assertTrue(result.getWarnings().get(1).contains("test:g")); + } + + @Test + void testBadDependencyManagementScope() throws Exception { + SimpleProblemCollector result = validate("bad-dependency-management-scope.xml"); + + assertViolations(result, 0, 0, 1); + + assertContains(result.getWarnings().get(0), "test:g"); + } + + @Test + void testBadDependencyVersion() throws Exception { + SimpleProblemCollector result = validate("bad-dependency-version.xml"); + + assertViolations(result, 0, 2, 0); + + assertContains( + result.getErrors().get(0), "'dependencies.dependency.version' for test:b:jar must be a valid version"); + assertContains( + result.getErrors().get(1), + "'dependencies.dependency.version' for test:c:jar must not contain any of these characters"); + } + + @Test + void testDuplicateModule() throws Exception { + SimpleProblemCollector result = validateFile("duplicate-module.xml"); + + assertViolations(result, 0, 1, 0); + + assertTrue(result.getErrors().get(0).contains("child")); + } + + @Test + void testInvalidProfileId() throws Exception { + SimpleProblemCollector result = validateFile("invalid-profile-ids.xml"); + + assertViolations(result, 0, 4, 0); + + assertTrue(result.getErrors().get(0).contains("+invalid-id")); + assertTrue(result.getErrors().get(1).contains("-invalid-id")); + assertTrue(result.getErrors().get(2).contains("!invalid-id")); + assertTrue(result.getErrors().get(3).contains("?invalid-id")); + } + + @Test + void testDuplicateProfileId() throws Exception { + SimpleProblemCollector result = validateFile("duplicate-profile-id.xml"); + + assertViolations(result, 0, 1, 0); + + assertTrue(result.getErrors().get(0).contains("non-unique-id")); + } + + @Test + void testBadPluginVersion() throws Exception { + SimpleProblemCollector result = validate("bad-plugin-version.xml"); + + assertViolations(result, 0, 4, 0); + + assertContains( + result.getErrors().get(0), "'build.plugins.plugin.version' for test:mip must be a valid version"); + assertContains( + result.getErrors().get(1), "'build.plugins.plugin.version' for test:rmv must be a valid version"); + assertContains( + result.getErrors().get(2), "'build.plugins.plugin.version' for test:lmv must be a valid version"); + assertContains( + result.getErrors().get(3), + "'build.plugins.plugin.version' for test:ifsc must not contain any of these characters"); + } + + @Test + void testDistributionManagementStatus() throws Exception { + SimpleProblemCollector result = validate("distribution-management-status.xml"); + + assertViolations(result, 0, 1, 0); + + assertTrue(result.getErrors().get(0).contains("distributionManagement.status")); + } + + @Test + void testIncompleteParent() throws Exception { + SimpleProblemCollector result = validateRaw("incomplete-parent.xml"); + + assertViolations(result, 3, 0, 0); + assertTrue(result.getFatals().get(0).contains("parent.groupId")); + assertTrue(result.getFatals().get(1).contains("parent.artifactId")); + assertTrue(result.getFatals().get(2).contains("parent.version")); + } + + @Test + void testHardCodedSystemPath() throws Exception { + SimpleProblemCollector result = validateFile("hard-coded-system-path.xml"); + + assertViolations(result, 0, 0, 3); + + assertContains( + result.getWarnings().get(0), + "'dependencies.dependency.scope' for test:a:jar declares usage of deprecated 'system' scope"); + assertContains( + result.getWarnings().get(1), + "'dependencies.dependency.systemPath' for test:a:jar should use a variable instead of a hard-coded path"); + assertContains( + result.getWarnings().get(2), + "'dependencies.dependency.scope' for test:b:jar declares usage of deprecated 'system' scope"); + } + + @Test + void testEmptyModule() throws Exception { + SimpleProblemCollector result = validate("empty-module.xml"); + + assertViolations(result, 0, 1, 0); + + assertTrue(result.getErrors().get(0).contains("'modules.module[0]' has been specified without a path")); + } + + @Test + void testDuplicatePlugin() throws Exception { + SimpleProblemCollector result = validateFile("duplicate-plugin.xml"); + + assertViolations(result, 0, 4, 0); + + 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 + void testDuplicatePluginExecution() throws Exception { + SimpleProblemCollector result = validateFile("duplicate-plugin-execution.xml"); + + assertViolations(result, 0, 4, 0); + + assertContains(result.getErrors().get(0), "duplicate execution with id a"); + assertContains(result.getErrors().get(1), "duplicate execution with id default"); + assertContains(result.getErrors().get(2), "duplicate execution with id c"); + assertContains(result.getErrors().get(3), "duplicate execution with id b"); + } + + @Test + void testReservedRepositoryId() throws Exception { + SimpleProblemCollector result = validate("reserved-repository-id.xml"); + + assertViolations(result, 0, 4, 0); + + 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'"); + } + + @Test + void testMissingPluginDependencyGroupId() throws Exception { + SimpleProblemCollector result = validate("missing-plugin-dependency-groupId.xml"); + + assertViolations(result, 0, 1, 0); + + assertTrue(result.getErrors().get(0).contains(":a:")); + } + + @Test + void testMissingPluginDependencyArtifactId() throws Exception { + SimpleProblemCollector result = validate("missing-plugin-dependency-artifactId.xml"); + + assertViolations(result, 0, 1, 0); + + assertTrue(result.getErrors().get(0).contains("test:")); + } + + @Test + void testMissingPluginDependencyVersion() throws Exception { + SimpleProblemCollector result = validate("missing-plugin-dependency-version.xml"); + + assertViolations(result, 0, 1, 0); + + assertTrue(result.getErrors().get(0).contains("test:a")); + } + + @Test + void testBadPluginDependencyVersion() throws Exception { + SimpleProblemCollector result = validate("bad-plugin-dependency-version.xml"); + + assertViolations(result, 0, 1, 0); + + assertTrue(result.getErrors().get(0).contains("test:b")); + } + + @Test + void testBadVersion() throws Exception { + SimpleProblemCollector result = validate("bad-version.xml"); + + assertViolations(result, 0, 1, 0); + + assertContains(result.getErrors().get(0), "'version' must not contain any of these characters"); + } + + @Test + void testBadSnapshotVersion() throws Exception { + SimpleProblemCollector result = validate("bad-snapshot-version.xml"); + + assertViolations(result, 0, 1, 0); + + assertContains(result.getErrors().get(0), "'version' uses an unsupported snapshot version format"); + } + + @Test + void testBadRepositoryId() throws Exception { + SimpleProblemCollector result = validate("bad-repository-id.xml"); + + assertViolations(result, 0, 4, 0); + + assertContains( + result.getErrors().get(0), "'repositories.repository.id' must not contain any of these characters"); + assertContains( + result.getErrors().get(1), + "'pluginRepositories.pluginRepository.id' must not contain any of these characters"); + assertContains( + result.getErrors().get(2), + "'distributionManagement.repository.id' must not contain any of these characters"); + assertContains( + result.getErrors().get(3), + "'distributionManagement.snapshotRepository.id' must not contain any of these characters"); + } + + @Test + void testBadDependencyExclusionId() throws Exception { + SimpleProblemCollector result = + validateEffective("bad-dependency-exclusion-id.xml", ModelValidator.VALIDATION_LEVEL_MAVEN_2_0); + + assertViolations(result, 0, 0, 2); + + assertContains( + result.getWarnings().get(0), "'dependencies.dependency.exclusions.exclusion.groupId' for gid:aid:jar"); + assertContains( + result.getWarnings().get(1), + "'dependencies.dependency.exclusions.exclusion.artifactId' for gid:aid:jar"); + + // MNG-3832: Aether (part of M3+) supports wildcard expressions for exclusions + + SimpleProblemCollector result_30 = validate("bad-dependency-exclusion-id.xml"); + + assertViolations(result_30, 0, 0, 0); + } + + @Test + void testMissingDependencyExclusionId() throws Exception { + SimpleProblemCollector result = validate("missing-dependency-exclusion-id.xml"); + + assertViolations(result, 0, 0, 2); + + assertContains( + result.getWarnings().get(0), + "'dependencies.dependency.exclusions.exclusion.groupId' for gid:aid:jar is missing"); + assertContains( + result.getWarnings().get(1), + "'dependencies.dependency.exclusions.exclusion.artifactId' for gid:aid:jar is missing"); + } + + @Test + void testBadImportScopeType() throws Exception { + SimpleProblemCollector result = validateFile("bad-import-scope-type.xml"); + + assertViolations(result, 0, 0, 1); + + assertContains( + result.getWarnings().get(0), + "'dependencyManagement.dependencies.dependency.type' for test:a:jar must be 'pom'"); + } + + @Test + void testBadImportScopeClassifier() throws Exception { + SimpleProblemCollector result = validateFile("bad-import-scope-classifier.xml"); + + assertViolations(result, 0, 1, 0); + + assertContains( + result.getErrors().get(0), + "'dependencyManagement.dependencies.dependency.classifier' for test:a:pom:cls must be empty"); + } + + @Test + void testSystemPathRefersToProjectBasedir() throws Exception { + SimpleProblemCollector result = validateFile("basedir-system-path.xml"); + + assertViolations(result, 0, 0, 4); + + assertContains( + result.getWarnings().get(0), + "'dependencies.dependency.scope' for test:a:jar declares usage of deprecated 'system' scope"); + assertContains( + result.getWarnings().get(1), + "'dependencies.dependency.systemPath' for test:a:jar should not point at files within the project directory"); + assertContains( + result.getWarnings().get(2), + "'dependencies.dependency.scope' for test:b:jar declares usage of deprecated 'system' scope"); + assertContains( + result.getWarnings().get(3), + "'dependencies.dependency.systemPath' for test:b:jar should not point at files within the project directory"); + } + + @Test + void testInvalidVersionInPluginManagement() throws Exception { + SimpleProblemCollector result = validateFile("raw-model/missing-plugin-version-pluginManagement.xml"); + + assertViolations(result, 1, 0, 0); + + assertEquals( + "'build.pluginManagement.plugins.plugin.(groupId:artifactId)' version of a plugin must be defined. ", + result.getFatals().get(0)); + } + + @Test + void testInvalidGroupIdInPluginManagement() throws Exception { + SimpleProblemCollector result = validateFile("raw-model/missing-groupId-pluginManagement.xml"); + + assertViolations(result, 1, 0, 0); + + assertEquals( + "'build.pluginManagement.plugins.plugin.(groupId:artifactId)' groupId of a plugin must be defined. ", + result.getFatals().get(0)); + } + + @Test + void testInvalidArtifactIdInPluginManagement() throws Exception { + SimpleProblemCollector result = validateFile("raw-model/missing-artifactId-pluginManagement.xml"); + + assertViolations(result, 1, 0, 0); + + assertEquals( + "'build.pluginManagement.plugins.plugin.(groupId:artifactId)' artifactId of a plugin must be defined. ", + result.getFatals().get(0)); + } + + @Test + void testInvalidGroupAndArtifactIdInPluginManagement() throws Exception { + SimpleProblemCollector result = validateFile("raw-model/missing-ga-pluginManagement.xml"); + + assertViolations(result, 2, 0, 0); + + assertEquals( + "'build.pluginManagement.plugins.plugin.(groupId:artifactId)' groupId of a plugin must be defined. ", + result.getFatals().get(0)); + + assertEquals( + "'build.pluginManagement.plugins.plugin.(groupId:artifactId)' artifactId of a plugin must be defined. ", + result.getFatals().get(1)); + } + + @Test + void testMissingReportPluginVersion() throws Exception { + SimpleProblemCollector result = validate("missing-report-version-pom.xml"); + + assertViolations(result, 0, 0, 0); + } + + @Test + void testDeprecatedDependencyMetaversionsLatestAndRelease() throws Exception { + SimpleProblemCollector result = validateFile("deprecated-dependency-metaversions-latest-and-release.xml"); + + assertViolations(result, 0, 0, 2); + + assertContains( + result.getWarnings().get(0), + "'dependencies.dependency.version' for test:a:jar is either LATEST or RELEASE (both of them are being deprecated)"); + assertContains( + result.getWarnings().get(1), + "'dependencies.dependency.version' for test:b:jar is either LATEST or RELEASE (both of them are being deprecated)"); + } + + @Test + void testSelfReferencingDependencyInRawModel() throws Exception { + SimpleProblemCollector result = validateFile("raw-model/self-referencing.xml"); + + assertViolations(result, 1, 0, 0); + + assertEquals( + "'dependencies.dependency[com.example.group:testinvalidpom:0.0.1-SNAPSHOT]' for com.example.group:testinvalidpom:0.0.1-SNAPSHOT is referencing itself.", + result.getFatals().get(0)); + } + + @Test + void testSelfReferencingDependencyWithClassifierInRawModel() throws Exception { + SimpleProblemCollector result = validateRaw("raw-model/self-referencing-classifier.xml"); + + assertViolations(result, 0, 0, 0); + } + + @Test + void testCiFriendlySha1() throws Exception { + SimpleProblemCollector result = validateRaw("raw-model/ok-ci-friendly-sha1.xml"); + assertViolations(result, 0, 0, 0); + } + + @Test + void testCiFriendlyRevision() throws Exception { + SimpleProblemCollector result = validateRaw("raw-model/ok-ci-friendly-revision.xml"); + assertViolations(result, 0, 0, 0); + } + + @Test + void testCiFriendlyChangeList() throws Exception { + SimpleProblemCollector result = validateRaw("raw-model/ok-ci-friendly-changelist.xml"); + assertViolations(result, 0, 0, 0); + } + + @Test + void testCiFriendlyAllExpressions() throws Exception { + SimpleProblemCollector result = validateRaw("raw-model/ok-ci-friendly-all-expressions.xml"); + assertViolations(result, 0, 0, 0); + } + + @Test + void testCiFriendlyBad() throws Exception { + SimpleProblemCollector result = validateFile("raw-model/bad-ci-friendly.xml"); + assertViolations(result, 0, 0, 1); + assertEquals( + "'version' contains an expression but should be a constant.", + result.getWarnings().get(0)); + } + + @Test + void testCiFriendlyBadSha1Plus() throws Exception { + SimpleProblemCollector result = validateFile("raw-model/bad-ci-friendly-sha1plus.xml"); + assertViolations(result, 0, 0, 1); + assertEquals( + "'version' contains an expression but should be a constant.", + result.getWarnings().get(0)); + } + + @Test + void testCiFriendlyBadSha1Plus2() throws Exception { + SimpleProblemCollector result = validateFile("raw-model/bad-ci-friendly-sha1plus2.xml"); + assertViolations(result, 0, 0, 1); + assertEquals( + "'version' contains an expression but should be a constant.", + result.getWarnings().get(0)); + } + + @Test + void testParentVersionLATEST() throws Exception { + SimpleProblemCollector result = validateRaw("raw-model/bad-parent-version-latest.xml"); + assertViolations(result, 0, 0, 1); + assertEquals( + "'parent.version' is either LATEST or RELEASE (both of them are being deprecated)", + result.getWarnings().get(0)); + } + + @Test + void testParentVersionRELEASE() throws Exception { + SimpleProblemCollector result = validateRaw("raw-model/bad-parent-version-release.xml"); + assertViolations(result, 0, 0, 1); + assertEquals( + "'parent.version' is either LATEST or RELEASE (both of them are being deprecated)", + result.getWarnings().get(0)); + } + + @Test + void repositoryWithExpression() throws Exception { + SimpleProblemCollector result = validateFile("raw-model/repository-with-expression.xml"); + assertViolations(result, 0, 1, 0); + assertEquals( + "'repositories.repository.[repo].url' contains an expression but should be a constant.", + result.getErrors().get(0)); + } + + @Test + void repositoryWithBasedirExpression() throws Exception { + SimpleProblemCollector result = validateRaw("raw-model/repository-with-basedir-expression.xml"); + assertViolations(result, 0, 0, 0); + } + + @Test + void profileActivationWithAllowedExpression() throws Exception { + SimpleProblemCollector result = validateRaw( + "raw-model/profile-activation-file-with-allowed-expressions.xml", + ModelValidator.VALIDATION_LEVEL_STRICT); + // mbr -> mbr.userProperties( + // Map.of("foo", "foo", "bar", "foo"))); + assertViolations(result, 0, 0, 0); + } + + @Test + void profileActivationFileWithProjectExpression() throws Exception { + SimpleProblemCollector result = validateFile("raw-model/profile-activation-file-with-project-expressions.xml"); + assertViolations(result, 0, 0, 2); + + assertEquals( + "'profiles.profile[exists-project-version].activation.file.exists' " + + "Failed to interpolate profile activation property ${project.version}/test.txt: " + + "${project.version} expressions are not supported during profile activation.", + result.getWarnings().get(0)); + + assertEquals( + "'profiles.profile[missing-project-version].activation.file.missing' " + + "Failed to interpolate profile activation property ${project.version}/test.txt: " + + "${project.version} expressions are not supported during profile activation.", + result.getWarnings().get(1)); + } + + @Test + void profileActivationPropertyWithProjectExpression() throws Exception { + SimpleProblemCollector result = + validateFile("raw-model/profile-activation-property-with-project-expressions.xml"); + assertViolations(result, 0, 0, 2); + + assertEquals( + "'profiles.profile[property-name-project-version].activation.property.name' " + + "Failed to interpolate profile activation property ${project.version}: " + + "${project.version} expressions are not supported during profile activation.", + result.getWarnings().get(0)); + + assertEquals( + "'profiles.profile[property-value-project-version].activation.property.value' " + + "Failed to interpolate profile activation property ${project.version}: " + + "${project.version} expressions are not supported during profile activation.", + result.getWarnings().get(1)); + } +} diff --git a/impl/maven-impl/src/test/resources/poms/validation/bad-dependency-exclusion-id.xml b/impl/maven-impl/src/test/resources/poms/validation/bad-dependency-exclusion-id.xml new file mode 100644 index 0000000000..1e02b15430 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/bad-dependency-exclusion-id.xml @@ -0,0 +1,40 @@ + + + + 4.0.0 + foo + foo + 99.44 + jar + + + + gid + aid + 1.0 + + + test? + * + + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/bad-dependency-management-scope.xml b/impl/maven-impl/src/test/resources/poms/validation/bad-dependency-management-scope.xml new file mode 100644 index 0000000000..be0726743b --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/bad-dependency-management-scope.xml @@ -0,0 +1,72 @@ + + + + 4.0.0 + aid + gid + 0.1 + + + + + test + a + 0.2 + + + test + b + 0.2 + compile + + + test + c + 0.2 + runtime + + + test + d + 0.2 + test + + + test + e + 0.2 + provided + + + test + f + 0.2 + import + + + test + g + 1 + pom + include + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/bad-dependency-scope.xml b/impl/maven-impl/src/test/resources/poms/validation/bad-dependency-scope.xml new file mode 100644 index 0000000000..0ae0b45ff6 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/bad-dependency-scope.xml @@ -0,0 +1,69 @@ + + + + 4.0.0 + aid + gid + 0.1 + + + + test + a + 0.2 + + + test + b + 0.2 + compile + + + test + c + 0.2 + runtime + + + test + d + 0.2 + test + + + test + e + 0.2 + provided + + + test + f + 0.2 + import + + + test + g + 0.2 + optional + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/bad-dependency-version.xml b/impl/maven-impl/src/test/resources/poms/validation/bad-dependency-version.xml new file mode 100644 index 0000000000..cb75e7b7a5 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/bad-dependency-version.xml @@ -0,0 +1,43 @@ + + + + 4.0.0 + aid + gid + 0.1 + + + + test + a + 0.2 + + + test + b + ${missing.property} + + + test + c + 1/1 + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/bad-import-scope-classifier.xml b/impl/maven-impl/src/test/resources/poms/validation/bad-import-scope-classifier.xml new file mode 100644 index 0000000000..833134511d --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/bad-import-scope-classifier.xml @@ -0,0 +1,38 @@ + + + + 4.0.0 + aid + gid + 0.1 + + + + + test + a + 0.1 + import + pom + cls + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/bad-import-scope-type.xml b/impl/maven-impl/src/test/resources/poms/validation/bad-import-scope-type.xml new file mode 100644 index 0000000000..fb505c5429 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/bad-import-scope-type.xml @@ -0,0 +1,37 @@ + + + + 4.0.0 + aid + gid + 0.1 + + + + + test + a + 0.1 + import + + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/bad-modelVersion.xml b/impl/maven-impl/src/test/resources/poms/validation/bad-modelVersion.xml new file mode 100644 index 0000000000..1f381b3bec --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/bad-modelVersion.xml @@ -0,0 +1,25 @@ + + + + 99.0.0 + foo + bar + 0.1 + diff --git a/impl/maven-impl/src/test/resources/poms/validation/bad-plugin-dependency-scope.xml b/impl/maven-impl/src/test/resources/poms/validation/bad-plugin-dependency-scope.xml new file mode 100644 index 0000000000..3b06e620b3 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/bad-plugin-dependency-scope.xml @@ -0,0 +1,70 @@ + + + + 4.0.0 + aid + gid + 0.1 + + + + maven-it-plugin + 0.1 + + + test + a + 0.2 + + + test + b + 0.2 + compile + + + test + c + 0.2 + runtime + + + test + d + 0.2 + test + + + test + e + 0.2 + provided + + + test + f + 0.2 + import + + + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/bad-plugin-dependency-version.xml b/impl/maven-impl/src/test/resources/poms/validation/bad-plugin-dependency-version.xml new file mode 100644 index 0000000000..6438252945 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/bad-plugin-dependency-version.xml @@ -0,0 +1,46 @@ + + + + 4.0.0 + aid + gid + 0.1 + + + + + maven-it-plugin + 1.0 + + + test + a + 0.1 + + + test + b + ${missing.property} + + + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/bad-plugin-version.xml b/impl/maven-impl/src/test/resources/poms/validation/bad-plugin-version.xml new file mode 100644 index 0000000000..2ca936aa46 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/bad-plugin-version.xml @@ -0,0 +1,55 @@ + + + + 4.0.0 + aid + gid + 0.1 + + + + + test + good + 1.0 + + + test + mip + ${missing.property} + + + test + rmv + RELEASE + + + test + lmv + LATEST + + + test + ifsc + 1/1 + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/bad-repository-id.xml b/impl/maven-impl/src/test/resources/poms/validation/bad-repository-id.xml new file mode 100644 index 0000000000..70553eb3fd --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/bad-repository-id.xml @@ -0,0 +1,50 @@ + + + + 4.0.0 + + gid + aid + 1.0 + + + + this/is\bad + http://localhost + + + + + this/is\bad + http://localhost + + + + + + this/is\bad + http://localhost + + + this/is\bad + http://localhost + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/bad-snapshot-version.xml b/impl/maven-impl/src/test/resources/poms/validation/bad-snapshot-version.xml new file mode 100644 index 0000000000..70b5ddcbef --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/bad-snapshot-version.xml @@ -0,0 +1,25 @@ + + + + 4.0.0 + foo + bar + 1.2.3.SNAPSHOT + diff --git a/impl/maven-impl/src/test/resources/poms/validation/bad-version.xml b/impl/maven-impl/src/test/resources/poms/validation/bad-version.xml new file mode 100644 index 0000000000..bf6a1fc81f --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/bad-version.xml @@ -0,0 +1,25 @@ + + + + 4.0.0 + foo + bar + this\is/bad + diff --git a/impl/maven-impl/src/test/resources/poms/validation/basedir-system-path.xml b/impl/maven-impl/src/test/resources/poms/validation/basedir-system-path.xml new file mode 100644 index 0000000000..24d49d3d21 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/basedir-system-path.xml @@ -0,0 +1,42 @@ + + + + 4.0.0 + aid + gid + 0.1 + + + + test + a + 0.2 + system + ${basedir}/lib/a.jar + + + test + b + 0.1 + system + ${project.basedir}/lib/b.jar + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/deprecated-dependency-metaversions-latest-and-release.xml b/impl/maven-impl/src/test/resources/poms/validation/deprecated-dependency-metaversions-latest-and-release.xml new file mode 100644 index 0000000000..eba532bd9c --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/deprecated-dependency-metaversions-latest-and-release.xml @@ -0,0 +1,38 @@ + + + + 4.0.0 + gid + aid + 0.1 + + + + test + a + LATEST + + + test + b + RELEASE + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/distribution-management-status.xml b/impl/maven-impl/src/test/resources/poms/validation/distribution-management-status.xml new file mode 100644 index 0000000000..3a5968b063 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/distribution-management-status.xml @@ -0,0 +1,29 @@ + + + + 4.0.0 + foo + bar + 0.1 + + + generated + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/duplicate-module.xml b/impl/maven-impl/src/test/resources/poms/validation/duplicate-module.xml new file mode 100644 index 0000000000..d3ef528fc9 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/duplicate-module.xml @@ -0,0 +1,31 @@ + + + + 4.0.0 + aid + gid + 0.1 + pom + + + child + child + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/duplicate-plugin-execution.xml b/impl/maven-impl/src/test/resources/poms/validation/duplicate-plugin-execution.xml new file mode 100644 index 0000000000..0d4256de25 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/duplicate-plugin-execution.xml @@ -0,0 +1,103 @@ + + + + 4.0.0 + aid + gid + 0.1 + pom + + + + + + build + managed-plugin + + + test + + + test + + + + + + + + build + plugin + + + a + test + + + a + test + + + + + + + + + test + + + + + profile + managed-plugin + + + b + test + + + b + test + + + + + + + + profile + plugin + + + c + test + + + c + test + + + + + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/duplicate-plugin.xml b/impl/maven-impl/src/test/resources/poms/validation/duplicate-plugin.xml new file mode 100644 index 0000000000..06a6a65776 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/duplicate-plugin.xml @@ -0,0 +1,81 @@ + + + + 4.0.0 + aid + gid + 0.1 + pom + + + + + + test + managed-duplicate + + + test + managed-duplicate + + + + + + test + duplicate + + + test + duplicate + + + + + + + test + + + + + profile + managed-duplicate + + + profile + managed-duplicate + + + + + + profile + duplicate + + + profile + duplicate + + + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/duplicate-profile-id.xml b/impl/maven-impl/src/test/resources/poms/validation/duplicate-profile-id.xml new file mode 100644 index 0000000000..2379c3dbdf --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/duplicate-profile-id.xml @@ -0,0 +1,35 @@ + + + + 4.0.0 + aid + gid + 0.1 + pom + + + + non-unique-id + + + non-unique-id + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/empty-module.xml b/impl/maven-impl/src/test/resources/poms/validation/empty-module.xml new file mode 100644 index 0000000000..f7a91d1d69 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/empty-module.xml @@ -0,0 +1,30 @@ + + + + 4.0.0 + aid + gid + 0.1 + pom + + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/empty-plugin-version.xml b/impl/maven-impl/src/test/resources/poms/validation/empty-plugin-version.xml new file mode 100644 index 0000000000..340efc5cd3 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/empty-plugin-version.xml @@ -0,0 +1,34 @@ + + + + 4.0.0 + foo + bar + 1.0 + pack + + + + maven-it-plugin + + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/hard-coded-system-path.xml b/impl/maven-impl/src/test/resources/poms/validation/hard-coded-system-path.xml new file mode 100644 index 0000000000..b5a4dd679c --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/hard-coded-system-path.xml @@ -0,0 +1,42 @@ + + + + 4.0.0 + aid + gid + 0.1 + + + + test + a + 0.2 + system + should-use-variables-and-not-hard-code-this-path + + + test + b + 0.1 + system + ${java.home}/lib/good.jar + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/incomplete-parent.xml b/impl/maven-impl/src/test/resources/poms/validation/incomplete-parent.xml new file mode 100644 index 0000000000..2fc94d57d3 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/incomplete-parent.xml @@ -0,0 +1,30 @@ + + + + 4.0.0 + + + + + + aid + gid + 0.1 + diff --git a/impl/maven-impl/src/test/resources/poms/validation/invalid-aggregator-packaging-pom.xml b/impl/maven-impl/src/test/resources/poms/validation/invalid-aggregator-packaging-pom.xml new file mode 100644 index 0000000000..977f5db4e5 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/invalid-aggregator-packaging-pom.xml @@ -0,0 +1,30 @@ + + + + 4.0.0 + foo + foo + 99.44 + bleh + + + test-module + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/invalid-coordinate-ids-pom.xml b/impl/maven-impl/src/test/resources/poms/validation/invalid-coordinate-ids-pom.xml new file mode 100644 index 0000000000..bbb8e9c841 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/invalid-coordinate-ids-pom.xml @@ -0,0 +1,26 @@ + + + + 4.0.0 + o/a/m + m$-do$ + 99.44 + bleh + diff --git a/impl/maven-impl/src/test/resources/poms/validation/invalid-profile-ids.xml b/impl/maven-impl/src/test/resources/poms/validation/invalid-profile-ids.xml new file mode 100644 index 0000000000..74b670b9d5 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/invalid-profile-ids.xml @@ -0,0 +1,47 @@ + + + + 4.0.0 + aid + gid + 0.1 + pom + + + + +invalid-id + + + -invalid-id + + + !invalid-id + + + ?invalid-id + + + valid-id + + + valid?-jdk9+! + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/missing-1-pom.xml b/impl/maven-impl/src/test/resources/poms/validation/missing-1-pom.xml new file mode 100644 index 0000000000..fe297e6e58 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/missing-1-pom.xml @@ -0,0 +1,21 @@ + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/missing-artifactId-pom.xml b/impl/maven-impl/src/test/resources/poms/validation/missing-artifactId-pom.xml new file mode 100644 index 0000000000..39f0d7bcba --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/missing-artifactId-pom.xml @@ -0,0 +1,25 @@ + + + + 4.0.0 + foo + 99.44 + bleh + diff --git a/impl/maven-impl/src/test/resources/poms/validation/missing-dependency-artifactId-pom.xml b/impl/maven-impl/src/test/resources/poms/validation/missing-dependency-artifactId-pom.xml new file mode 100644 index 0000000000..3a5b647990 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/missing-dependency-artifactId-pom.xml @@ -0,0 +1,32 @@ + + + + 4.0.0 + foo + foo + 99.44 + bleh + + + groupId + 1.0 + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/missing-dependency-exclusion-id.xml b/impl/maven-impl/src/test/resources/poms/validation/missing-dependency-exclusion-id.xml new file mode 100644 index 0000000000..b9baada18a --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/missing-dependency-exclusion-id.xml @@ -0,0 +1,39 @@ + + + + 4.0.0 + foo + foo + 99.44 + jar + + + + gid + aid + 1.0 + + + + + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/missing-dependency-groupId-pom.xml b/impl/maven-impl/src/test/resources/poms/validation/missing-dependency-groupId-pom.xml new file mode 100644 index 0000000000..5799c572cb --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/missing-dependency-groupId-pom.xml @@ -0,0 +1,32 @@ + + + + 4.0.0 + foo + foo + 99.44 + bleh + + + artifactId + 1.0 + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/missing-dependency-mgmt-artifactId-pom.xml b/impl/maven-impl/src/test/resources/poms/validation/missing-dependency-mgmt-artifactId-pom.xml new file mode 100644 index 0000000000..e050ef43d8 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/missing-dependency-mgmt-artifactId-pom.xml @@ -0,0 +1,34 @@ + + + + 4.0.0 + foo + foo + 99.44 + bleh + + + + groupId + version + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/missing-dependency-mgmt-groupId-pom.xml b/impl/maven-impl/src/test/resources/poms/validation/missing-dependency-mgmt-groupId-pom.xml new file mode 100644 index 0000000000..a012d0f5d9 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/missing-dependency-mgmt-groupId-pom.xml @@ -0,0 +1,34 @@ + + + + 4.0.0 + foo + foo + 99.44 + bleh + + + + artifactId + version + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/missing-dependency-mgmt-version-pom.xml b/impl/maven-impl/src/test/resources/poms/validation/missing-dependency-mgmt-version-pom.xml new file mode 100644 index 0000000000..cc5ff5b3c1 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/missing-dependency-mgmt-version-pom.xml @@ -0,0 +1,34 @@ + + + + 4.0.0 + foo + foo + 99.44 + bleh + + + + artifactId + groupId + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/missing-dependency-version-pom.xml b/impl/maven-impl/src/test/resources/poms/validation/missing-dependency-version-pom.xml new file mode 100644 index 0000000000..217b036d81 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/missing-dependency-version-pom.xml @@ -0,0 +1,32 @@ + + + + 4.0.0 + foo + foo + 99.44 + bleh + + + artifactId + groupId + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/missing-groupId-pom.xml b/impl/maven-impl/src/test/resources/poms/validation/missing-groupId-pom.xml new file mode 100644 index 0000000000..528b8b6a19 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/missing-groupId-pom.xml @@ -0,0 +1,25 @@ + + + + 4.0.0 + bar + 99.44 + bleh + diff --git a/impl/maven-impl/src/test/resources/poms/validation/missing-modelVersion-pom.xml b/impl/maven-impl/src/test/resources/poms/validation/missing-modelVersion-pom.xml new file mode 100644 index 0000000000..f0273d9e60 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/missing-modelVersion-pom.xml @@ -0,0 +1,25 @@ + + + + foo + foo + 99.44 + bleh + diff --git a/impl/maven-impl/src/test/resources/poms/validation/missing-plugin-artifactId-pom.xml b/impl/maven-impl/src/test/resources/poms/validation/missing-plugin-artifactId-pom.xml new file mode 100644 index 0000000000..27e27d6b83 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/missing-plugin-artifactId-pom.xml @@ -0,0 +1,33 @@ + + + + 4.0.0 + foo + foo + 99.44 + bleh + + + + 1.0 + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/missing-plugin-dependency-artifactId.xml b/impl/maven-impl/src/test/resources/poms/validation/missing-plugin-dependency-artifactId.xml new file mode 100644 index 0000000000..5c21e363de --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/missing-plugin-dependency-artifactId.xml @@ -0,0 +1,41 @@ + + + + 4.0.0 + aid + gid + 1.0 + + + + + maven-it-plugin + 1.0 + + + test + + 2.0 + + + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/missing-plugin-dependency-groupId.xml b/impl/maven-impl/src/test/resources/poms/validation/missing-plugin-dependency-groupId.xml new file mode 100644 index 0000000000..eaf4a97126 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/missing-plugin-dependency-groupId.xml @@ -0,0 +1,41 @@ + + + + 4.0.0 + aid + gid + 1.0 + + + + + maven-it-plugin + 1.0 + + + + a + 2.0 + + + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/missing-plugin-dependency-version.xml b/impl/maven-impl/src/test/resources/poms/validation/missing-plugin-dependency-version.xml new file mode 100644 index 0000000000..29e0b7e789 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/missing-plugin-dependency-version.xml @@ -0,0 +1,41 @@ + + + + 4.0.0 + aid + gid + 1.0 + + + + + maven-it-plugin + 1.0 + + + test + a + + + + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/missing-plugin-version-pom.xml b/impl/maven-impl/src/test/resources/poms/validation/missing-plugin-version-pom.xml new file mode 100644 index 0000000000..b0ea7aa7f5 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/missing-plugin-version-pom.xml @@ -0,0 +1,33 @@ + + + + 4.0.0 + foo + foo + 99.44 + bleh + + + + maven-it-plugin + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/missing-report-artifactId-pom.xml b/impl/maven-impl/src/test/resources/poms/validation/missing-report-artifactId-pom.xml new file mode 100644 index 0000000000..4cb5649c1d --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/missing-report-artifactId-pom.xml @@ -0,0 +1,33 @@ + + + + 4.0.0 + foo + foo + 99.44 + bleh + + + + + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/missing-report-version-pom.xml b/impl/maven-impl/src/test/resources/poms/validation/missing-report-version-pom.xml new file mode 100644 index 0000000000..46a560f6bc --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/missing-report-version-pom.xml @@ -0,0 +1,57 @@ + + + + 4.0.0 + foo + foo + 99.44 + bleh + + + + + + maven-from-pluginManagement-plugin + 1.0 + + + + + + maven-from-plugins-plugin + 1.0 + + + + + + + + maven-noversion-plugin + + + maven-from-plugins-plugin + + + maven-from-pluginManagement-plugin + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/missing-repository-id-pom.xml b/impl/maven-impl/src/test/resources/poms/validation/missing-repository-id-pom.xml new file mode 100644 index 0000000000..1d385f2969 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/missing-repository-id-pom.xml @@ -0,0 +1,36 @@ + + + + 4.0.0 + foo + foo + 99.44 + bleh + + + + + + + + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/missing-resource-directory-pom.xml b/impl/maven-impl/src/test/resources/poms/validation/missing-resource-directory-pom.xml new file mode 100644 index 0000000000..232db095eb --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/missing-resource-directory-pom.xml @@ -0,0 +1,38 @@ + + + + 4.0.0 + foo + foo + 99.44 + bleh + + + + + + + + + + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/missing-type-pom.xml b/impl/maven-impl/src/test/resources/poms/validation/missing-type-pom.xml new file mode 100644 index 0000000000..663e58add5 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/missing-type-pom.xml @@ -0,0 +1,26 @@ + + + + 4.0.0 + foo + bar + 99.44 + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/missing-version-pom.xml b/impl/maven-impl/src/test/resources/poms/validation/missing-version-pom.xml new file mode 100644 index 0000000000..2a111f191d --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/missing-version-pom.xml @@ -0,0 +1,25 @@ + + + + 4.0.0 + foo + bar + bleh + diff --git a/impl/maven-impl/src/test/resources/poms/validation/modelVersion-4_0.xml b/impl/maven-impl/src/test/resources/poms/validation/modelVersion-4_0.xml new file mode 100644 index 0000000000..544331b1f1 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/modelVersion-4_0.xml @@ -0,0 +1,25 @@ + + + + 4.0 + foo + bar + 0.1 + diff --git a/impl/maven-impl/src/test/resources/poms/validation/raw-model/bad-ci-friendly-sha1plus.xml b/impl/maven-impl/src/test/resources/poms/validation/raw-model/bad-ci-friendly-sha1plus.xml new file mode 100644 index 0000000000..8276c94e61 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/raw-model/bad-ci-friendly-sha1plus.xml @@ -0,0 +1,31 @@ + + + + 4.0.0 + com.example.group + valid-version-sha1plus + ${sha1}${wrong} + + + This will test if the validation for the ci friendly versions + is working correct. + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/raw-model/bad-ci-friendly-sha1plus2.xml b/impl/maven-impl/src/test/resources/poms/validation/raw-model/bad-ci-friendly-sha1plus2.xml new file mode 100644 index 0000000000..247b326da0 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/raw-model/bad-ci-friendly-sha1plus2.xml @@ -0,0 +1,31 @@ + + + + 4.0.0 + com.example.group + valid-version-sha1plus + ${sha1}${wrong}${revision} + + + This will test if the validation for the ci friendly versions + is working correct. + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/raw-model/bad-ci-friendly.xml b/impl/maven-impl/src/test/resources/poms/validation/raw-model/bad-ci-friendly.xml new file mode 100644 index 0000000000..0ef3def9af --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/raw-model/bad-ci-friendly.xml @@ -0,0 +1,31 @@ + + + + 4.0.0 + com.example.group + valid-version-wrong + ${wrong} + + + This will test if the validation for the ci friendly versions + is working correct. + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/raw-model/bad-parent-version-latest.xml b/impl/maven-impl/src/test/resources/poms/validation/raw-model/bad-parent-version-latest.xml new file mode 100644 index 0000000000..5782f99ba9 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/raw-model/bad-parent-version-latest.xml @@ -0,0 +1,37 @@ + + + + 4.0.0 + + + com.example.group + com-parent + LATEST + + com.example.group + valid-version-wrong + 1.0 + + + This will test if the validation for the parent version + is working correct in case of usage of LATEST + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/raw-model/bad-parent-version-release.xml b/impl/maven-impl/src/test/resources/poms/validation/raw-model/bad-parent-version-release.xml new file mode 100644 index 0000000000..13cd42aa53 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/raw-model/bad-parent-version-release.xml @@ -0,0 +1,37 @@ + + + + 4.0.0 + + + com.example.group + com-parent + RELEASE + + com.example.group + valid-version-wrong + 1.0 + + + This will test if the validation for the parent version + is working correct in case of usage of RELEASE + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/raw-model/missing-artifactId-pluginManagement.xml b/impl/maven-impl/src/test/resources/poms/validation/raw-model/missing-artifactId-pluginManagement.xml new file mode 100644 index 0000000000..658f3305b5 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/raw-model/missing-artifactId-pluginManagement.xml @@ -0,0 +1,39 @@ + + + + 4.0.0 + com.example.group + testinvalidpom + 0.0.1-SNAPSHOT + + + + + + the.groupId.Of.This.Plugin + + + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/raw-model/missing-ga-pluginManagement.xml b/impl/maven-impl/src/test/resources/poms/validation/raw-model/missing-ga-pluginManagement.xml new file mode 100644 index 0000000000..27c6152318 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/raw-model/missing-ga-pluginManagement.xml @@ -0,0 +1,39 @@ + + + + 4.0.0 + com.example.group + testinvalidpom + 0.0.1-SNAPSHOT + + + + + + + + + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/raw-model/missing-groupId-pluginManagement.xml b/impl/maven-impl/src/test/resources/poms/validation/raw-model/missing-groupId-pluginManagement.xml new file mode 100644 index 0000000000..290550337f --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/raw-model/missing-groupId-pluginManagement.xml @@ -0,0 +1,39 @@ + + + + 4.0.0 + com.example.group + testinvalidpom + 0.0.1-SNAPSHOT + + + + + + + this-is-the-artifact + + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/raw-model/missing-plugin-version-pluginManagement.xml b/impl/maven-impl/src/test/resources/poms/validation/raw-model/missing-plugin-version-pluginManagement.xml new file mode 100644 index 0000000000..b1bc5e3257 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/raw-model/missing-plugin-version-pluginManagement.xml @@ -0,0 +1,40 @@ + + + + 4.0.0 + com.example.group + testinvalidpom + 0.0.1-SNAPSHOT + + + + + + the.group.id + the.artifact + + + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/raw-model/ok-ci-friendly-all-expressions.xml b/impl/maven-impl/src/test/resources/poms/validation/raw-model/ok-ci-friendly-all-expressions.xml new file mode 100644 index 0000000000..3eefb15e68 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/raw-model/ok-ci-friendly-all-expressions.xml @@ -0,0 +1,31 @@ + + + + 4.0.0 + com.example.group + valid-version-sha1 + ${revision}${changelist}${sha1} + + + This will test if the validation for the ci friendly versions + is working correct. + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/raw-model/ok-ci-friendly-changelist.xml b/impl/maven-impl/src/test/resources/poms/validation/raw-model/ok-ci-friendly-changelist.xml new file mode 100644 index 0000000000..56fda9a681 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/raw-model/ok-ci-friendly-changelist.xml @@ -0,0 +1,31 @@ + + + + 4.0.0 + com.example.group + valid-version-changelist + ${changelist} + + + This will test if the validation for the ci friendly versions + is working correct. + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/raw-model/ok-ci-friendly-revision.xml b/impl/maven-impl/src/test/resources/poms/validation/raw-model/ok-ci-friendly-revision.xml new file mode 100644 index 0000000000..5b0c73f40c --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/raw-model/ok-ci-friendly-revision.xml @@ -0,0 +1,31 @@ + + + + 4.0.0 + com.example.group + valid-version-revision + ${revision} + + + This will test if the validation for the ci friendly versions + is working correct. + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/raw-model/ok-ci-friendly-sha1.xml b/impl/maven-impl/src/test/resources/poms/validation/raw-model/ok-ci-friendly-sha1.xml new file mode 100644 index 0000000000..d1bc42f8d3 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/raw-model/ok-ci-friendly-sha1.xml @@ -0,0 +1,31 @@ + + + + 4.0.0 + com.example.group + valid-version-sha1 + ${sha1} + + + This will test if the validation for the ci friendly versions + is working correct. + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/raw-model/profile-activation-file-with-allowed-expressions.xml b/impl/maven-impl/src/test/resources/poms/validation/raw-model/profile-activation-file-with-allowed-expressions.xml new file mode 100644 index 0000000000..72b6747f18 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/raw-model/profile-activation-file-with-allowed-expressions.xml @@ -0,0 +1,82 @@ + + + + 4.0.0 + aid + gid + 0.1 + pom + + + + exists-basedir + + + ${basedir}/test.txt + + + + + missing-basedir + + + ${basedir}/test.txt + + + + + + exists-project-basedir + + + ${project.basedir}/test.txt + + + + + missing-project-basedir + + + ${project.basedir}/test.txt + + + + + + dynamic-property-available + + + ${activationProperty} + + + + + + matches-another-property + + + foo + ${bar} + + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/raw-model/profile-activation-file-with-project-expressions.xml b/impl/maven-impl/src/test/resources/poms/validation/raw-model/profile-activation-file-with-project-expressions.xml new file mode 100644 index 0000000000..65953c3bb9 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/raw-model/profile-activation-file-with-project-expressions.xml @@ -0,0 +1,48 @@ + + + + 4.0.0 + aid + gid + 0.1 + pom + + + + + exists-project-version + + + ${project.version}/test.txt + + + + + missing-project-version + + + ${project.version}/test.txt + + + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/raw-model/profile-activation-property-with-project-expressions.xml b/impl/maven-impl/src/test/resources/poms/validation/raw-model/profile-activation-property-with-project-expressions.xml new file mode 100644 index 0000000000..8bcf89f66f --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/raw-model/profile-activation-property-with-project-expressions.xml @@ -0,0 +1,49 @@ + + + + 4.0.0 + aid + gid + 0.1 + pom + + + + + property-name-project-version + + + ${project.version} + + + + + property-value-project-version + + + project.version + ${project.version} + + + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/raw-model/repository-with-basedir-expression.xml b/impl/maven-impl/src/test/resources/poms/validation/raw-model/repository-with-basedir-expression.xml new file mode 100644 index 0000000000..2dd11eb42e --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/raw-model/repository-with-basedir-expression.xml @@ -0,0 +1,50 @@ + + + + + 4.0.0 + + org.apache.maven.validation + parent + 1 + + + org.apache.maven.validation + project + 1.0.0-SNAPSHOT + + + + repo + file://${basedir}/target/remote-repo + + + repo-project-basedir + file://${project.basedir}/sdk/maven/repo + + + repo-project-baseUri + ${project.baseUri}/sdk/maven/repo + + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/raw-model/repository-with-expression.xml b/impl/maven-impl/src/test/resources/poms/validation/raw-model/repository-with-expression.xml new file mode 100644 index 0000000000..fcdd9465d8 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/raw-model/repository-with-expression.xml @@ -0,0 +1,46 @@ + + + + + 4.0.0 + + org.apache.maven.validation + parent + 1 + + + org.apache.maven.validation + project + 1.0.0-SNAPSHOT + + + just/some/path + + + + + repo + file://${x}/sdk/maven/repo + + + + \ No newline at end of file diff --git a/impl/maven-impl/src/test/resources/poms/validation/raw-model/self-referencing-classifier.xml b/impl/maven-impl/src/test/resources/poms/validation/raw-model/self-referencing-classifier.xml new file mode 100644 index 0000000000..2fc5dca654 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/raw-model/self-referencing-classifier.xml @@ -0,0 +1,39 @@ + + + + 4.0.0 + com.example.group + testvalidpom + 0.0.1-SNAPSHOT + + + This will test if the module validator recognized that this dependency with classifier + is not the same as the module itself. + + + + com.example.group + testvalidpom + 0.0.1-SNAPSHOT + linux + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/raw-model/self-referencing.xml b/impl/maven-impl/src/test/resources/poms/validation/raw-model/self-referencing.xml new file mode 100644 index 0000000000..d65cbc2269 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/raw-model/self-referencing.xml @@ -0,0 +1,38 @@ + + + + 4.0.0 + com.example.group + testinvalidpom + 0.0.1-SNAPSHOT + + + This will test if the module validator recognized that this + dependency is the same as the module itself. + + + + com.example.group + testinvalidpom + 0.0.1-SNAPSHOT + + + diff --git a/impl/maven-impl/src/test/resources/poms/validation/reserved-repository-id.xml b/impl/maven-impl/src/test/resources/poms/validation/reserved-repository-id.xml new file mode 100644 index 0000000000..90a6c88c45 --- /dev/null +++ b/impl/maven-impl/src/test/resources/poms/validation/reserved-repository-id.xml @@ -0,0 +1,50 @@ + + + + 4.0.0 + + gid + aid + 99.44 + + + + local + http://localhost + + + + + local + http://localhost + + + + + + local + http://localhost + + + local + http://localhost + + +