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

Error during resolving unused dependency #5136

Open
SiBorea opened this issue Mar 6, 2025 · 6 comments
Open

Error during resolving unused dependency #5136

SiBorea opened this issue Mar 6, 2025 · 6 comments
Labels
bug Something isn't working

Comments

@SiBorea
Copy link
Contributor

SiBorea commented Mar 6, 2025

I am using

  • OpenRewrite v8.42.0
  • Mavenplugin v6.2.2

How are you running OpenRewrite?

I am using Maven plugin to run OpenRewrite

        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-rest-java-client-api</artifactId>
            <version>5.0.4</version>
        </dependency>

What did you expect to see?

Running normally.

What did you see instead?

Unable to resolve dependency of com.atlassian.httpclient:atlassian-httpclient-api:0.22.3, which is introduced by com.atlassian.platform:platform:3.1.7 in dependencyManagement.
jira-rest-java-client-api defined com.atlassian.httpclient:atlassian-httpclient-api:1.0.0 in its own pom.
And com.atlassian.httpclient:atlassian-httpclient-api:0.22.3 is not in our central.

@SiBorea SiBorea added the bug Something isn't working label Mar 6, 2025
@SiBorea
Copy link
Contributor Author

SiBorea commented Mar 6, 2025

This error can be ignored by commenting this out: https://github.com/openrewrite/rewrite-maven-plugin/blob/e30c8e7afdc3c30d13a0237d5fcea8a7680a9a63/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java#L588
Will there be any concerns if I do so? I suppose we can add a parameter to leave user decide

@knutwannheden
Copy link
Contributor

I think you raise a very good point here: If an unresolvable dependency is listed in a dependency management section, this should not cause any issues, if this dependency isn't actually used anywhere.

Thanks for reporting this!

@knutwannheden
Copy link
Contributor

Actually, it seems like OpenRewrite already allows for this. Can you maybe provide some more details of your setup or maybe even a test case to reproduce the issue?

@SiBorea
Copy link
Contributor Author

SiBorea commented Mar 6, 2025

Actually, it seems like OpenRewrite already allows for this. Can you maybe provide some more details of your setup or maybe even a test case to reproduce the issue?

You can create an empty maven project, and add that dependency only. Run OpenRewrite on it with maven plugin

@knutwannheden
Copy link
Contributor

What repo would I use for the test, as this artifact isn't published on Maven Central? I don't get any failures when I have this:

<project>
    <groupId>com.mycompany.app</groupId>
    <artifactId>my-app</artifactId>
    <version>1</version>
    <repositories>
        <repository>
            <id>some-repo</id>
            <url>https://packages.atlassian.com/maven-public/</url>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-rest-java-client-api</artifactId>
            <version>5.0.4</version>
        </dependency>
    </dependencies>
</project>

@SiBorea
Copy link
Contributor Author

SiBorea commented Mar 7, 2025

Oh, I see the problem. com.atlassian.httpclient:atlassian-httpclient-api:0.22.3 doesn't exist in our company's central, but in public maven central.

You may have to create such a scenario:
A contains dependencyManagement B and dependency C (of version C1)
B contains dependency C (of version C2)
B is not actually used in the project
C1 is exist in central while C2 is not

In my case:
A=com.atlassian.jira:jira-rest-java-client-api:5.0.4
B=com.atlassian.platform:platform:3.1.7
C1=com.atlassian.httpclient:atlassian-httpclient-api:1.0.0
C2=com.atlassian.httpclient:atlassian-httpclient-api:0.22.3

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

2 participants