From 9973c00fa7ad3da2db5d06601fca7d7111333e1c Mon Sep 17 00:00:00 2001 From: Lipeng <44571204+gaosaroma@users.noreply.github.com> Date: Mon, 12 Aug 2024 11:54:08 +0800 Subject: [PATCH] fix module slim when using starter (#991) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 优化显示 * fix as bizStateRecords * 更新显示 * fix module slim for snapshot --- .../sofa/ark/boot/mojo/ModuleSlimStrategy.java | 4 ++-- .../sofa/ark/boot/mojo/ModuleSlimStrategyTest.java | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/sofa-ark-parent/support/ark-maven-plugin/src/main/java/com/alipay/sofa/ark/boot/mojo/ModuleSlimStrategy.java b/sofa-ark-parent/support/ark-maven-plugin/src/main/java/com/alipay/sofa/ark/boot/mojo/ModuleSlimStrategy.java index 1a97360bc..59657be83 100644 --- a/sofa-ark-parent/support/ark-maven-plugin/src/main/java/com/alipay/sofa/ark/boot/mojo/ModuleSlimStrategy.java +++ b/sofa-ark-parent/support/ark-maven-plugin/src/main/java/com/alipay/sofa/ark/boot/mojo/ModuleSlimStrategy.java @@ -131,10 +131,10 @@ private Model getBaseDependencyParentOriginalModel() { private String getArtifactIdentity(Artifact artifact) { if (artifact.hasClassifier()) { return artifact.getGroupId() + STRING_COLON + artifact.getArtifactId() + STRING_COLON - + artifact.getVersion() + ":" + artifact.getClassifier(); + + artifact.getBaseVersion() + STRING_COLON + artifact.getClassifier(); } else { return artifact.getGroupId() + STRING_COLON + artifact.getArtifactId() + STRING_COLON - + artifact.getVersion(); + + artifact.getBaseVersion(); } } diff --git a/sofa-ark-parent/support/ark-maven-plugin/src/test/java/com/alipay/sofa/ark/boot/mojo/ModuleSlimStrategyTest.java b/sofa-ark-parent/support/ark-maven-plugin/src/test/java/com/alipay/sofa/ark/boot/mojo/ModuleSlimStrategyTest.java index 2a2b44ebf..3d775e314 100644 --- a/sofa-ark-parent/support/ark-maven-plugin/src/test/java/com/alipay/sofa/ark/boot/mojo/ModuleSlimStrategyTest.java +++ b/sofa-ark-parent/support/ark-maven-plugin/src/test/java/com/alipay/sofa/ark/boot/mojo/ModuleSlimStrategyTest.java @@ -33,7 +33,11 @@ import java.io.IOException; import java.net.URISyntaxException; import java.net.URL; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; import static com.alipay.sofa.ark.boot.mojo.ReflectionUtils.setField; import static java.util.Arrays.asList; @@ -105,11 +109,13 @@ public void testGetArtifactsToFilterByParentIdentity() throws URISyntaxException when(sameArtifact.getGroupId()).thenReturn("com.mock"); when(sameArtifact.getArtifactId()).thenReturn("same-dependency-artifact"); when(sameArtifact.getVersion()).thenReturn("1.0"); + when(sameArtifact.getBaseVersion()).thenReturn("1.0-SNAPSHOT"); Artifact differenceArtifact = mock(Artifact.class); when(differenceArtifact.getGroupId()).thenReturn("com.mock"); when(differenceArtifact.getArtifactId()).thenReturn("difference-dependency-artifact"); when(differenceArtifact.getVersion()).thenReturn("2.0"); + when(differenceArtifact.getBaseVersion()).thenReturn("2.0-SNAPSHOT"); Set res = strategy.getArtifactsToFilterByParentIdentity(Sets.newHashSet( sameArtifact, differenceArtifact)); @@ -259,6 +265,7 @@ private MavenProject getRootProject() { when(artifact.getArtifactId()).thenReturn("base-dependencies-starter"); when(artifact.getGroupId()).thenReturn("com.mock"); when(artifact.getVersion()).thenReturn("1.0"); + when(artifact.getBaseVersion()).thenReturn("1.0"); project.setArtifact(artifact); project.setParent(null); @@ -266,12 +273,12 @@ private MavenProject getRootProject() { Dependency sameDependency = new Dependency(); sameDependency.setArtifactId("same-dependency-artifact"); sameDependency.setGroupId("com.mock"); - sameDependency.setVersion("1.0"); + sameDependency.setVersion("1.0-SNAPSHOT"); Dependency differenceDependency = new Dependency(); differenceDependency.setArtifactId("difference-dependency-artifact"); differenceDependency.setGroupId("com.mock"); - differenceDependency.setVersion("1.0"); + differenceDependency.setVersion("1.0-SNAPSHOT"); DependencyManagement dm = new DependencyManagement(); dm.setDependencies(Lists.newArrayList(sameDependency, differenceDependency));