google / google-java-format

Reformats Java source code to comply with Google Java Style.
Other
5.56k stars 852 forks source link

Provide an option to disable import ordering or customize order #986

Open PatrickRen opened 10 months ago

PatrickRen commented 10 months ago

I'm working on a project (Apache Flink) using AOSP format but with customized import ordering. I manually set the order in Preferences | Editor | Code Style | Java | Imports | Import Layout, but google-java-plugin will override my settings when I use "Optimize Imports".

Is it possible to provide an option to disable the feature, or let users to customize the import order? Thanks!

AgNS61 commented 10 months ago

Many teams use custom import ordering, but now this limitation drives us to use the 1.15.0 version. I hope this feature will come soon.

nrayburn-tech commented 3 weeks ago

Should the other applicable CLI options also be exposed? This would allow using different options within the CLI and remaining consistent with the plugin. This would be beneficial when running a validation in CI to ensure code is formatted before merging. Currently, we are restricted to only what the plugin allows.

At a glance, these all look like candidates.

I can make a separate issue if that's preferred. Also, happy to contribute the changes if it's something that would be accepted.