Skip to content

Commit

Permalink
feat:baseDependencyParentIdentity_without_version (#1019)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaosaroma authored Oct 25, 2024
1 parent 7c40ec7 commit f3b88fc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,12 @@ private Set<Artifact> getSameVersionArtifactsWithBase(Set<Artifact> 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();
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit f3b88fc

Please sign in to comment.