Closed k3code06 closed 6 months ago
Hi @AnkitaJain06, 5.40.0 is a very old version of the plugin and there are a number of Gradle specific (ie. Not OpenRewrite specific) issues that can lead to not being able to apply a plugin or create an extension object. The current information provided doesn't provide any useful bits to help you with what's going on there.
Regardless, I'd advise using the latest OpenRewrite plugin with your project as you'll have much better luck with it and there are numerous changes upstream in rewrite proper for parsing and operating on the OpenRewrite LST model that would not be available with your current plugin version.
I have also tried using the latest version (6.1.19) and still having the same error. What's the recommended gradle version for this dependency?
On running gradle build, this error comes up.
Caused by: org.gradle.internal.instantiation.ClassGenerationException: Could not generate a decorated class for type RewritePlugin.
at org.gradle.internal.instantiation.generator.AbstractClassGenerator.generateUnderLock(AbstractClassGenerator.java:255)
at org.gradle.cache.internal.DefaultCrossBuildInMemoryCacheFactory$AbstractCrossBuildInMemoryCache.get(DefaultCrossBuildInMemoryCacheFactory.java:130)
at org.gradle.internal.instantiation.generator.AbstractClassGenerator.generate(AbstractClassGenerator.java:181)
at org.gradle.internal.instantiation.generator.AsmBackedClassGenerator.generate(AsmBackedClassGenerator.java:121)
at org.gradle.internal.instantiation.generator.Jsr330ConstructorSelector.lambda$forType$0(Jsr330ConstructorSelector.java:56)
at org.gradle.cache.Cache.lambda$get$0(Cache.java:31)
at org.gradle.cache.internal.DefaultCrossBuildInMemoryCacheFactory$AbstractCrossBuildInMemoryCache.get(DefaultCrossBuildInMemoryCacheFactory.java:130)
at org.gradle.cache.Cache.get(Cache.java:31)
at org.gradle.internal.instantiation.generator.Jsr330ConstructorSelector.forType(Jsr330ConstructorSelector.java:53)
at org.gradle.internal.instantiation.generator.Jsr330ConstructorSelector.forParams(Jsr330ConstructorSelector.java:48)
at org.gradle.internal.instantiation.generator.DependencyInjectingInstantiator.doCreate(DependencyInjectingInstantiator.java:61)
at org.gradle.internal.instantiation.generator.DependencyInjectingInstantiator.newInstance(DependencyInjectingInstantiator.java:55)
at org.gradle.api.internal.plugins.DefaultPluginManager.instantiatePlugin(DefaultPluginManager.java:83)
... 189 more
Caused by: java.lang.NoClassDefFoundError: org/openrewrite/gradle/RewriteExtension
at org.gradle.internal.reflect.ClassInspector.inspectClass(ClassInspector.java:70)
at org.gradle.internal.reflect.ClassInspector.visitGraph(ClassInspector.java:56)
at org.gradle.internal.reflect.ClassInspector.inspect(ClassInspector.java:36)
at org.gradle.internal.instantiation.generator.AbstractClassGenerator.inspectType(AbstractClassGenerator.java:284)
at org.gradle.internal.instantiation.generator.AbstractClassGenerator.generateUnderLock(AbstractClassGenerator.java:224)
... 201 more
Caused by: java.lang.ClassNotFoundException: org.openrewrite.gradle.RewriteExtension
at org.gradle.internal.classloader.VisitableURLClassLoader$InstrumentingVisitableURLClassLoader.findClass(VisitableURLClassLoader.java:186)
... 206 more
So that looks like you have a dependency problem locally. The RewritePlugin
and RewriteExtension
are both public classes existing in the same jar file next to each other.
From a Gradle support standpoint, presently we support 4.10 through latest.
Thanks for reaching out @k3code06 ; As Shannon already pointed out we support version 4.10 of Gradle and up, and beyond that recommend that you use the very latest versions of OpenRewrite itself, the OSS Gradle plugin and and recipe modules through our rewrite-recipe-bom where possible. We've taken to documenting releases that are compatible with each other there: https://github.com/openrewrite/rewrite-recipe-bom/releases
Given that the above likely still used mismatched or outdated versions I suppose an attempt with the very latest should prove more successful. Let us know if you still have any issues with that though, and perhaps share how we can reproduce if needed.
I'll close this issue assuming the above helps you resolve your problem, but will monitor this issue for any replies that come in still.
I am using Open Rewrite Gradle Plugin (implementation group: 'org.openrewrite', name: 'plugin', version: '5.40.0') from mvn repository Gradle version - 8.5 I am trying to override RewritePlugin class and on running the plugin it shows- Error-