Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant versions for Gradle #4492

Merged
merged 6 commits into from
Dec 11, 2024

Conversation

shanman190
Copy link
Contributor

What's changed?

Add recipe to remove redundant versions.

What's your motivation?

A similar feature is available in Maven.

Anything in particular you'd like reviewers to focus on?

Nothing in particular

Anyone you would like to review specifically?

Anybody

Have you considered any alternatives or workarounds?

Forcibly removing versions would result in broken builds.

Any additional context

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

@shanman190 shanman190 added the recipe Requested Recipe label Sep 14, 2024
@shanman190 shanman190 self-assigned this Sep 14, 2024
@shanman190 shanman190 force-pushed the feature/gradle-remove-redundant-versions branch from 9381432 to a70e429 Compare November 27, 2024 21:34
@shanman190
Copy link
Contributor Author

The implementation here is now handling everything except for freestanding scripts which like the other recipes is also spotty for support anyway.

@timtebeek timtebeek self-requested a review November 27, 2024 21:46
@shanman190
Copy link
Contributor Author

The one failing test as described earlier.

RemoveRedundantDependencyVersionsTest > freestandingScript() FAILED
    java.lang.AssertionError: Recipe was expected to make a change but made no changes.
        at org.openrewrite.test.LargeSourceSetCheckingExpectedCycles.afterCycle(LargeSourceSetCheckingExpectedCycles.java:119)
        at org.openrewrite.RecipeScheduler.runRecipeCycles(RecipeScheduler.java:98)
        at org.openrewrite.RecipeScheduler.scheduleRun(RecipeScheduler.java:41)
        at org.openrewrite.Recipe.run(Recipe.java:378)
        at org.openrewrite.test.RewriteTest.rewriteRun(RewriteTest.java:376)
        at org.openrewrite.test.RewriteTest.rewriteRun(RewriteTest.java:132)
        at org.openrewrite.test.RewriteTest.rewriteRun(RewriteTest.java:127)
        at org.openrewrite.gradle.RemoveRedundantDependencyVersionsTest.freestandingScript(RemoveRedundantDependencyVersionsTest.java:216)

shanman190 and others added 6 commits December 10, 2024 20:03
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…onfigurations. Include fix for ChangeDependencyClassifier for G.MapLiteral types
@shanman190 shanman190 force-pushed the feature/gradle-remove-redundant-versions branch from 2abf042 to 630cf5f Compare December 11, 2024 02:38
Comment on lines +124 to +125
public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, ExecutionContext p) {
J.MethodInvocation m = super.visitMethodInvocation(method, p);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, ExecutionContext p) {
J.MethodInvocation m = super.visitMethodInvocation(method, p);
public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) {
J.MethodInvocation m = super.visitMethodInvocation(method, ctx);

Comment on lines +137 to +138
MavenPomDownloader mpd = new MavenPomDownloader(p);
try {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
MavenPomDownloader mpd = new MavenPomDownloader(p);
try {
MavenPomDownloader mpd = new MavenPomDownloader(ctx);
.resolve(Collections.emptyList(), mpd, ctx);

Comment on lines +183 to +184
MavenPomDownloader mpd = new MavenPomDownloader(p);
try {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
MavenPomDownloader mpd = new MavenPomDownloader(p);
try {
MavenPomDownloader mpd = new MavenPomDownloader(ctx);
.resolve(Collections.emptyList(), mpd, ctx);

@shanman190 shanman190 marked this pull request as ready for review December 11, 2024 03:10
@shanman190 shanman190 merged commit bee3e2f into main Dec 11, 2024
2 checks passed
@shanman190 shanman190 deleted the feature/gradle-remove-redundant-versions branch December 11, 2024 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
recipe Requested Recipe
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants