open-java-format

openjavaformat/open-java-format last check 12 releases recent
Notes

A modern, lambda-friendly, 120 character Java formatter.

Release notes
view on github
17.1.0 · recent

The first release of the 17 line: the formatter and the Gradle plugin of 21.1.2, built for Java 17, for builds that run on JDK 17 to 20. On every file that javac 17 parses, 17.1.0 formats exactly as 21.1.2 does, so a build that checks the format on JDK 17 and on JDK 21 sees one output on both. On JDK 21 and later, use 21.x (#293).

What the line carries

  • dev.openjavaformat:open-java-format, -spi and -jdk-bootstrap on Maven Central, for Spotless's palantirJavaFormat step and for fmt-maven-plugin, and the Gradle plugin dev.openjavaformat.java-format with its -idea, -spotless and -provider IDs on the Gradle Plugin Portal. The runnable jar is on this release.
  • No native image, IntelliJ or Eclipse plugin, .deb package or WebAssembly module of its own: they do not depend on the JDK a build runs on, and the 21 line's serve builds on JDK 17 too. The Gradle plugin's native formatter takes the version of its image from the new openjavaformat.native.formatter.version property; with 17.1.0, set it to 21.1.2 (#297).

Formatter

  • The syntax of Java 17. Syntax that javac 17 does not parse, such as record patterns and guarded case labels, needs 21.x.
  • A semicolon among the imports fails with extraneous semicolon at the same place as on 21.1.2, although javac 17 takes it, and an import that only a Javadoc reference to an anchor uses, {@link Set##anchor}, stays as on 21.1.2 (#298).