Skip to content

Commit 5bfa0ff

Browse files
committed
Add IntelliJ setup for formatting in CONTRIBUTING.md
1 parent 3c85c15 commit 5bfa0ff

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

CONTRIBUTING.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ We use [Spotless](https://github.com/diffplug/spotless) to enforce consistent co
8282

8383
Before committing, run:
8484

85-
```
85+
```bash
8686
mvn spotless:check
8787
```
8888

8989
#### 🛠️ Auto-format your code
9090

9191
To automatically format your code, run:
9292

93-
```
93+
```bash
9494
mvn spotless:apply
9595
```
9696

@@ -102,6 +102,46 @@ This ensures that your code:
102102

103103
All contributions **must pass `spotless:check` in CI**.
104104

105+
### 🧠 IntelliJ IDEA Setup for Spotless
106+
107+
To use Spotless formatting from IntelliJ:
108+
109+
1. **Enable necessary VM options** (required to support Google Java Format):
110+
111+
Go to:
112+
113+
```
114+
Preferences (macOS) or Settings (Windows/Linux) >
115+
Build, Execution, Deployment >
116+
Compiler >
117+
Java Compiler >
118+
Additional command line parameters
119+
```
120+
121+
Add the following VM options:
122+
123+
```
124+
--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
125+
--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
126+
--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
127+
--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
128+
--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
129+
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
130+
```
131+
132+
2. **(Optional)**: Automate formatting on save using the *Save Actions* plugin:
133+
134+
- Install the **Save Actions** plugin from the IntelliJ Marketplace
135+
- Go to `Preferences > Save Actions`
136+
- Enable **"Activate save actions on save"**
137+
- Configure it to run an external tool with the command:
138+
139+
```bash
140+
mvn spotless:apply
141+
```
142+
143+
> 💡 You can also define a custom keybinding in IntelliJ to run `mvn spotless:apply` easily when needed.
144+
105145
## 🔄 Creating a Pull Request
106146

107147
To contribute, follow these steps:

0 commit comments

Comments
 (0)