openrewrite / openrewrite/rewrite

Create `UpgradeDependencyConstraintVersion` recipe

Open
#5,757 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

gradle 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?

Enable updating dependency constraints which include first orders. In particular, Gradle projects that use the java-platform plugin declare all of their managed dependencies as constraints, so being able to update these build scripts is the goal.

NOTE: I'm considering using constraints for first order dependencies declared in the current project as out of scope even though this recipe would technically work for those cases.

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

I could potentially see restricting the recipe to only build scripts that contain the java-platform plugin, but as the additional note above there is some overlap with a Gradle practice, albeit not a best practice.

Describe the situation before applying the recipe

plugins {
  id "java-platform"
}

dependencies {
  constraints {
    api("com.google.guava:guava:29.0-jre")
  }
}

Describe the situation after applying the recipe

plugins {
  id "java-platform"
}

dependencies {
  constraints {
    api("com.google.guava:guava:31.0-jre")
  }
}

Have you considered any alternatives or workarounds?

N/A

Any additional context

None

Are you interested in contributing this recipe to OpenRewrite?

Always.

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 from the Gradle build-script example in the issue and verify how the java-platform plugin represents dependency constraints. Decide whether the recipe should require that plugin or also handle first-order project constraints. Done means updating the constraint version from 29.0-jre to 31.0-jre without changing unrelated declarations.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.