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

RemoveDuplicateDependencies Removes Dependency with Classifier, Breaking Maven Build #4868

Open
torsten-liermann opened this issue Jan 8, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@torsten-liermann
Copy link

What version of OpenRewrite are you using?

8.42.4

I am using

  • OpenRewrite v8.42.4
  • Maven/Gradle plugin v5.47.3
  • rewrite-module v2.31.0

How are you running OpenRewrite?

mvnw org.openrewrite.maven:rewrite-maven-plugin:5.47.3:run -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-migrate-java:LATEST -Drewrite.activeRecipes=org.openrewrite.maven.RemoveDuplicateDependencies

The issue can be reproduced: https://github.com/torsten-liermann/orw-problem-removeduplicatesdependencies

RemoveDuplicateDependencies mistakenly removes a dependency from the dependency management. The peculiarity of this dependency is that it appears twice in the dependency management: once with a classifier and once without a classifier. Depending on the order of these two dependencies, one of them gets removed, resulting in a non-functional build. The demo contains the setup that triggers this error.

         <dependencyManagement>
              <dependencies>
                <dependency>
                        <groupId>com.adobe.aio.cloudmanager</groupId>
                        <artifactId>aio-lib-cloudmanager</artifactId>
                        <classifier>java8</classifier>
                        <version>2.0.0</version>
                </dependency>
                <dependency>
                        <groupId>com.adobe.aio.cloudmanager</groupId>
                        <artifactId>aio-lib-cloudmanager</artifactId>
                        <version>2.0.0</version>
                </dependency>
            </dependencies>
        </dependencyManagement>

Reordering the dependencies resolves the issue.

        <dependencyManagement>
              <dependencies>
                <dependency>
                        <groupId>com.adobe.aio.cloudmanager</groupId>
                        <artifactId>aio-lib-cloudmanager</artifactId>
                        <version>2.0.0</version>
                </dependency>
                <dependency>
                        <groupId>com.adobe.aio.cloudmanager</groupId>
                        <artifactId>aio-lib-cloudmanager</artifactId>
                        <classifier>java8</classifier>
                        <version>2.0.0</version>
                </dependency>
            </dependencies>
        </dependencyManagement>
@torsten-liermann torsten-liermann added the bug Something isn't working label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: No status
Development

No branches or pull requests

1 participant