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

Gradle ChangeDependency behaves incorrectly, if new dependency exists #4521

Open
ashakirin opened this issue Sep 24, 2024 · 2 comments
Open
Labels
enhancement New feature or request

Comments

@ashakirin
Copy link
Contributor

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"
@ashakirin ashakirin added the enhancement New feature or request label Sep 24, 2024
@timtebeek
Copy link
Contributor

Sounds like you're uncovering quite some edge cases over there! Appreciate you reporting these here and already tackling the Maven side of things in

@ashakirin
Copy link
Contributor Author

PR was suggested: #4523

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Backlog
Development

No branches or pull requests

2 participants