Add configurable line length and configuration-aware caching - #315
Merged
Merged
Conversation
Select formatter 1.37.0 for Java 21-compatible execution and expose javafmtMaxLineLength with compatibility validation and documentation. Invalidate caches when the effective invocation changes, including CLI options, formatter classpath, heap settings, and resolved Java-home targets. Separate import-only and full-format caches, ignore irrelevant formatting options for import-only tasks, and defer launcher validation until execution. Keep shared formatter arguments mandatory so full-format callers cannot silently ignore user settings. Add scripted coverage for line lengths, configuration and runtime changes, symlink retargeting, no-source builds, import-only isolation, and version guards across sbt 1 and 2.
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Upgrade the Java 21-compatible formatter runtime to
google-java-format 1.37.0and expose its configurable line length. The Java 11 and Java 17 compatibility lines remain on1.24.0and1.28.0.javafmtMaxLineLength, defaulting to100, and map custom values to--max-line-length. Values must be positive; custom widths requirejavafmtFormatterCompatibleJavaVersion := 21.javafmtStylesetting covers the new--style=google|aospand--google-stylealiases without introducing duplicate settings.Cache Fixes
The previous cache tracked source timestamps only, so changing formatter options could leave unchanged files unchecked or unformatted. Import-only checks also shared cache state with full-formatting tasks, allowing an imports-only result to incorrectly satisfy a full-format check.
Shared formatter arguments remain mandatory, preventing future full-formatting callers from silently dropping configured line-length or string-reflow settings.
Verification
Added scripted coverage for option changes on unchanged sources, cache-mode isolation, import-only options, line lengths and string wrapping, runtime changes, symlink retargeting and recovery, no-source builds, and compatibility validation. The new runtime tests are included in CI.
All 64 scripted runs passed across the five Java/sbt combinations: sbt 1 on Java 11; sbt 2 on Java 17, 21, and 25; and sbt 1 on Java 11 with the formatter on Java 25. After the final explicit-argument cleanup, all 15 targeted reruns passed on sbt 1/Java 11 and sbt 2/Java 21. Formatting checks also passed.