Get started¶
open-java-format runs in the build, in the editor, on the command line and in CI. Every route uses
the same formatter, so they all produce the same files; the one exception is the
palantirJavaFormat step of Spotless. Set up the ones your project needs.
Requirements
The current version is 21.1.1. Everything except the native binaries needs Java 21 or later, and the Gradle plugin needs Gradle 9. The Maven plugin has version numbers of its own; the current one is 2.27.0.2.
-
Formats the lines you changed with
formatDiffand keeps IntelliJ IDEA on the same formatter version as the build. -
Works with Gradle through our plugin, and with Maven through a Spotless step that formats a little differently.
-
Formats the sources in every build, or fails the build in CI when they are not formatted.
-
A native binary for Linux, macOS and Windows, or a runnable jar anywhere else. Formats files in place or checks them.
-
Makes Reformat Code run open-java-format instead of the IDE's own Java formatter.
-
Adds open-java-format as a formatter implementation for the Java editor.
-
Fails a pull request, or stops a commit, when a Java file is not formatted.