-
Notifications
You must be signed in to change notification settings - Fork 376
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
Adding ImportLayoutStyle to OrderImports recipe removes all import statements... #5032
Comments
Thanks for the clear steps to reproduce this issue @ajoshi66 ! Indeed strange how setting a preferred style leads to removed imports. Admittedly I haven't used explicit styles much myself. Seems like something to explore & fix. Did you already try to also configure rewrite/rewrite-java/src/main/java/org/openrewrite/java/style/ImportLayoutStyle.java Lines 71 to 75 in 525f368
|
Thanks, @timtebeek for the response. I took a fresh copy of the source, added the |
That's unfortunate! Guess we'll need to figure out a fix & update the docs then. /cc @mike-solomon for visibility already |
Just an update. May not be of much use to you. I found the JUnit test case that tests |
Thank you for creating this framework and the platform.
Problem Context:
This one is straight from the "getting started" documentation (https://docs.openrewrite.org/running-recipes/getting-started). I cloned the project "spring-petclinic-migration" and setup the plugin (version 6.1.1.) as documented and configured the plugin for OrderImports recipe.
The recipe worked fine. The order of imports were changed from the original. However, I found that the class
org.springframework.samples.petclinic.owner.Owner
got its javax.persistence classes got collapsed asjavax.persistence.*
. As I prefer the imports to include individual classes, I wanted to change the style. Based on another documentation (https://docs.openrewrite.org/concepts-and-explanations/styles), when I added the rewrite.yml and configured maven plugin to include the style. At this time, the rewrite:run removed all imports from all classes.Creating this as new issue, as I could not find a similar one reported. Apologize, if this is already reported/resolved.
What version of OpenRewrite are you using?
I am using maven plugin version 6.1.1. I do have Java JDK 21 installed; but maven is configured to use version JDK 11.
How are you running OpenRewrite?
From the command line. Not using any IDE. I am using WinMerge to view the differences against original.
What is the smallest, simplest way to reproduce the problem?
Here is the maven plugin configuration:
And here is the rewrite.yml
What did you expect to see?
The java class with the imports as below. But the entire section of imports were removed. From all classes.
The text was updated successfully, but these errors were encountered: