-
Notifications
You must be signed in to change notification settings - Fork 41
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
Rewrite is not using the configured groovy dependency but using the localGroovy() dependency packaged with Gradle #354
Comments
Hi @MartinAhrer ! Indeed OpenRewrite uses the Groovy version bundled with Gradle, as our support for Groovy was mostly in service of parsing |
So I think this is a little more nuanced of an issue, but to Tim's point at the moment Groovy support has been pretty isolated to Gradle scripts. On top of the Spock tests are an entirely different animal due to the myriad of AST transformations that Spock uses. With the Gradle plugin, were taking the user's classpath for each source set configuration and using that as the provided classpath. But there is a caveat that the Groovy classes are being parent loaded from the Gradle distribution to support parsing of Gradle buildscript using the library versions from the Gradle itself to support that step. When OpenRewrite tries to parse Groovy source code, it's by nature then referring to the Groovy runtime from Gradle first due to the way that Java's classloaders work rather than the user's Groovy version that comes later in the classpath. |
Thanks for clarifying. I understand the complexity. I fear this is then going to be a "too big thing" and I think I will have to exclude my spock based tests from source scanning for now ;( With Groovy 4 released roughly 2 years ago, I hope that Gradle then would at some point update their embedded Gradle 3. |
So just a note, but based on the stacktrace, I'd expect for it to mostly be reporting as a warning for the failure to parse the Spock tests. However, I'm guessing that you probably are seeing a ton of those warnings. OpenRewrite logs any failure to parse as a warning, so that you as a user are aware of it, but tries to make sure that processing can continue as far as possible. The idea here being that allowing recipe execution over some of the source code is still better than none. |
Thanks for explaning. For one tiny project I have managed to just stick with groovy 3 but still get errors for my groovy code. However as you have explained, I think right now for other projects I wouldn't continue to use it for anything else but rewriting Gradle groovy code. |
What version of OpenRewrite are you using?
I am using
How are you running OpenRewrite?
I am using the Gradle plugin, and my project is a single module project.
Test are using the spockframework which requires groovy.
The dependency configuration for the test is as follows. It configures a groovy 4.0, not using the localGroovy bundled with Gradle.
What is the smallest, simplest way to reproduce the problem?
What did you expect to see?
Successful processing of Groovy source.
What did you see instead?
Rewrite seems to be using the local Groovy bundled with Gradle.
As a result the spock compile which is doing some code transformation is not working as it is expecting the configured groovy 4.0 runtime.
What is the full stack trace of any errors you encountered?
The only workaround is to use localGroovy() for dependency configuration.
However tests require some Groovy 4.0 stuff!
So the above dependency configuration would have to be modified to be as below
The text was updated successfully, but these errors were encountered: