Conversation
…d with glob pattern When ChangeDependencyGroupIdAndArtifactId is invoked with a wildcard oldArtifactId (e.g. "swagger-*") and newArtifactId=null, the managed dependency handler incorrectly overwrites the artifactId XML tag with the literal glob string instead of preserving the original value. Only change groupId/artifactId tags when the new value actually differs from the old value. When they match (glob passthrough), preserve the original tag value. Also read actual groupId/artifactId from the XML tag for version resolution instead of using potentially-glob values.
ChangeManagedDependencyGroupIdAndArtifactId overwriting artifactId with glob pattern
...e-maven/src/main/java/org/openrewrite/maven/ChangeManagedDependencyGroupIdAndArtifactId.java
Show resolved
Hide resolved
92ffd14 to
e2bedca
Compare
| String resolvedGroupId = t.getChildValue("groupId").orElse(newGroupId != null ? newGroupId : oldGroupId); | ||
| String resolvedArtifactId = t.getChildValue("artifactId").orElse(newArtifactId != null ? newArtifactId : oldArtifactId); | ||
| if (resolvedArtifactId.contains("${")) { | ||
| ResolvedPom pom = getResolutionResult().getPom(); |
Contributor
There was a problem hiding this comment.
Could reduce some repetition if we extract this outside of the if and use it here, in the next if and for the getValue(..) call for setting the resolvedNewVersion
e2bedca to
6bc827f
Compare
...ven/src/test/java/org/openrewrite/maven/ChangeManagedDependencyGroupIdAndArtifactIdTest.java
Show resolved
Hide resolved
steve-aom-elliott
approved these changes
Feb 20, 2026
…ation ChangeDependencyGroupIdAndArtifactId was passing glob patterns (e.g. "swagger-*") as concrete newArtifactId/newGroupId values when delegating to ChangeManagedDependencyGroupIdAndArtifactId. Fix the root cause by making newGroupId/newArtifactId nullable (null = preserve existing value) and passing them directly instead of falling back to old glob values. Also move the duplicate dependency check from visitDocument into visitTag so it uses the actual tag coordinates rather than potentially-null or glob new values.
7e033d4 to
de82343
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ChangeManagedDependencyGroupIdAndArtifactIdincorrectly overwriting theartifactIdXML tag with a literal glob string (e.g.swagger-*) whenChangeDependencyGroupIdAndArtifactIdis invoked with a wildcardoldArtifactIdandnewArtifactId=nullgroupId/artifactIdtags when the new value actually differs from the old value; when they match (glob passthrough), preserve the original tag valuegroupId/artifactIdfrom the XML tag for version resolution instead of using potentially-glob valuesTest plan
globArtifactIdRetainedWhenNewMatchesOldtest inChangeManagedDependencyGroupIdAndArtifactIdTestChangeManagedDependencyGroupIdAndArtifactIdTesttests passChangeDependencyGroupIdAndArtifactIdTesttests passrewrite-maventest suite passes