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 1f43df3e58 [MNG-8562] remove "child" attributes from <scm> (#2101)
1f43df3e58 is described below
commit 1f43df3e589e6fa453e1efdd5ce10cf7e82ce687
Author: Guillaume Nodet <[email protected]>
AuthorDate: Tue Feb 11 13:19:54 2025 +0100
[MNG-8562] remove "child" attributes from <scm> (#2101)
---
.../impl/DefaultConsumerPomBuilder.java | 11 ++++++++++-
.../transformation/impl/ConsumerPomBuilderTest.java | 20 ++++++++++++++++++++
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git
a/impl/maven-core/src/main/java/org/apache/maven/internal/transformation/impl/DefaultConsumerPomBuilder.java
b/impl/maven-core/src/main/java/org/apache/maven/internal/transformation/impl/DefaultConsumerPomBuilder.java
index 2f098c96d4..34897868c9 100644
---
a/impl/maven-core/src/main/java/org/apache/maven/internal/transformation/impl/DefaultConsumerPomBuilder.java
+++
b/impl/maven-core/src/main/java/org/apache/maven/internal/transformation/impl/DefaultConsumerPomBuilder.java
@@ -40,6 +40,7 @@
import org.apache.maven.api.model.ModelBase;
import org.apache.maven.api.model.Profile;
import org.apache.maven.api.model.Repository;
+import org.apache.maven.api.model.Scm;
import org.apache.maven.api.services.ModelBuilder;
import org.apache.maven.api.services.ModelBuilderException;
import org.apache.maven.api.services.ModelBuilderRequest;
@@ -244,7 +245,15 @@ static Model transform(Model model, MavenProject project) {
.developers(null)
.contributors(null)
.mailingLists(null)
- .issueManagement(null);
+ .issueManagement(null)
+ .scm(
+ model.getScm() != null
+ ? Scm.newBuilder(model.getScm(), true)
+
.childScmConnectionInheritAppendPath(null)
+ .childScmUrlInheritAppendPath(null)
+
.childScmDeveloperConnectionInheritAppendPath(null)
+ .build()
+ : null);
builder.profiles(prune(model.getProfiles()));
model = builder.build();
diff --git
a/impl/maven-core/src/test/java/org/apache/maven/internal/transformation/impl/ConsumerPomBuilderTest.java
b/impl/maven-core/src/test/java/org/apache/maven/internal/transformation/impl/ConsumerPomBuilderTest.java
index fce6b5dbfa..d627796b13 100644
---
a/impl/maven-core/src/test/java/org/apache/maven/internal/transformation/impl/ConsumerPomBuilderTest.java
+++
b/impl/maven-core/src/test/java/org/apache/maven/internal/transformation/impl/ConsumerPomBuilderTest.java
@@ -31,6 +31,7 @@
import org.apache.maven.api.Session;
import org.apache.maven.api.SessionData;
import org.apache.maven.api.model.Model;
+import org.apache.maven.api.model.Scm;
import org.apache.maven.api.services.DependencyResolver;
import org.apache.maven.api.services.DependencyResolverResult;
import org.apache.maven.api.services.ModelBuilder;
@@ -51,6 +52,7 @@
import org.mockito.Mockito;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ConsumerPomBuilderTest extends AbstractRepositoryTestCase {
@@ -138,4 +140,22 @@ void testSimpleConsumer() throws Exception {
assertNotNull(model);
assertTrue(model.getProfiles().isEmpty());
}
+
+ @Test
+ void testScmInheritance() throws Exception {
+ Model model = Model.newBuilder()
+ .scm(Scm.newBuilder()
+
.connection("scm:git:https://github.com/apache/maven-project.git")
+
.developerConnection("scm:git:https://github.com/apache/maven-project.git")
+ .url("https://github.com/apache/maven-project")
+ .childScmConnectionInheritAppendPath("true")
+ .childScmUrlInheritAppendPath("true")
+ .childScmDeveloperConnectionInheritAppendPath("true")
+ .build())
+ .build();
+ Model transformed = DefaultConsumerPomBuilder.transform(model, null);
+
assertNull(transformed.getScm().getChildScmConnectionInheritAppendPath());
+ assertNull(transformed.getScm().getChildScmUrlInheritAppendPath());
+
assertNull(transformed.getScm().getChildScmDeveloperConnectionInheritAppendPath());
+ }
}