openrewrite / openrewrite/rewrite

Recipe to use managed dependency versions

Open
#3,290 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

recipe
Dominant language
Java
Stars
3.7k
Forks
570
Avg merge
13h 12m
Merged PRs (30d)
261

Description

What problem are you trying to solve?

Many builds, including ours, find it convenient to manage dependency versions via a Bill of Materials (BOM).
Amongst our Maven dependency management recipes we have org.openrewrite.maven.ManagedDependencies which provides this functionality for Maven. A Gradle equivalent is desirable.

What precondition(s) should be checked before applying this recipe?

The DependencyHandler.platform() function was added to Gradle in version 5.0. This recipe is inapplicable to earlier versions of Gradle.

Describe the situation before applying the recipe

Assuming the recipe were being configured to manage rewrite versions via rewrite-bom, a build.gradle file might look like this:

dependencies {
    implementation("org.openrewrite:rewrite-core:latest.release")
}

Describe the situation after applying the recipe

dependencies {
    implementation(platform("org.openrewrite:rewrite-bom:latest.release"))
    implementation("org.openrewrite:rewrite-core")
}

Any additional context

After this recipe is created a composite of it and its maven equivalent should be added to rewrite-java-dependencies

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing org.openrewrite.maven.ManagedDependencies recipe and the rewrite-java-dependencies composite. Check how build.gradle dependencies are represented and how DependencyHandler.platform() applies for Gradle 5.0 and later. Done means a Gradle recipe produces the shown BOM platform dependency and removes the managed version from the original dependency.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.