openrewrite / rewrite-gradle-plugin

OpenRewrite's Gradle plugin.
Apache License 2.0
60 stars 37 forks source link

upgrade to springboot 2.7 fails for gradle project #275

Closed Sanskarbajaj closed 7 months ago

Sanskarbajaj commented 7 months ago

What went wrong: Execution failed for task ':rewriteRun'.

java.lang.RuntimeException: Error while visiting \build.gradle: java.lang.RuntimeException: java.io.UncheckedIOException: java.net.UnknownHostException: repo.maven.apache.org org.openrewrite.maven.internal.MavenPomDownloader.requestAsAuthenticatedOrAnonymous(MavenPomDownloader.java:802) org.openrewrite.maven.internal.MavenPomDownloader.downloadMetadata(MavenPomDownloader.java:254) org.openrewrite.maven.internal.MavenPomDownloader.downloadMetadata(MavenPomDownloader.java:210) org.openrewrite.gradle.plugins.AddPluginVisitor.downloadMetadata(AddPluginVisitor.java:95) org.openrewrite.gradle.plugins.AddPluginVisitor.findNewerVersion(AddPluginVisitor.java:85) org.openrewrite.gradle.plugins.AddPluginVisitor.resolvePluginVersion(AddPluginVisitor.java:77) org.openrewrite.gradle.plugins.UpgradePluginVersion$3.visitMethodInvocation(UpgradePluginVersion.java:257) org.openrewrite.gradle.plugins.UpgradePluginVersion$3.visitMethodInvocation(UpgradePluginVersion.java:206) org.openrewrite.java.tree.J$MethodInvocation.acceptJava(J.java:3932) org.openrewrite.java.tree.J.accept(J.java:59) org.openrewrite.TreeVisitor.visit(TreeVisitor.java:278) org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:361) org.openrewrite.java.JavaVisitor.visitRightPadded(JavaVisitor.java:1375) org.openrewrite.java.JavaVisitor.lambda$visitBlock$4(JavaVisitor.java:401) org.openrewrite.internal.ListUtils.map(ListUtils.java:176) org.openrewrite.java.JavaVisitor.visitBlock(JavaVisitor.java:400)

timtebeek commented 7 months ago

The recipes connect to Maven Central to download updated dependencies and plugins. Here it seems Maven Central is not accessible from your machine, unrelated to OpenRewrite. Might you have some company network policies that get in the way? Also welcome to ask questions via Slack, or Stack overflow, as those are more geared towards questions.

Sanskarbajaj commented 7 months ago

other recipies also i'm trying those working well like junit4 to 5 and all

timtebeek commented 7 months ago

Are you saying that other recipes work just fine, and it's just the upgrade to Spring Boot 2.7 recipe that fails for you? Does it repeatedly fail? Since I can access https://repo.maven.apache.org just fine here. How's that for you?

Sanskarbajaj commented 7 months ago

yes other recipies work fine this didn't work not even one time for me maybe something i'm doing wrong and get the error i pasted earlier and yes i can access the link you sent

shanman190 commented 7 months ago

So there are two parts here, I think.

Sanskarbajaj commented 7 months ago

i think its the second issue that you mentioned how to fix this any idea? @shanman190 @timtebeek

shanman190 commented 7 months ago

@Sanskarbajaj, from just your stack trace alone the issue that you're presently facing is the first one for sure. Specifically the java.net.UnknownHostException is only thrown when the specified DNS address cannot be resolved.

The second one only appears -- and furthermore it appears as an instance of org.openrewrite.maven.MavenDownloadingException -- if you have multiple build.gradle files with different repositories across them. It would specifically present as being unable to resolve a specific dependency because it is unavailable in any of the set of used repositories. The bug in particular originates from finding and then reusing the first GradleProject marker that was found across the entire project rather than the one specific to the current build.gradle file that was being visited. The fix for this will be available in the next rewrite and rewrite-gradle-plugin releases.

Sanskarbajaj commented 7 months ago

Execution failed for task ':rewriteRun'.

java.lang.RuntimeException: Error while visiting clients\build.gradle: java.lang.RuntimeException: java.io.UncheckedIOException: java.net.UnknownHostException: repo.maven.apache.org org.openrewrite.maven.internal.MavenPomDownloader.requestAsAuthenticatedOrAnonymous(MavenPomDownloader.java:808) org.openrewrite.maven.internal.MavenPomDownloader.downloadMetadata(MavenPomDownloader.java:255) org.openrewrite.maven.internal.MavenPomDownloader.downloadMetadata(MavenPomDownloader.java:211) org.openrewrite.gradle.plugins.AddPluginVisitor.downloadMetadata(AddPluginVisitor.java:95) org.openrewrite.gradle.plugins.AddPluginVisitor.findNewerVersion(AddPluginVisitor.java:85) org.openrewrite.gradle.plugins.AddPluginVisitor.resolvePluginVersion(AddPluginVisitor.java:77) org.openrewrite.gradle.plugins.UpgradePluginVersion$3.visitMethodInvocation(UpgradePluginVersion.java:257) org.openrewrite.gradle.plugins.UpgradePluginVersion$3.visitMethodInvocation(UpgradePluginVersion.java:206) org.openrewrite.java.tree.J$MethodInvocation.acceptJava(J.java:3932) org.openrewrite.java.tree.J.accept(J.java:59) org.openrewrite.TreeVisitor.visit(TreeVisitor.java:278) org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:361) org.openrewrite.java.JavaVisitor.visitRightPadded(JavaVisitor.java:1375) org.openrewrite.java.JavaVisitor.lambda$visitBlock$4(JavaVisitor.java:401) org.openrewrite.internal.ListUtils.map(ListUtils.java:176) org.openrewrite.java.JavaVisitor.visitBlock(JavaVisitor.java:400)

the error im getting also related to upgradepluginversion only right? i've made it bold could you please check @shanman190 @timtebeek

Sanskarbajaj commented 7 months ago

and other recipies like move from java 8 to 17 junit 4 to 5 and all are working so its not related to proxy or its not able to access any particular DNS address

shanman190 commented 7 months ago

Just letting you know that 8.16.0 was released a few days ago, so the fix for the secondary issues of the Gradle recipes also trying Maven Central and incorrectly using the first project's repositories was contained within that release.

Sanskarbajaj commented 7 months ago

What's the latest version of gradle plugin? @shanman190 For the moment I'm using 6.8.2 I couldn't find any latest version in docs could you please help

timtebeek commented 7 months ago

The latest version is still 6.8.2, and can always be found here: https://github.com/openrewrite/rewrite-gradle-plugin/releases

We'll follow up with a matching Gradle plugin release soon such that you can try out the above 8.16.0 release.

Sanskarbajaj commented 7 months ago

What went wrong: Execution failed for task ':rewriteRun'.

org.openrewrite.RecipeException: Recipes not found:

could you help in this when i'm writing my rewrite.yaml file i give some other name to the recipie

and running command with -Drewrite.configLocation="$PWD/rewrite.yml" its not picking it up any idea ? @shanman190 @timtebeek

timtebeek commented 7 months ago

The -Drewrite.configLocation= path should not be absolute, but relative to your project root. If it's ./rewrite.yml there's no need to pass in any -Drewrite.configLocation explicitly.

Sanskarbajaj commented 7 months ago

The -Drewrite.configLocation= path should not be absolute, but relative to your project root. If it's ./rewrite.yml there's no need to pass in any -Drewrite.configLocation explicitly.

yeah the path is ./rewrite.yml but its not taking . even tried without passing -Drewrite.configLocation

shanman190 commented 7 months ago

To start of with here is the published guide for running a Gradle build without modifying the Gradle build. https://docs.openrewrite.org/running-recipes/running-rewrite-on-a-gradle-project-without-modifying-the-build

In that setup there are 3 important things to note:

Sanskarbajaj commented 7 months ago

:rewriteRun (Thread[Execution worker for ':',5,main]) started.

Task :rewriteRun Caching disabled for task ':rewriteRun' because: Build cache is disabled Task ':rewriteRun' is not up-to-date because: Task has not declared any outputs despite executing actions.

Task :rewriteRun FAILED :rewriteRun (Thread[Execution worker for ':',5,main]) completed. Took 8.092 secs.

FAILURE: Build failed with an exception.

this is what i'm getting i've tried putting rewrite.yml in root directory in src directory but its not picking it up

Sanskarbajaj commented 7 months ago

please help @shanman190 @timtebeek