Skip to content

0.14.0

Latest

Choose a tag to compare

@mkurz mkurz released this 02 Oct 12:19
v0.14.0
ad2eed2

sbt-java-formatter 0.14.0 is cross-published for sbt 1.x and 2.x.

Highlights

google-java-format 1.37.0

The default formatter runtime (javafmtFormatterCompatibleJavaVersion := 21) has been upgraded from google-java-format 1.36.1 to 1.37.0. The Java 11 and Java 17 compatibility lines remain on 1.24.0 and 1.28.0, respectively.

google-java-format's new --style=google|aosp CLI option is already covered by the existing javafmtStyle setting. Tab indentation, which 1.37.0 offers only through its programmatic API, is not available via the CLI and therefore not supported by this plugin. If you need it, please add a 👍 reaction (rather than a "+1" comment) to both issues:

  • google/google-java-format#1470: adding a --use-tabs CLI flag upstream, which this plugin requires
  • #314: supporting tab indentation in sbt-java-formatter once the flag exists - or maybe we just implement our own solution via post processing

Configurable Line Length

The new javafmtMaxLineLength setting lets you customize the line width used for code, comments, and long-string reflow:

ThisBuild / javafmtMaxLineLength := 120

The default remains 100. Values must be positive, and custom widths require javafmtFormatterCompatibleJavaVersion := 21 (the default), with the formatter JVM running on Java 21 or newer.

Configuration-Aware Caching

Changing formatter settings now causes unchanged source files to be reformatted or rechecked when needed. Previously, the cache tracked only source timestamps and could incorrectly reuse results after configuration changes.

  • Cache invalidation now accounts for formatter options and runtime changes, including changes to the target of a symlinked Java home.
  • Import-only tasks use a separate cache from full-formatting tasks, preventing an imports-only result from incorrectly satisfying a full-format check.
  • Full-formatting options are ignored by import-only tasks and no longer cause irrelevant compatibility errors or cache invalidation.

All three improvements are included in #315.

Migration

No configuration changes are required. The default line length remains 100, and no manual cache cleanup is needed; the first run after upgrading rechecks all files.

google-java-format 1.37.0 changes Javadoc formatting in some cases (for example, HTML comments and Markdown /// block quotes), so javafmtCheck may report files after upgrading. Run javafmtAll once and commit the result.

What's Changed

Full Changelog: v0.13.1...v0.14.0