Skip to content

Commit 626a3d1

Browse files
authored
Merge pull request #2535 from simschla/feature/intellij-formatter
feat: add IntelliJ IDEA formatter
2 parents 2d32ccd + 6c7ecf5 commit 626a3d1

File tree

26 files changed

+948
-29
lines changed

26 files changed

+948
-29
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ jobs:
5959
jre: 11
6060
os: ubuntu-latest
6161
shfmt-version: v3.8.0
62+
- kind: idea
63+
jre: 11
64+
os: ubuntu-latest
6265
runs-on: ${{ matrix.os }}
6366
steps:
6467
- name: Checkout
@@ -91,6 +94,16 @@ jobs:
9194
- name: Test shfmt
9295
if: matrix.kind == 'shfmt'
9396
run: ./gradlew testShfmt
97+
- name: Test idea
98+
if: matrix.kind == 'idea'
99+
run: |
100+
download_link=$(curl https://data.services.jetbrains.com/products/releases\?code\=IIC\&latest\=true\&type\=release | jq -r '.IIC[0].downloads.linux.link')
101+
curl --location "$download_link" -o idea.tar.gz
102+
tar -xf idea.tar.gz
103+
cd idea-IC*
104+
export PATH=${PATH}:$(pwd)/bin
105+
cd ..
106+
./gradlew testIdea
94107
- name: junit result
95108
uses: mikepenz/action-junit-report@v5
96109
if: always() # always run even if the previous step fails

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# Project-specific stuff
88
userHome/
99
workspace/
10+
testenv.properties
1011

1112
### Gradle ###
1213
.gradle

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
1111

1212
## [Unreleased]
1313
### Added
14+
* Support for `idea` ([#2020](https://github.com/diffplug/spotless/pull/2020), [#2535](https://github.com/diffplug/spotless/pull/2535))
1415
* Add support for removing wildcard imports via `removeWildcardImports` step. ([#2517](https://github.com/diffplug/spotless/pull/2517))
1516

1617
## [3.1.2] - 2025-05-27

INTELLIJ_IDEA_SCREENSHOTS.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Extracting Code Style from IntelliJ IDEA
2+
3+
## 1. Exporting Code Style Settings to a file
4+
To export code style settings from IntelliJ IDEA to a file, go to
5+
`Settings | Editor | Code Style` and click on the gear icon next to the scheme name.
6+
7+
![Exporting code style settings](_images/intellij_export_codestyle.png)
8+
9+
## 2. Using IntelliJ's active code style directly
10+
If you have your code style settings checked into version control (in your `.idea` directory),
11+
you can use the active code style directly in Spotless without exporting it to a file.
12+
The file can be found at `.idea/codeStyles/Project.xml`.
13+
14+
## Upstream documentation
15+
More details can be found in the [IntelliJ IDEA documentation](https://www.jetbrains.com/help/idea/command-line-formatter.html#options)
16+
for the command line formatter, which is what Spotless uses under the hood.

_images/intellij_export_codestyle.png

131 KB
Loading

gradle/special-tests.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ def special = [
66
'buf',
77
'clang',
88
'gofmt',
9+
'idea',
910
'npm',
1011
'shfmt'
1112
]
@@ -37,5 +38,9 @@ tasks.named('test').configure {
3738
special.forEach { tag ->
3839
tasks.register("test${tag.capitalize()}", Test) {
3940
useJUnitPlatform { includeTags tag }
41+
if (rootProject.file('testenv.properties').exists()) {
42+
systemProperty 'testenv.properties.path', rootProject.file('testenv.properties').canonicalPath
43+
}
4044
}
4145
}
46+

0 commit comments

Comments
 (0)