Skip to content

Format Java with open-java-format, which also runs on JDK 25 and later - #468

Merged
slachiewicz merged 1 commit into
masterfrom
agent/open-java-format
Nov 22, 2026
Merged

slachiewicz merged 1 commit into
masterfrom
agent/open-java-format

Conversation

@slachiewicz

@slachiewicz slachiewicz commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Spotless now formats Java with open-java-format 21.0.2 through the new groupArtifact option of spotless-maven-plugin 3.12.0. It is the palantir-java-format code under the same packages and with the same output, and it runs on JDK 25 to 27, where palantir-java-format fails with NoSuchFieldError and no fixed release exists yet.

open-java-format is compiled for Java 21, so on JDK 17 to 20 the new java17 profile switches back to palantir-java-format (version.palantir-java-format, 2.80.0); Spotless keeps running on JDK 17 and later. The formatter comes from two properties, spotless.java-format.groupArtifact and spotless.java-format.version, which a project can override.

Verified: plexus-utils on the 29-SNAPSHOT parent, CI=true mvn process-sources on JDK 17, 21 and 27 → check passes on clean sources and fails on a misformatted file; that file formats byte-identically on JDK 17 and 21; plexus-utils and plexus-compiler reformatted with open-java-format 21.0.2 → 0 files changed.

@slachiewicz slachiewicz added the enhancement New feature or request label Nov 22, 2026
palantir-java-format fails on JDK 27 (NoSuchFieldError on JCCompilationUnit.endPositions) and no fixed release exists; open-java-format keeps its packages and output, so Spotless loads it through groupArtifact. It needs JDK 21, so the java17 profile keeps palantir-java-format on JDK 17 to 20; both format the same way.
@slachiewicz
slachiewicz force-pushed the agent/open-java-format branch from e9d2957 to 5d9fe8c Compare November 22, 2026 22:32
@slachiewicz
slachiewicz marked this pull request as ready for review November 22, 2026 22:41
@slachiewicz
slachiewicz merged commit 9e31556 into master Nov 22, 2026
13 checks passed
@slachiewicz
slachiewicz deleted the agent/open-java-format branch November 22, 2026 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant