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

Failed to resolve dependencies #862

Open
philippe-granet opened this issue Sep 14, 2024 · 4 comments
Open

Failed to resolve dependencies #862

philippe-granet opened this issue Sep 14, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@philippe-granet
Copy link
Contributor

What version of OpenRewrite are you using?

I am using latest maven plugin version v5.40.2

How are you running OpenRewrite?

I am using the Maven plugin in CLI

mvn org.openrewrite.maven:rewrite-maven-plugin:run -Drewrite.activeRecipes=org.openrewrite.maven.BestPractices

What is the smallest, simplest way to reproduce the problem?

When I run mvn dependency:tree, I see my app depends on org.jetbrains:annotations:jar:24.1.0:compile:

mvn dependency:tree
...
[INFO] --------------------< org.openrewrite.test:module1 >--------------------
[INFO] Building module1 1.1-SNAPSHOT                                      [2/2]
[INFO]   from module1/pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- dependency:3.7.0:tree (default-cli) @ module1 ---
[INFO] org.openrewrite.test:module1:jar:1.1-SNAPSHOT
[INFO] \- org.openrewrite.test:starter-security-client-webmvc:jar:1.0:compile
[INFO]    \- org.openrewrite.test:starter-security-common:jar:1.0:compile
[INFO]       \- org.jetbrains:annotations:jar:24.1.0:compile

But when I run openrewrite on my app with this command:

mvn org.openrewrite.maven:rewrite-maven-plugin:run -Drewrite.activeRecipes=org.openrewrite.maven.BestPractices

it failed with this error:
MavenDownloadingException: org.jetbrains:annotations failed. No version provided

To reproduce the problem, I create an exemple from my project.
Unzip this (only poms inside): openrewrite-bug.zip

and run these commands:

cd lib
mvn clean install
cd ../app
mvn clean install
mvn dependency:tree
mvn org.openrewrite.maven:rewrite-maven-plugin:run -Drewrite.activeRecipes=org.openrewrite.maven.BestPractices

What did you expect to see?

No errors :-)

What did you see instead?

This error, it can't find version of org.jetbrains:annotations dependency:

[ERROR] Failed to execute goal org.openrewrite.maven:rewrite-maven-plugin:5.40.2:run (default-cli) on project module1: Failed to parse or resolve the Maven POM file or one of its dependencies; We can not reliably continue without this information.: Failed to parse or resolve the Maven POM file or one of its dependencies; We can not reliably continue without this information.
[ERROR] <?xml version="1.0" encoding="UTF-8"?>
[ERROR] <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
[ERROR]          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
[ERROR]     <modelVersion>4.0.0</modelVersion>
[ERROR]
[ERROR]     <parent>
[ERROR]         <groupId>org.openrewrite.test</groupId>
[ERROR]         <artifactId>app</artifactId>
[ERROR]         <version>1.1-SNAPSHOT</version>
[ERROR]     </parent>
[ERROR]
[ERROR]     <groupId>org.openrewrite.test</groupId>
[ERROR]     <artifactId>module1</artifactId>
[ERROR]     <packaging>jar</packaging>
[ERROR]
[ERROR]     <dependencies>
[ERROR]         <!--~~(org.jetbrains:annotations failed. No version provided)~~>--><dependency>
[ERROR]             <groupId>org.openrewrite.test</groupId>
[ERROR]             <artifactId>starter-security-client-webmvc</artifactId>
[ERROR]             <version>1.0</version>
[ERROR]             <scope>compile</scope>
[ERROR]         </dependency>
[ERROR]     </dependencies>
[ERROR] </project>
[ERROR] org.openrewrite.maven.MavenDownloadingExceptions: null
[ERROR]   org.openrewrite.maven.MavenDownloadingExceptions.append(MavenDownloadingExceptions.java:44)
[ERROR]   org.openrewrite.maven.tree.MavenResolutionResult.resolveDependencies(MavenResolutionResult.java:178)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :module1

What is the full stack trace of any errors you encountered?

[INFO] Project [app] Resolving Poms...
[DEBUG] Downloaded org.openrewrite.test:java:1.0 from org.openrewrite.test:app:1.1-SNAPSHOT
[DEBUG] Downloaded org.openrewrite.test:pom:1.0 from org.openrewrite.test:app:1.1-SNAPSHOT
[DEBUG] Downloaded org.openrewrite.test:bom-pom:1.0 from org.openrewrite.test:app:1.1-SNAPSHOT
[DEBUG] Downloaded org.openrewrite.test:lib:1.0 from org.openrewrite.test:app:1.1-SNAPSHOT
[DEBUG] Downloaded org.openrewrite.test:all-bom:1.0 from org.openrewrite.test:app:1.1-SNAPSHOT
[DEBUG] Downloaded org.openrewrite.test:bom:1.0 from org.openrewrite.test:all-bom:1.0
[DEBUG] Downloaded org.openrewrite.test:commons-bom:1.0 from org.openrewrite.test:all-bom:1.0
[DEBUG] Downloaded org.openrewrite.test:libs-bom:1.0 from org.openrewrite.test:all-bom:1.0
[DEBUG] Downloaded org.openrewrite.test:starter-security-client-webmvc:1.0 from org.openrewrite.test:module1:1.1-SNAPSHOT
[DEBUG] Downloaded org.openrewrite.test:starter-security:1.0 from org.openrewrite.test:starter-security-client-webmvc:1.0
[DEBUG] Downloaded org.openrewrite.test:starters:1.0 from org.openrewrite.test:starter-security-client-webmvc:1.0
[DEBUG] Downloaded org.openrewrite.test:starter-security-common:1.0 from org.openrewrite.test:starter-security-client-webmvc:1.0
[DEBUG]
org.openrewrite.maven.MavenDownloadingExceptions
    at org.openrewrite.maven.MavenDownloadingExceptions.append (MavenDownloadingExceptions.java:44)
    at org.openrewrite.maven.tree.MavenResolutionResult.resolveDependencies (MavenResolutionResult.java:178)
    at org.openrewrite.maven.MavenParser.parseInputs (MavenParser.java:116)
    at org.openrewrite.Parser.parse (Parser.java:59)
    at org.openrewrite.maven.MavenMojoProjectParser.parseMaven (MavenMojoProjectParser.java:553)
    at org.openrewrite.maven.MavenMojoProjectParser.listSourceFiles (MavenMojoProjectParser.java:146)
    at org.openrewrite.maven.AbstractRewriteBaseRunMojo.loadSourceSet (AbstractRewriteBaseRunMojo.java:236)
    at org.openrewrite.maven.AbstractRewriteBaseRunMojo.listResults (AbstractRewriteBaseRunMojo.java:152)
    at org.openrewrite.maven.AbstractRewriteRunMojo.execute (AbstractRewriteRunMojo.java:64)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:903)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:280)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:203)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:255)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:201)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:361)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:314)
    Suppressed: org.openrewrite.maven.MavenDownloadingException: org.jetbrains:annotations failed. No version provided
        at org.openrewrite.maven.tree.ResolvedPom.resolveDependencies (ResolvedPom.java:874)
        at org.openrewrite.maven.tree.ResolvedPom.resolveDependencies (ResolvedPom.java:845)
        at org.openrewrite.maven.tree.MavenResolutionResult.resolveDependencies (MavenResolutionResult.java:173)
        at org.openrewrite.maven.MavenParser.parseInputs (MavenParser.java:116)
        at org.openrewrite.Parser.parse (Parser.java:59)
        at org.openrewrite.maven.MavenMojoProjectParser.parseMaven (MavenMojoProjectParser.java:553)
        at org.openrewrite.maven.MavenMojoProjectParser.listSourceFiles (MavenMojoProjectParser.java:146)
        at org.openrewrite.maven.AbstractRewriteBaseRunMojo.loadSourceSet (AbstractRewriteBaseRunMojo.java:236)
        at org.openrewrite.maven.AbstractRewriteBaseRunMojo.listResults (AbstractRewriteBaseRunMojo.java:152)
        at org.openrewrite.maven.AbstractRewriteRunMojo.execute (AbstractRewriteRunMojo.java:64)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
        at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
        at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
        at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
        at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
        at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
        at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
        at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
        at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
        at org.apache.maven.cli.MavenCli.execute (MavenCli.java:903)
        at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:280)
        at org.apache.maven.cli.MavenCli.main (MavenCli.java:203)
        at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
        at java.lang.reflect.Method.invoke (Method.java:580)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:255)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:201)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:361)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:314)
@philippe-granet philippe-granet added the bug Something isn't working label Sep 14, 2024
@HelloDhero
Copy link

Setting the parameter -Drewrite.pomCacheEnabled=false may solve the problem

@philippe-granet
Copy link
Contributor Author

Same problem with -Drewrite.pomCacheEnabled=false parameter

@timtebeek
Copy link
Contributor

Hi @philippe-granet ; Appreciate the level of detail in your report. Is there any way to reproduce the problem in a smaller example? Since 14 poms is quite a bit to wrap my head around. Ideally this is reproduced in a unit test. Note that we have mechanisms to reproduce this in unit tests in openrewrite/rewrite in our Assertions classes

https://github.com/openrewrite/rewrite/blob/a98d83d698dda9971c93a0767b7f85d5866f306d/rewrite-java/src/main/java/org/openrewrite/java/Assertions.java#L131-L137

https://github.com/openrewrite/rewrite/blob/50cb39c5da3362d1eed4d6ec4562177f007becb0/rewrite-maven/src/main/java/org/openrewrite/maven/Assertions.java#L45-L70

@philippe-granet
Copy link
Contributor Author

@timtebeek I have reproduce the problem with only 3 simples poms:
openrewrite-bug.zip

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

3 participants