I'm sure this must be answered somewhere, but I did no find it.
How does one use SUN Java formatting style rather than Google style?
Thanks!
Hi @binkley, thanks for your patience!
(@nedtwigg, to give you some context, this conversation started over at https://github.com/binkley/modern-java-practices/issues/2#issuecomment-708383854)
So I still don't remember us having ever implemented a Sun code style formatter in Spotless, and a quick search seems to confirm this. (I assume you were referring to the rules implemented by Checkstyle here?)
The only workaround I'm aware of is to use Checkstyle, but it only lets you know if your code violates Sun conventions; it doesn't fix things for you.
I was hoping to find an Eclipse code formatter config file for Sun conventions to share with you, but Googling around brings up nothing for me. The only lead I found was to use the Checkstyle plugin for Eclipse, which used to be able to translate Checkstyle configs to Eclipse formatter configs, but not anymore. I installed Eclipse just now and I was able to confirm this, sadly.
I'm sorry I wasn't able to give you the answer you were expecting.
@nedtwigg I'm considering turning this issue into a feature request, but I'm hesitant because I don't have any expertise in writing code formatters, and I know you like to close stale issues after a while. What do you think?
@nedtwigg Alternatively, are you aware of an Eclipse config that produces Sun-compliant code or pretty close, by any chance?
The eclipse formatter is extremely configurable, you can definitely get it to match Sun's guidelines. You could make it yourself (eclipse has a nice GUI for this), or if you google "eclipse formatter sun" you can several which people have made (e.g. this one). https://github.com/diffplug/spotless/blob/main/ECLIPSE_SCREENSHOTS.md
If you find one or make one, it would be great to link to it in this issue for other people who want the same thing.
Thank you both @jbduncan and @nedtwigg. I was not aware of the Eclipse formatter!
@binkley If you've not found the time yet to create an Eclipse formatter config for Sun code style rules, I have an alternative for you: try using https://github.com/openrewrite/rewrite-checkstyle along with Checkstyle's built-in Sun config. I'm sure the fine folks over at openrewrite would appreciate any feedback. :)
@jbduncan Thank you for the reference to Rewrite. I posted about a matching Gradle plugin to their Maven plugin: https://github.com/openrewrite/rewrite-checkstyle/issues/5
My use cases cover both Gradle and Maven builds