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 973f049fd..e73391201 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,12 @@ private Set getSameVersionArtifactsWithBase(Set artifacts) t return artifacts.stream().filter(it -> dependencyIdentities.contains(getArtifactIdentity(it))).collect(Collectors.toSet()); } - private Model getBaseDependencyParentOriginalModel() { + protected Model getBaseDependencyParentOriginalModel() { MavenProject proj = project; while (null != proj) { - if (getGAVIdentity(proj.getArtifact()).equals(config.getBaseDependencyParentIdentity())) { + if (getGAIdentity(proj.getArtifact()).equals(config.getBaseDependencyParentIdentity()) + || getGAVIdentity(proj.getArtifact()).equals( + config.getBaseDependencyParentIdentity())) { return proj.getOriginalModel(); } proj = proj.getParent(); @@ -147,6 +149,10 @@ private String getGAVIdentity(Artifact artifact) { + artifact.getBaseVersion(); } + private String getGAIdentity(Artifact artifact) { + return artifact.getGroupId() + STRING_COLON + artifact.getArtifactId(); + } + protected String getArtifactIdentity(Artifact artifact) { if (artifact.hasClassifier()) { return artifact.getGroupId() + STRING_COLON + artifact.getArtifactId() + STRING_COLON 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 29a7ac616..09195d54a 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 @@ -46,6 +46,7 @@ import static java.util.Arrays.asList; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.anySet; import static org.mockito.ArgumentMatchers.anyString; @@ -136,6 +137,20 @@ public void testGetArtifactsToFilterByParentIdentity() throws URISyntaxException assertFalse(res.contains(differenceArtifact)); } + @Test + public void testGetBaseDependencyParentOriginalModel() throws URISyntaxException { + // find base-dependency-parent by gav identity + ModuleSlimConfig config = (new ModuleSlimConfig()) + .setBaseDependencyParentIdentity("com.mock:base-dependencies-starter:1.0"); + ModuleSlimStrategy strategy = new ModuleSlimStrategy(getMockBootstrapProject(), null, + config, mockBaseDir(), null); + assertNotNull(strategy.getBaseDependencyParentOriginalModel()); + + // find base-dependency-parent by ga identity + config.setBaseDependencyParentIdentity("com.mock:base-dependencies-starter"); + assertNotNull(strategy.getBaseDependencyParentOriginalModel()); + } + @Test public void testExtensionExcludeAndIncludeArtifactsByDefault() throws URISyntaxException, IOException {