Skip to content

Commit

Permalink
FindMinimumDependencyVersion - use the artifact ID when matching de…
Browse files Browse the repository at this point in the history
…pendencies (#123)
  • Loading branch information
pstreef authored Sep 10, 2024
1 parent 351fb32 commit d7b0833
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ private void collectMinimumVersions(VersionParser versionParser, List<ResolvedDe
Map<GroupArtifact, ResolvedGroupArtifactVersion> acc) {
StaticVersionComparator versionComparator = new StaticVersionComparator();
for (ResolvedDependency dep : resolved) {
if (StringUtils.matchesGlob(dep.getGroupId(), groupIdPattern)) {
if (StringUtils.matchesGlob(dep.getGroupId(), groupIdPattern) &&
StringUtils.matchesGlob(dep.getArtifactId(), artifactIdPattern)) {
acc.merge(new GroupArtifact(dep.getGroupId(), dep.getArtifactId()),
dep.getGav(), (d1, d2) -> versionComparator.compare(
versionParser.transform(d1.getVersion()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class FindMinimumDependencyVersionTest implements RewriteTest {

@Override
public void defaults(RecipeSpec spec) {
spec.recipe(new FindMinimumDependencyVersion("com.fasterxml.jackson*", "*", "2.14-2.16"));
spec.recipe(new FindMinimumDependencyVersion("com.fasterxml.jackson*", "jackson-core", "2.14-2.16"));
}

@Test
Expand Down Expand Up @@ -117,10 +117,7 @@ void minimumGradle() {
}
""",
"""
/*~~(com.fasterxml.jackson.core:jackson-annotations:2.14.0
com.fasterxml.jackson.core:jackson-core:2.14.0
com.fasterxml.jackson.core:jackson-databind:2.14.0
com.fasterxml.jackson:jackson-bom:2.14.0)~~>*/plugins { id 'java' }
/*~~(com.fasterxml.jackson.core:jackson-core:2.14.0)~~>*/plugins { id 'java' }
repositories { mavenCentral() }
dependencies {
implementation 'com.fasterxml.jackson.core:jackson-databind:2.14.0'
Expand Down

0 comments on commit d7b0833

Please sign in to comment.