@@ -14,20 +14,18 @@ Pick the file for your platform from the
1414| Linux AArch64, glibc | ` open-java-format-linux-glibc_aarch64 ` |
1515| macOS, Apple silicon | ` open-java-format-macos_aarch64 ` |
1616| macOS, Intel | ` open-java-format-macos_x86-64 ` |
17- | Windows, x86-64 | ` open-java-format-windows_x86-64.exe ` |
1817| Anything else with Java 21 or later | ` open-java-format-{{ ojf_version }}-all.jar ` |
1918
20- There is no native binary for Windows on ARM or for musl-based Linux such as Alpine. Use the jar
21- there.
19+ There is no native binary for Windows or for musl-based Linux such as Alpine. Use the jar there.
2220
2321``` sh title="Native binary, here for Apple silicon"
2422curl -LO https://github.com/openjavaformat/open-java-format/releases/download/{{ ojf_version }}/open-java-format-macos_aarch64
2523chmod +x open-java-format-macos_aarch64
2624./open-java-format-macos_aarch64 --version
2725```
2826
29- Rename the file to ` open-java-format ` , or ` open-java-format.exe ` on Windows, and move it to a
30- directory on your ` PATH ` . The examples below assume you did.
27+ Rename the file to ` open-java-format ` and move it to a directory on your ` PATH ` . The examples below
28+ assume you did.
3129
3230!!! note "macOS and files downloaded with a browser"
3331
@@ -61,32 +59,33 @@ Every release has a `checksums_sha256.txt`. Download it next to your file and ch
6159
6260## Format and check
6361
64- There is one style, so no flag chooses it. Version 2.98.0.1 needed ` --ojf ` : later versions still
65- accept it, print a warning and format as usual, so drop it from your scripts .
62+ Pass ` --ojf ` every time. Without a style flag the formatter uses Google Java Style, and the old
63+ ` --palantir ` flag is no longer accepted .
6664
6765``` sh title="Format files in place"
68- open-java-format --replace src/main/java/com/example/Hello.java
66+ open-java-format --ojf -- replace src/main/java/com/example/Hello.java
6967```
7068
7169``` sh title="Format every tracked Java file"
72- open-java-format --replace $( git ls-files ' *.java' )
70+ open-java-format --ojf -- replace $( git ls-files ' *.java' )
7371```
7472
7573``` sh title="Check without changing anything"
76- open-java-format --dry-run --set-exit-if-changed $( git ls-files ' *.java' )
74+ open-java-format --ojf -- dry-run --set-exit-if-changed $( git ls-files ' *.java' )
7775```
7876
7977The check prints the files that would change and exits with 1 if there are any, which is what a CI
8078step needs.
8179
8280``` sh title="Format standard input"
83- cat Hello.java | open-java-format -
81+ cat Hello.java | open-java-format --ojf -
8482```
8583
8684## Options
8785
8886| Option | What it does |
8987| --- | --- |
88+ | ` --ojf ` | Use the open-java-format style: 120 columns, 4-space indents |
9089| ` --replace ` , ` -i ` | Write the result back to the files instead of printing it |
9190| ` --dry-run ` , ` -n ` | Print the files that would change, change nothing |
9291| ` --set-exit-if-changed ` | Exit with 1 if anything would change |
@@ -98,14 +97,3 @@ cat Hello.java | open-java-format -
9897| ` --skip-reflowing-long-strings ` | Do not rewrap string literals that pass the column limit |
9998| ` @file ` | Read options and file names from a file |
10099| ` --version ` , ` --help ` | Print the version, or every option |
101-
102- ## Exit codes
103-
104- | Code | Meaning |
105- | --- | --- |
106- | 0 | Every file was formatted or checked without a problem |
107- | 1 | With ` --set-exit-if-changed ` : a file is not formatted |
108- | 2 | A file could not be read, parsed or written, or an option is wrong. The reason is on standard error |
109-
110- A file that does not parse is left as it is. When a run hits both, a file that is not formatted and
111- one it cannot format, the exit code is 2.
0 commit comments