Skip to content

Bump google-java-format to 2.0.0 and add a cleanup option - #3157

Open
cushon wants to merge 3 commits into
diffplug:mainfrom
cushon:gjf-2.0.0
Open

cushon wants to merge 3 commits into
diffplug:mainfrom
cushon:gjf-2.0.0

Conversation

@cushon

@cushon cushon commented Oct 30, 2026

Copy link
Copy Markdown

google-java-format 2.0.0 (https://github.com/google/google-java-format/releases/tag/v2.0.0) adds a cleanup pass that makes small non-whitespace changes, and enables it by default: removing redundant semicolons, empty annotation parentheses (@Foo() → @Foo), and parentheses around a single untyped lambda parameter ((x) -> ... → x -> ...).

This PR bumps the default google-java-format version from 1.36.1 to 2.0.0, and adds a cleanup option to the googleJavaFormat step to turn the cleanups off (googleJavaFormat().cleanup(false) in Gradle, <cleanup>false</cleanup> in Maven). Older google-java-format versions don't have cleanups, so the option has no effect with them.

2.0.0 also indents text block contents as part of the main formatting pass, even when long strings aren't reflowed, so this updates the expected output of the text block test.

2.0.0 also restores JavaFormatterOptions.Style.valueOf(String) (google/google-java-format#1478), which 1.37.0 removed and which Spotless uses (#3126).

google-java-format 2.0.0 adds a cleanup pass that makes small
non-whitespace changes, and enables it by default: removing redundant
semicolons, empty annotation parentheses, and parentheses around a
single untyped lambda parameter. Add a `cleanup` option to the
googleJavaFormat step in the Gradle and Maven plugins to disable it.
Older google-java-format versions don't have cleanups, so
`cleanup(false)` has no effect with them.

2.0.0 also indents text block contents as part of the main formatting
pass, even when long strings aren't reflowed, so update the expected
output of the text block test.

https://github.com/google/google-java-format/releases/tag/v2.0.0
Comment thread plugin-gradle/CHANGES.md Resolved
Comment thread plugin-gradle/CHANGES.md Resolved
Comment thread plugin-maven/CHANGES.md Resolved
Comment thread plugin-maven/CHANGES.md Resolved
Comment thread CHANGES.md Resolved
Comment thread CHANGES.md Resolved
cushon and others added 2 commits October 31, 2026 00:37
Co-authored-by: Zongle Wang <wangzongler@gmail.com>
On Java 17 the default google-java-format version is 1.28.0, which
doesn't have cleanups and doesn't indent text block contents without
reflowing long strings.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants