Skip to content

RemoveRedundantDependencyVersions recipe removes unused properties#5645

Merged
jkschneider merged 17 commits intomainfrom
remove-redundant-dependencies-remove-unused-properties-as-well
Jan 26, 2026
Merged

RemoveRedundantDependencyVersions recipe removes unused properties#5645
jkschneider merged 17 commits intomainfrom
remove-redundant-dependencies-remove-unused-properties-as-well

Conversation

@jevanlingen
Copy link
Copy Markdown
Contributor

What's changed?

RemoveRedundantDependencyVersions recipe removes unused properties if the recipe removes a version with said properties.

What's your motivation?

After the recipe in its current state has run, it's possible there are now properties in the properties block that are no longer used.

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

… the recipe removes a version with said properties
@jevanlingen jevanlingen requested a review from Laurens-W June 20, 2025 08:04
@jevanlingen jevanlingen self-assigned this Jun 20, 2025
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Jun 20, 2025
@jevanlingen jevanlingen added enhancement New feature or request recipe Requested Recipe labels Jun 20, 2025
@jevanlingen jevanlingen requested a review from jkschneider June 20, 2025 08:06
@jevanlingen
Copy link
Copy Markdown
Contributor Author

Don't merge until @jkschneider has time to review. No high priority either to get this merged!

Comment on lines +1899 to +1901
<properties>
<spring-web.version>5.3.9</spring-web.version>
</properties>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some concerns about removing properties like this; in a multi module project we could remove a property from a parent that's still used in a child project, since doAfterVisit can only look at a single source file.

Copy link
Copy Markdown
Contributor Author

@jevanlingen jevanlingen Jun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, you are right about this. Added a test to reflect this problem: 6aa0e64.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would a

getResolutionResult().getPom().getPackaging().equals("jar")

check be enough?

@jevanlingen jevanlingen marked this pull request as draft June 20, 2025 09:27
@jevanlingen jevanlingen marked this pull request as ready for review June 20, 2025 10:15
@jevanlingen jevanlingen moved this from In Progress to Ready to Review in OpenRewrite Jun 20, 2025
…ndencies-remove-unused-properties-as-well

# Conflicts:
#	rewrite-maven/src/test/java/org/openrewrite/maven/RemoveRedundantDependencyVersionsTest.java
github-actions[bot]

This comment was marked as spam.

jevanlingen and others added 3 commits September 5, 2025 08:21
…antDependencyVersions.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…aceholderHelper.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 8, 2025

This PR is stale because it has been open for 90 days with no activity. Remove stale label or comment or this will be closed in two weeks. PRs may be reopened when there is renewed interest.

@github-actions github-actions Bot added the Stale label Dec 8, 2025
@github-actions github-actions Bot removed the Stale label Dec 15, 2025
Copy link
Copy Markdown
Member

@jkschneider jkschneider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. This properly cleans up orphaned properties when removing redundant dependency versions, addressing the customer concern in #1291.

Good handling of:

  • Multiple properties in a single version string
  • Shared properties across dependencies
  • Excluding pom packaging to avoid breaking child projects

@jkschneider jkschneider merged commit e0d7e9a into main Jan 26, 2026
2 checks passed
@jkschneider jkschneider deleted the remove-redundant-dependencies-remove-unused-properties-as-well branch January 26, 2026 13:32
@github-project-automation github-project-automation Bot moved this from Ready to Review to Done in OpenRewrite Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request recipe Requested Recipe

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants