Skip to content

Commit fcd566a

Browse files
committed
Switch the native binary on in IntelliJ IDEA, not in the build
The IntelliJ IDEA page said the native binary is switched on in the build, with openjavaformat.native.formatter=true, and only in a project with the Gradle plugin. Since openjavaformat/open-java-format#197 it is a setting of the IDE plugin for any project: Use native binary, with a Download the plugin carries out itself, or a binary of one's own. The section now says how, what the plugin does after an update, and where the binary exists; a note tells projects that set the property to tick the box once. The Gradle page says the property no longer reaches the IDE.
1 parent 0fa5d71 commit fcd566a

2 files changed

Lines changed: 38 additions & 13 deletions

File tree

‎docs/get-started/gradle.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,5 @@ is resolved by the root project, so the root project needs the repository too.
119119

120120
When the project is opened in IntelliJ IDEA, the plugin writes the formatter settings into `.idea`,
121121
and the [IDE plugin](intellij-idea.md) then formats with the version the build uses. The IDE plugin
122-
is installed separately.
122+
is installed separately. Whether the IDE runs the native binary is a setting of the IDE plugin,
123+
whatever `openjavaformat.native.formatter` says: see [Native binary](intellij-idea.md#native-binary).

‎docs/get-started/intellij-idea.md‎

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,42 @@ be any version.
6666

6767
## Native binary
6868

69-
In a project with the [Gradle plugin](gradle.md), the IDE can run the formatter as the native binary
70-
that the build uses. It is switched on in the build, not in the IDE:
69+
Reformat Code starts the formatter as a new process for every file, and the Java-based formatter
70+
starts a JVM each time, which a whole directory makes you feel. The native binary starts without
71+
one: on an Apple silicon Mac a file takes about 40 ms instead of 430 ms.
7172

72-
``` properties title="gradle.properties"
73-
openjavaformat.native.formatter=true
74-
```
73+
It is a setting of the IDE and works in any project, whether Maven, Gradle or neither builds it.
7574

76-
After the next Gradle sync in the IDE, the plugin writes the path of the binary into
77-
`.idea/open-java-format.xml`, and **Formatter type** on the settings page changes from
78-
**Java-based formatter** to **Native image formatter**. Each reformat starts the formatter as a new
79-
process, and the native binary starts without a JVM.
75+
1. Open **Settings** and go to **Other Settings → open-java-format Settings**.
76+
2. Tick **Use native binary**.
77+
3. Click **Download** next to **No embedded version.** The IDE downloads the binary of the plugin's
78+
version for your platform from Maven Central, checks it against its SHA-256 checksum and keeps
79+
it for every project. The line then reads **Use embedded version** and the version.
80+
4. Click **OK**.
81+
82+
**Formatter type** at the bottom of the page names what runs, and `idea.log` has a line starting
83+
with `open-java-format: using` each time the plugin starts a formatter.
84+
85+
!!! note "Projects that set `openjavaformat.native.formatter`"
86+
87+
Up to 21.0.1 that Gradle property also switched the IDE to the native binary. It now applies to
88+
the build alone, so tick **Use native binary** once in such a project.
89+
90+
### A binary of your own
91+
92+
To run another binary, such as one from the [command line](command-line.md) page, choose it in
93+
**Binary** under **Use native binary**. It takes the place of the embedded one; empty the field to
94+
go back to the embedded binary.
95+
96+
### After an update of the plugin
97+
98+
The binary of the previous version keeps formatting. When a project opens, a notification says
99+
that a newer one is available, with **Download** and **Ignore**. Ignore holds until the plugin's
100+
next version, and the settings page still offers **Update to** next to the version in use. Once
101+
the newer binary is in, the old one is deleted.
102+
103+
### Platforms
80104

81-
The binary runs on the platforms listed on the
82-
[Gradle plugin](gradle.md#choose-how-the-formatter-runs) page. Elsewhere the plugin ignores the
83-
property, and the IDE keeps the Java-based formatter.
105+
The binary is published for Linux with glibc on x86-64 and AArch64, macOS on Apple silicon and
106+
Intel, and Windows on x86-64. Anywhere else, such as Windows on ARM or Alpine, the settings page
107+
says there is none and the Java-based formatter runs, unless you choose a binary of your own.

0 commit comments

Comments
 (0)