-
Notifications
You must be signed in to change notification settings - Fork 67
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
Sort imports and remove unused imports #11
Comments
Note that fmt-maven-plugin doesn't look at imports (see spotify/fmt-maven-plugin#11). Files here have been formatted using: java -jar google-java-format-1.3-all-deps.jar -i \ $(find . -name '*.java') rather than 'mvn fmt:format'.
Note that fmt-maven-plugin doesn't look at imports (see spotify/fmt-maven-plugin#11). Files here have been formatted using: java -jar google-java-format-1.3-all-deps.jar -i \ $(find . -name '*.java') rather than 'mvn fmt:format'.
Note that fmt-maven-plugin doesn't look at imports (see spotify/fmt-maven-plugin#11). Files here have been formatted using: java -jar google-java-format-1.3-all-deps.jar -i \ $(find . -name '*.java') rather than 'mvn fmt:format'.
For Spotless, we effectively call the following lines one after another. String source = ...;
String formatted = new Formatter().formatSource(...);
formatted = RemoveUnusedImports.removeUnusedImports(formatted);
formatted = ImportOrderer.reorderImports(formatted); Using |
On a somewhat different note, I'm interested in seeing this issue resolved as well, as it would make implementing jrtom/jung#86 easier for us. |
Fixed by #13 |
Great to see that this issue is resolved now. Thank you very much @pastjean and @therealppa. 👍 |
The
Formatter
class won't sort imports or remove unused imports. This can be done using theImportOrderer
andRemoveUnusedImports
classes respectively.See google/google-java-format#96 which adds this as a default behavior in the
Formatter
class.(note that
java -jar google-java-format-1.3-all-deps.jar
usesFormatFileCallable
instead of directly calling theFormatter
;FormatFileCallable
sort and cleans up imports in addition to formatting the code; actually, this is probably what this plugin should use too)The text was updated successfully, but these errors were encountered: