This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/master by this push:
new 4108a98359 Fix #12075: skip expression validation for
distributionManagement repository IDs (#12076)
4108a98359 is described below
commit 4108a9835914e1fa45cfbf86ef53f34962844c68
Author: Guillaume Nodet <[email protected]>
AuthorDate: Tue May 19 15:32:36 2026 +0200
Fix #12075: skip expression validation for distributionManagement
repository IDs (#12076)
Parent POM properties are not available during file model validation,
so chained property references in distributionManagement repository
IDs (e.g. ${distMgmtStagingId} -> ${distMgmtReleasesId}) cannot be
fully resolved at this stage. Skip the uninterpolated expression
check for distributionManagement repositories, consistent with how
profile repositories are already handled.
Uninterpolated repositories are still caught by MavenValidator when
they are actually used by the resolver.
Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
---
.../maven/impl/model/DefaultModelValidator.java | 4 +-
.../impl/model/DefaultModelValidatorTest.java | 15 ++++---
.../raw-model/dm-with-chained-property-in-id.xml | 46 ++++++++++++++++++++++
3 files changed, 58 insertions(+), 7 deletions(-)
diff --git
a/impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelValidator.java
b/impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelValidator.java
index 6e73c57bcc..f71ed85adf 100644
---
a/impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelValidator.java
+++
b/impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelValidator.java
@@ -696,14 +696,14 @@ && equals(parent.getArtifactId(), model.getArtifactId()))
{
DistributionManagement distMgmt =
model.getDistributionManagement();
if (distMgmt != null) {
validateRawRepository(
- problems, distMgmt.getRepository(),
"distributionManagement.repository.", "", true, false);
+ problems, distMgmt.getRepository(),
"distributionManagement.repository.", "", true, true);
validateRawRepository(
problems,
distMgmt.getSnapshotRepository(),
"distributionManagement.snapshotRepository.",
"",
true,
- false);
+ true);
}
}
}
diff --git
a/impl/maven-impl/src/test/java/org/apache/maven/impl/model/DefaultModelValidatorTest.java
b/impl/maven-impl/src/test/java/org/apache/maven/impl/model/DefaultModelValidatorTest.java
index 24ed0596ed..5825e1ab44 100644
---
a/impl/maven-impl/src/test/java/org/apache/maven/impl/model/DefaultModelValidatorTest.java
+++
b/impl/maven-impl/src/test/java/org/apache/maven/impl/model/DefaultModelValidatorTest.java
@@ -929,18 +929,23 @@ void repositoryWithUnsupportedExpression() throws
Exception {
void repositoryWithUninterpolatedId() throws Exception {
SimpleProblemCollector result =
validateRaw("raw-model/repository-with-uninterpolated-id.xml");
// Uninterpolated expressions in repository IDs should cause
validation errors
- assertViolations(result, 0, 3, 0);
+ // distributionManagement repositories skip expression check since
parent properties
+ // may not be available at file model validation stage
+ assertViolations(result, 0, 2, 0);
- // Check that all three repository ID validation errors are present
+ // Check that repository ID validation errors are present for
repositories and pluginRepositories
assertTrue(result.getErrors().stream()
.anyMatch(error ->
error.contains("repositories.repository.[${repository.id}].id")
&& error.contains("contains an uninterpolated
expression")));
assertTrue(result.getErrors().stream()
.anyMatch(error ->
error.contains("pluginRepositories.pluginRepository.[${plugin.repository.id}].id")
&& error.contains("contains an uninterpolated
expression")));
- assertTrue(result.getErrors().stream()
- .anyMatch(error ->
error.contains("distributionManagement.repository.[${staging.repository.id}].id")
- && error.contains("contains an uninterpolated
expression")));
+ }
+
+ @Test
+ void distributionManagementWithChainedPropertyInId() throws Exception {
+ SimpleProblemCollector result =
validateRaw("raw-model/dm-with-chained-property-in-id.xml");
+ assertViolations(result, 0, 0, 0);
}
@Test
diff --git
a/impl/maven-impl/src/test/resources/poms/validation/raw-model/dm-with-chained-property-in-id.xml
b/impl/maven-impl/src/test/resources/poms/validation/raw-model/dm-with-chained-property-in-id.xml
new file mode 100644
index 0000000000..845da0a7c4
--- /dev/null
+++
b/impl/maven-impl/src/test/resources/poms/validation/raw-model/dm-with-chained-property-in-id.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<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
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.validation</groupId>
+ <artifactId>project</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <properties>
+ <distMgmtStagingId>${distMgmtReleasesId}</distMgmtStagingId>
+ <distMgmtSnapshotsId>${distMgmtReleasesId}</distMgmtSnapshotsId>
+ </properties>
+
+ <distributionManagement>
+ <repository>
+ <id>${distMgmtStagingId}</id>
+
<url>https://repository.apache.org/service/local/staging/deploy/maven2</url>
+ </repository>
+ <snapshotRepository>
+ <id>${distMgmtSnapshotsId}</id>
+ <url>https://repository.apache.org/content/repositories/snapshots</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>