Skip to content
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

Support Google-Java-Formats own import order out of the box #1769

Closed
bjrke opened this issue Jul 26, 2023 · 3 comments · Fixed by #1780
Closed

Support Google-Java-Formats own import order out of the box #1769

bjrke opened this issue Jul 26, 2023 · 3 comments · Fixed by #1780

Comments

@bjrke
Copy link

bjrke commented Jul 26, 2023

As mentioned in #1680 spotless v6.18.0 unintentionally switched to gjf's own import order handling which was introduced as default also into the corresponding intellij plugin.
With spotless v6.19.0 the import order was changed back to the previous behavior of spotless prior v6.18.
I would like to see a simple config API change to the googleJavaFormat() definition which disables spotless own import order and uses the order from gjf.

@nedtwigg
Copy link
Member

nedtwigg commented Jul 28, 2023

Implementing this is super duper easy, just do the inverse of this: 0183cc2

The only tricky part is the API, maybe: googleJavaFormat().reorderImports(true), and leave false as the default value.

Happy to merge a PR for this.

@nedtwigg
Copy link
Member

nedtwigg commented Sep 1, 2023

Released in plugin-gradle 6.21.0 and plugin-maven 2.38.0.

@bjrke
Copy link
Author

bjrke commented Oct 17, 2023

I tried this out with the recently release version 6.21 of the gradle plugin.
It looks like the new setting reorderImports(true) doesn't have any effect on our setup. While others like aosp() or using an older version is working.

I get the following change in the import order when updating from 6.18.0 (which accidentally enabled gjfs own import order) to 6.21.0:

          -
          -import·org.slf4j.Logger;
          -import·org.slf4j.LoggerFactory;
          -
           import·java.nio.file.Path;
           import·java.nio.file.Paths;
           import·java.util.Locale;
           import·java.util.Optional;
           import·java.util.stream.Stream;
          +import·org.slf4j.Logger;
          +import·org.slf4j.LoggerFactory;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants