rewrite icon indicating copy to clipboard operation
rewrite copied to clipboard

[Gradle] Support updating dependencies in the `dependencyManagement` block

Open ThomasVitale opened this issue 9 months ago • 4 comments

What problem are you trying to solve?

When running the org.openrewrite.java.dependencies.UpgradeDependencyVersion recipe, BOM dependencies defined in the dependencyManagement block are updated in a Maven project, but not in a Gradle project.

Describe the solution you'd like

I would like to get support in Gradle for updating BOM dependencies, similar to Maven.

Have you considered any alternatives or workarounds?

Gradle projects defining BOM dependencies in the dependencies block as "platform dependencies" are correctly updated. Dropping the dependencyManagement block altogether is definitely an alternative. However, it's not always a good one since "platform dependencies" are configuration specific. In a typical Spring Boot application, it means duplicating the BOM dependencies for each configuration you need (e.g. implementation, runtimeOnly, developmentOnly...).

Are you interested in contributing this feature to OpenRewrite?

Yes, I'm available to contribute this feature to OpenRewrite.

ThomasVitale avatar Apr 13 '25 16:04 ThomasVitale

Hi @ThomasVitale ; Great seeing you here and thanks for the suggestion & offer to help. Let us know how we can best support you with this effort. Typically we find it helps to start an early draft PR with just the tests of what you'd like to see covered, and then we can provide guidance from there.

timtebeek avatar Apr 14 '25 12:04 timtebeek

The recipes in this module combine the recipes for Maven and Gradle, but their actual implementations are in openrewrite/rewrite. Let me know if we should transfer this issue there, as I suspect the work would be in that repository, before it's picked up here.

timtebeek avatar Apr 14 '25 12:04 timtebeek

@timtebeek thanks so much for your support! I guess it makes sense to transfer the issue to openrewrite/rewrite since the main work will be in that repository for the Gradle-specific recipes. Thank you! I can start by submitting a PR with the tests as you suggested.

ThomasVitale avatar Apr 14 '25 20:04 ThomasVitale

I added a couple of tests to show the issue:

  • https://github.com/openrewrite/rewrite/pull/5304

ThomasVitale avatar Apr 15 '25 20:04 ThomasVitale

This issue is stale because it has not had any activity for 60 days. Remove question label or comment or this will be closed in two weeks. Issues may be reopened when there is renewed interest.

github-actions[bot] avatar Jul 28 '25 11:07 github-actions[bot]

A PR has been submitted to address this issue by @Jenson3210 in https://github.com/openrewrite/rewrite/pull/5623. It's pending review. More context in https://github.com/openrewrite/rewrite/pull/5304#issuecomment-2971954971

ThomasVitale avatar Jul 28 '25 11:07 ThomasVitale

Apologies! The bot didn't quite behave as we had wanted to; it wasn't support to add tags, only evaluate already tagged questions.

Hope all is well there, and thanks for the help!

timtebeek avatar Jul 28 '25 11:07 timtebeek

I just merged that linked PR, hopefully that helps

sambsnyd avatar Jul 28 '25 16:07 sambsnyd

Picking up the downstream option in

  • https://github.com/openrewrite/rewrite-java-dependencies/pull/145

timtebeek avatar Jul 28 '25 17:07 timtebeek

Thanks all! Hope that has you going. :)

timtebeek avatar Jul 28 '25 17:07 timtebeek

Thanks so much!

ThomasVitale avatar Jul 28 '25 19:07 ThomasVitale