Skip to content

Commit 1f43df3

Browse files
authored
[MNG-8562] remove "child" attributes from <scm> (#2101)
1 parent f3000ee commit 1f43df3

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

impl/maven-core/src/main/java/org/apache/maven/internal/transformation/impl/DefaultConsumerPomBuilder.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.apache.maven.api.model.ModelBase;
4141
import org.apache.maven.api.model.Profile;
4242
import org.apache.maven.api.model.Repository;
43+
import org.apache.maven.api.model.Scm;
4344
import org.apache.maven.api.services.ModelBuilder;
4445
import org.apache.maven.api.services.ModelBuilderException;
4546
import org.apache.maven.api.services.ModelBuilderRequest;
@@ -244,7 +245,15 @@ static Model transform(Model model, MavenProject project) {
244245
.developers(null)
245246
.contributors(null)
246247
.mailingLists(null)
247-
.issueManagement(null);
248+
.issueManagement(null)
249+
.scm(
250+
model.getScm() != null
251+
? Scm.newBuilder(model.getScm(), true)
252+
.childScmConnectionInheritAppendPath(null)
253+
.childScmUrlInheritAppendPath(null)
254+
.childScmDeveloperConnectionInheritAppendPath(null)
255+
.build()
256+
: null);
248257
builder.profiles(prune(model.getProfiles()));
249258

250259
model = builder.build();

impl/maven-core/src/test/java/org/apache/maven/internal/transformation/impl/ConsumerPomBuilderTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.apache.maven.api.Session;
3232
import org.apache.maven.api.SessionData;
3333
import org.apache.maven.api.model.Model;
34+
import org.apache.maven.api.model.Scm;
3435
import org.apache.maven.api.services.DependencyResolver;
3536
import org.apache.maven.api.services.DependencyResolverResult;
3637
import org.apache.maven.api.services.ModelBuilder;
@@ -51,6 +52,7 @@
5152
import org.mockito.Mockito;
5253

5354
import static org.junit.jupiter.api.Assertions.assertNotNull;
55+
import static org.junit.jupiter.api.Assertions.assertNull;
5456
import static org.junit.jupiter.api.Assertions.assertTrue;
5557

5658
public class ConsumerPomBuilderTest extends AbstractRepositoryTestCase {
@@ -138,4 +140,22 @@ void testSimpleConsumer() throws Exception {
138140
assertNotNull(model);
139141
assertTrue(model.getProfiles().isEmpty());
140142
}
143+
144+
@Test
145+
void testScmInheritance() throws Exception {
146+
Model model = Model.newBuilder()
147+
.scm(Scm.newBuilder()
148+
.connection("scm:git:https://github.com/apache/maven-project.git")
149+
.developerConnection("scm:git:https://github.com/apache/maven-project.git")
150+
.url("https://github.com/apache/maven-project")
151+
.childScmConnectionInheritAppendPath("true")
152+
.childScmUrlInheritAppendPath("true")
153+
.childScmDeveloperConnectionInheritAppendPath("true")
154+
.build())
155+
.build();
156+
Model transformed = DefaultConsumerPomBuilder.transform(model, null);
157+
assertNull(transformed.getScm().getChildScmConnectionInheritAppendPath());
158+
assertNull(transformed.getScm().getChildScmUrlInheritAppendPath());
159+
assertNull(transformed.getScm().getChildScmDeveloperConnectionInheritAppendPath());
160+
}
141161
}

0 commit comments

Comments
 (0)