You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2026/08/28 14:59:35 UTC
(maven) branch rebased/pr-1542-fix-validation-level-maven-3.9.x created (now 0c4eb4bf16)
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a change to branch rebased/pr-1542-fix-validation-level-maven-3.9.x
in repository https://gitbox.apache.org/repos/asf/maven.git
at 0c4eb4bf16 Fix unit tests
This branch includes the following new commits:
new 44ab5f0b36 Maven 3.9.x should use Maven 3.1 validation in strict mode
new 924fb4d7ed Fix UTs
new 0c4eb4bf16 Fix unit tests
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(maven) 02/03: Fix UTs
Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch rebased/pr-1542-fix-validation-level-maven-3.9.x
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 924fb4d7edabb761dc466fab8e3ba838cc111f4b
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Wed May 29 11:35:41 2024 +0200
Fix UTs
---
.../validation/DefaultModelValidatorTest.java | 97 +++++++++++++++++++---
1 file changed, 84 insertions(+), 13 deletions(-)
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 d29201ffea..93a76e826a 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
@@ -54,6 +54,10 @@ private SimpleProblemCollector validate(String pom) throws Exception {
return validateEffective(pom, UnaryOperator.identity());
}
+ private SimpleProblemCollector validate(String pom, int level) throws Exception {
+ return validateEffective(pom, mbr -> mbr.setValidationLevel(level));
+ }
+
private SimpleProblemCollector validateRaw(String pom) throws Exception {
return validateRaw(pom, UnaryOperator.identity());
}
@@ -428,7 +432,7 @@ public void testIncompleteParent() throws Exception {
@Test
public void testHardCodedSystemPath() throws Exception {
- SimpleProblemCollector result = validateRaw("hard-coded-system-path.xml");
+ SimpleProblemCollector result = validateRaw("hard-coded-system-path.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0);
assertViolations(result, 0, 0, 1);
@@ -437,7 +441,7 @@ public void testHardCodedSystemPath() throws Exception {
"'dependencies.dependency.systemPath' for test:a:jar should use a variable instead of a hard-coded path");
SimpleProblemCollector result31 =
- validateRaw("hard-coded-system-path.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1);
+ validateRaw("hard-coded-system-path.xml");
assertViolations(result31, 0, 0, 3);
@@ -462,8 +466,9 @@ public void testEmptyModule() throws Exception {
}
@Test
- public void testDuplicatePlugin() throws Exception {
- SimpleProblemCollector result = validateRaw("duplicate-plugin.xml");
+ public void testDuplicatePlugin30() throws Exception {
+ SimpleProblemCollector result =
+ validateRaw("duplicate-plugin.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0);
assertViolations(result, 0, 0, 4);
@@ -474,6 +479,18 @@ public void testDuplicatePlugin() throws Exception {
}
@Test
+ public void testDuplicatePlugin() throws Exception {
+ SimpleProblemCollector result = validateRaw("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"));
+ }
+
+
public void testDuplicatePluginExecution() throws Exception {
SimpleProblemCollector result = validateRaw("duplicate-plugin-execution.xml");
@@ -486,8 +503,9 @@ public void testDuplicatePluginExecution() throws Exception {
}
@Test
- public void testReservedRepositoryId() throws Exception {
- SimpleProblemCollector result = validate("reserved-repository-id.xml");
+ public void testReservedRepositoryId30() throws Exception {
+ SimpleProblemCollector result =
+ validate("reserved-repository-id.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0);
assertViolations(result, 0, 0, 4);
@@ -499,6 +517,19 @@ public void testReservedRepositoryId() throws Exception {
}
@Test
+ public 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'");
+ }
+
+
public void testMissingPluginDependencyGroupId() throws Exception {
SimpleProblemCollector result = validate("missing-plugin-dependency-groupId.xml");
@@ -534,27 +565,48 @@ public void testBadPluginDependencyVersion() throws Exception {
assertTrue(result.getErrors().get(0).contains("test:b"));
}
+ @Test
+ public void testBadVersion30() throws Exception {
+ SimpleProblemCollector result =
+ validate("bad-version.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0);
+
+ assertViolations(result, 0, 0, 1);
+
+ assertContains(result.getWarnings().get(0), "'version' must not contain any of these characters");
+ }
+
@Test
public 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
+ public void testBadSnapshotVersion30() throws Exception {
+ SimpleProblemCollector result =
+ validate("bad-snapshot-version.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0);
+
assertViolations(result, 0, 0, 1);
- assertContains(result.getWarnings().get(0), "'version' must not contain any of these characters");
+ assertContains(result.getWarnings().get(0), "'version' uses an unsupported snapshot version format");
}
@Test
public void testBadSnapshotVersion() throws Exception {
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
- public void testBadRepositoryId() throws Exception {
- SimpleProblemCollector result = validate("bad-repository-id.xml");
+ public void testBadRepositoryId30() throws Exception {
+ SimpleProblemCollector result =
+ validate("bad-repository-id.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0);
assertViolations(result, 0, 0, 4);
@@ -572,6 +624,25 @@ public void testBadRepositoryId() throws Exception {
}
@Test
+ public 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");
+ }
+
+
public void testBadDependencyExclusionId() throws Exception {
SimpleProblemCollector result =
validateEffective("bad-dependency-exclusion-id.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0);
@@ -629,7 +700,7 @@ public void testBadImportScopeClassifier() throws Exception {
@Test
public void testSystemPathRefersToProjectBasedir() throws Exception {
- SimpleProblemCollector result = validateRaw("basedir-system-path.xml");
+ SimpleProblemCollector result = validateRaw("basedir-system-path.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0);
assertViolations(result, 0, 0, 2);
@@ -641,7 +712,7 @@ public void testSystemPathRefersToProjectBasedir() throws Exception {
"'dependencies.dependency.systemPath' for test:b:jar should not point at files within the project directory");
SimpleProblemCollector result31 =
- validateRaw("basedir-system-path.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1);
+ validateRaw("basedir-system-path.xml");
assertViolations(result31, 0, 0, 4);
(maven) 03/03: Fix unit tests
Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch rebased/pr-1542-fix-validation-level-maven-3.9.x
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 0c4eb4bf1698470d51198fc8160f1c6ee11d4de0
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Wed May 29 14:34:01 2024 +0200
Fix unit tests
---
.../projects/duplicate-plugins-merged-pom.xml | 54 +++++++++++++---------
.../validation/DefaultModelValidatorTest.java | 12 ++---
2 files changed, 38 insertions(+), 28 deletions(-)
diff --git a/maven-core/src/test/resources/projects/duplicate-plugins-merged-pom.xml b/maven-core/src/test/resources/projects/duplicate-plugins-merged-pom.xml
index 7383109f0e..c651a3a28f 100644
--- a/maven-core/src/test/resources/projects/duplicate-plugins-merged-pom.xml
+++ b/maven-core/src/test/resources/projects/duplicate-plugins-merged-pom.xml
@@ -1,5 +1,5 @@
-<project>
- <modelVersion>4.0.0</modelVersion>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
<groupId>tests.project</groupId>
<artifactId>duplicate-plugin-defs-merged</artifactId>
<version>1</version>
@@ -8,6 +8,7 @@
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
+ <version>3.11.0</version>
<dependencies>
<dependency>
<groupId>group</groupId>
@@ -24,25 +25,36 @@
</execution>
</executions>
</plugin>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <dependencies>
- <dependency>
- <groupId>group</groupId>
- <artifactId>second</artifactId>
- <version>1</version>
- </dependency>
- </dependencies>
- <executions>
- <execution>
- <id>second</id>
- <goals>
- <goal>compile</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
+ </plugins>
</build>
+ <profiles>
+ <profile>
+ <id>foo</id>
+ <activation><activeByDefault>true</activeByDefault></activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>group</groupId>
+ <artifactId>second</artifactId>
+ <version>1</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>second</id>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
</project>
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 93a76e826a..6e86286696 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
@@ -432,7 +432,8 @@ public void testIncompleteParent() throws Exception {
@Test
public void testHardCodedSystemPath() throws Exception {
- SimpleProblemCollector result = validateRaw("hard-coded-system-path.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0);
+ SimpleProblemCollector result =
+ validateRaw("hard-coded-system-path.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0);
assertViolations(result, 0, 0, 1);
@@ -490,7 +491,6 @@ public void testDuplicatePlugin() throws Exception {
assertTrue(result.getErrors().get(3).contains("duplicate declaration of plugin profile:managed-duplicate"));
}
-
public void testDuplicatePluginExecution() throws Exception {
SimpleProblemCollector result = validateRaw("duplicate-plugin-execution.xml");
@@ -525,11 +525,9 @@ public void testReservedRepositoryId() throws Exception {
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'");
+ assertContains(result.getErrors().get(3), "'distributionManagement.snapshotRepository.id' must not be 'local'");
}
-
public void testMissingPluginDependencyGroupId() throws Exception {
SimpleProblemCollector result = validate("missing-plugin-dependency-groupId.xml");
@@ -642,7 +640,6 @@ public void testBadRepositoryId() throws Exception {
"'distributionManagement.snapshotRepository.id' must not contain any of these characters");
}
-
public void testBadDependencyExclusionId() throws Exception {
SimpleProblemCollector result =
validateEffective("bad-dependency-exclusion-id.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0);
@@ -700,7 +697,8 @@ public void testBadImportScopeClassifier() throws Exception {
@Test
public void testSystemPathRefersToProjectBasedir() throws Exception {
- SimpleProblemCollector result = validateRaw("basedir-system-path.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0);
+ SimpleProblemCollector result =
+ validateRaw("basedir-system-path.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0);
assertViolations(result, 0, 0, 2);
(maven) 01/03: Maven 3.9.x should use Maven 3.1 validation in strict mode
Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch rebased/pr-1542-fix-validation-level-maven-3.9.x
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 44ab5f0b362b5781be826cdb038a40bebada9df3
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Wed May 29 10:01:48 2024 +0200
Maven 3.9.x should use Maven 3.1 validation in strict mode
---
.../main/java/org/apache/maven/model/building/ModelBuildingRequest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 98649e0b44..1465a30580 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
@@ -60,7 +60,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 raw model to build. If not set, model source will be used to load raw model.