This is an automated email from the ASF dual-hosted git repository. slachiewicz pushed a commit to branch agent/supplement-keeps-urls in repository https://gitbox.apache.org/repos/asf/maven-remote-resources-plugin.git
commit ac48cbcc9f3ffc02f6fade4372fe8b0c76f7fea9 Author: Sylwester Lachiewicz <[email protected]> AuthorDate: Wed Oct 28 10:21:38 2026 +0000 Keep a dependency's URLs when a supplemental model is merged (#326) --- .../remote/AbstractProcessRemoteResourcesMojo.java | 3 +- .../resources/remote/SupplementMergeTest.java | 53 ++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/maven/plugin/resources/remote/AbstractProcessRemoteResourcesMojo.java b/src/main/java/org/apache/maven/plugin/resources/remote/AbstractProcessRemoteResourcesMojo.java index 755189a..fb1e3a3 100644 --- a/src/main/java/org/apache/maven/plugin/resources/remote/AbstractProcessRemoteResourcesMojo.java +++ b/src/main/java/org/apache/maven/plugin/resources/remote/AbstractProcessRemoteResourcesMojo.java @@ -1035,7 +1035,8 @@ public abstract class AbstractProcessRemoteResourcesMojo extends AbstractMojo { } protected Model mergeModels(Model parent, Model child) { - inheritanceAssembler.assembleModelInheritance(child, parent); + // a supplement describes the same artifact, not a child module, so URLs must not get the artifactId appended + inheritanceAssembler.copyModel(child, parent); return child; } diff --git a/src/test/java/org/apache/maven/plugin/resources/remote/SupplementMergeTest.java b/src/test/java/org/apache/maven/plugin/resources/remote/SupplementMergeTest.java new file mode 100644 index 0000000..d9462af --- /dev/null +++ b/src/test/java/org/apache/maven/plugin/resources/remote/SupplementMergeTest.java @@ -0,0 +1,53 @@ +/* + * 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.plugin.resources.remote; + +import org.apache.maven.model.License; +import org.apache.maven.model.Model; +import org.apache.maven.model.Scm; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class SupplementMergeTest { + + @Test + void supplementKeepsTheDependencyUrls() { + Model pom = new Model(); + pom.setGroupId("org.foo"); + pom.setArtifactId("widget"); + pom.setUrl("https://widget.example.org/site"); + Scm scm = new Scm(); + scm.setUrl("https://github.com/example/widget"); + pom.setScm(scm); + + Model supplement = new Model(); + supplement.setGroupId("org.foo"); + supplement.setArtifactId("widget"); + License license = new License(); + license.setName("MIT License"); + supplement.addLicense(license); + + Model merged = new ProcessRemoteResourcesMojo(null, null, null, null, null).mergeModels(pom, supplement); + + assertEquals("https://widget.example.org/site", merged.getUrl()); + assertEquals("https://github.com/example/widget", merged.getScm().getUrl()); + assertEquals("MIT License", merged.getLicenses().get(0).getName()); + } +}
