Skip to content

Gradle ChangeDependency behaves incorrectly, if new dependency exists #4521

Open
@ashakirin

Description

Gradle ChangeDependency shows following result, if new dependency was already defined:

        rewriteRun(
          spec -> spec.recipe(new ChangeDependency("commons-lang", "commons-lang", "org.apache.commons", "commons-lang3", "3.11.x", null, null)),
          buildGradle(
            """
              plugins {
                  id "java-library"
              }
              
              repositories {
                  mavenCentral()
              }
              
              dependencies {
                 implementation "org.apache.commons:commons-lang3:2.6"
                 implementation group: "org.apache.commons", name: "commons-lang3", version: "2.6"
                 implementation "org.apache.commons:commons-lang3:3.11"
              }
              """,
            """
              plugins {
                  id "java-library"
              }
              
              repositories {
                  mavenCentral()
              }
              
              dependencies {
                  implementation "commons-lang:commons-lang:2.6"
                  implementation group: "org.apache.commons", name: "commons-lang3", version: "2.6"
                  implementation "org.apache.commons:commons-lang3:3.11"
              }
              """

Recipe replaced commons-lang:commons-lang with new groupId and artifactId, but kept the version from old dependency.
Expected behavior will be just remove old dependency in this case:

                 implementation "org.apache.commons:commons-lang3:3.11"

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    • Status

      Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions