Skip to content

Commit e1366fb

Browse files
committed
Revert "Describe 2.98.0.2: one style, exit code 2 and a Windows binary"
This reverts commit c3e740b. It was meant for a branch that waits for the release, and reached main by mistake: 2.98.0.2 is not published yet, so the site would tell users of 2.98.0.1 to run the formatter without --ojf, which formats in Google style, and would link to downloads that do not exist yet. It goes back in once 2.98.0.2 is out.
1 parent c3e740b commit e1366fb

7 files changed

Lines changed: 31 additions & 42 deletions

File tree

‎docs/ai-agents.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ and [`jq`](https://jqlang.org/), which takes the path of the file out of that JS
8181
"hooks": [
8282
{
8383
"type": "command",
84-
"command": "open-java-format --skip-removing-unused-imports --replace \"$(jq -r '.tool_input.file_path')\""
84+
"command": "open-java-format --ojf --skip-removing-unused-imports --replace \"$(jq -r '.tool_input.file_path')\" || exit 2"
8585
}
8686
]
8787
}
@@ -102,8 +102,8 @@ it in the next. A full format after the first edit would delete that import, so
102102
imports that really are unused.
103103

104104
**A file that does not parse goes back to the agent.** The formatter leaves the file as it is,
105-
prints the error and exits with 2, the exit code that makes Claude Code show a hook's message to
106-
the model, so Claude sees it right after its edit:
105+
prints the error and exits with 1. `|| exit 2` turns that into 2, the exit code that makes Claude
106+
Code show a hook's message to the model, so Claude sees it right after its edit:
107107

108108
``` text
109109
src/main/java/com/example/Broken.java:5:22: error: ';' expected
@@ -128,13 +128,13 @@ for coding agents. Add a section that matches how the project runs the formatter
128128
After you create or edit a `.java` file, format it:
129129

130130
```sh
131-
open-java-format --replace path/to/File.java
131+
open-java-format --ojf --replace path/to/File.java
132132
```
133133

134134
Before you commit, run this check. It must print nothing, so format every file it lists:
135135

136136
```sh
137-
open-java-format --dry-run --set-exit-if-changed $(git ls-files '*.java')
137+
open-java-format --ojf --dry-run --set-exit-if-changed $(git ls-files '*.java')
138138
```
139139
````
140140

‎docs/get-started/command-line.md‎

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -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"
2422
curl -LO https://github.com/openjavaformat/open-java-format/releases/download/{{ ojf_version }}/open-java-format-macos_aarch64
2523
chmod +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

7977
The check prints the files that would change and exits with 1 if there are any, which is what a CI
8078
step 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.

‎docs/get-started/github-actions.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# GitHub Action and pre-commit
22

33
Both checks run the native binary, so they need no Java, Maven or Gradle. They work on Linux with
4-
glibc and on macOS, and stop with an error on Windows and on musl-based Linux such as Alpine.
4+
glibc and on macOS. There is no native binary for Windows or for musl-based Linux such as Alpine.
55

66
## Check pull requests and pushes
77

@@ -41,7 +41,7 @@ Run the formatter locally with the same version, then commit the result. See
4141
[Command line](command-line.md) for the download.
4242

4343
``` sh
44-
open-java-format --replace path/to/File.java
44+
open-java-format --ojf --replace path/to/File.java
4545
```
4646

4747
## Exclude files

‎docs/get-started/index.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ the same formatter, so they all produce the same files. Set up the ones your pro
2727

2828
---
2929

30-
A native binary for Linux, macOS and Windows, or a runnable jar anywhere else. Formats files in
31-
place or checks them.
30+
A native binary for Linux and macOS, or a runnable jar anywhere else. Formats files in place or
31+
checks them.
3232

3333
- :simple-intellijidea:{ .lg .middle } __[IntelliJ IDEA](intellij-idea.md)__
3434

‎docs/index.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,14 @@ a native binary on Linux and macOS. For Windows and for multi-project builds see
122122
### On the command line
123123

124124
Every [release](https://github.com/openjavaformat/open-java-format/releases/latest) carries native
125-
binaries for Linux, macOS and Windows, and a runnable jar for Java 21 or later.
125+
binaries for Linux and macOS, and a runnable jar for Java 21 or later.
126126

127127
``` sh title="Format files in place"
128-
open-java-format --replace src/main/java/com/example/Hello.java
128+
open-java-format --ojf --replace src/main/java/com/example/Hello.java
129129
```
130130

131131
``` sh title="Fail when anything is not formatted"
132-
open-java-format --dry-run --set-exit-if-changed $(git ls-files '*.java')
132+
open-java-format --ojf --dry-run --set-exit-if-changed $(git ls-files '*.java')
133133
```
134134

135135
Downloads, checksums and every option are on the [Command line](get-started/command-line.md) page.

‎docs/migrate.md‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The Java packages are unchanged as well. Only the names in your build and your s
1616
| SPI | `palantir-java-format-spi` | `open-java-format-spi` |
1717
| Gradle plugin | `com.palantir.java-format` | `dev.openjavaformat.java-format` |
1818
| Gradle property | `palantir.native.formatter` | `openjavaformat.native.formatter` |
19-
| Command-line style flag | `--palantir` | none: there is one style |
19+
| Command-line style flag | `--palantir` | `--ojf` |
2020
| Style in the API | `PALANTIR` | `OJF` |
2121
| IntelliJ plugin | `palantir-java-format` | `open-java-format` |
2222
| Java packages | `com.palantir.javaformat.*` | the same, for the whole 2.x line |
@@ -43,14 +43,15 @@ settings and multi-project builds.
4343

4444
### Command line and scripts
4545

46-
Remove `--palantir`: there is one style, so no flag chooses it. Take the binary or the jar from
46+
Replace `--palantir` with `--ojf`, and take the binary or the jar from
4747
[our releases](get-started/command-line.md).
4848

49-
!!! note "A leftover flag fails the run"
49+
!!! warning "The old flag does not fail"
5050

51-
An unknown flag such as `--palantir` stops the formatter with exit code 2, so a CI step that
52-
still passes it fails instead of going green. Version 2.98.0.1 printed its usage text there and
53-
exited with 0, without checking anything.
51+
`--palantir` is no longer accepted, but it is not an error either: the formatter prints
52+
`unexpected flag: --palantir` with its usage text and exits with 0. A CI step that still passes
53+
the old flag would go green without checking anything. Search your scripts and workflows for
54+
it.
5455

5556
### Libraries that call the formatter
5657

@@ -94,7 +95,7 @@ the same method in both styles.
9495
2. Format everything once and commit only that:
9596

9697
``` sh
97-
open-java-format --replace $(git ls-files '*.java')
98+
open-java-format --ojf --replace $(git ls-files '*.java')
9899
git commit -am "Reformat with open-java-format"
99100
```
100101

‎zensical.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ toggle.name = "Switch to system preference"
105105
# plugin puts it in before the Markdown is rendered, so it lands in code blocks too. The key is not
106106
# extra.version: the theme reads that one as the switch for a version selector.
107107
[project.extra]
108-
ojf_version = "2.98.0.2"
108+
ojf_version = "2.98.0.1"
109109

110110
# Renders every page as a Jinja template, for {{ ojf_version }}. A misspelt variable or a stray {{
111111
# fails the build instead of leaving a gap or the raw text on the site.

0 commit comments

Comments
 (0)