Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit 8abca85

Browse files
committed
Add automatic code style setting in IDEA
This was meant to happen but the old gradle script for it only worked if you used the old, deprecated method. This also adds support for the checkstyle plugin.
1 parent c890fab commit 8abca85

4 files changed

Lines changed: 80 additions & 2 deletions

File tree

build.gradle

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ allprojects {
120120

121121
checkstyle {
122122
configFile = rootProject.file("checkstyle.xml")
123-
toolVersion = '8.31'
123+
toolVersion = '8.36.2'
124124
}
125125
}
126126

@@ -281,4 +281,12 @@ loom {
281281
shareCaches = true
282282
}
283283

284-
apply from: 'https://github.com/FabricMC/fabric-docs/raw/master/gradle/ideconfig.gradle'
284+
285+
task copyIdeaFiles(type: Copy) {
286+
if (file(".idea/").exists()) {
287+
from "idea-docs/"
288+
into ".idea/"
289+
}
290+
}
291+
292+
copyIdeaFiles

idea-docs/checkstyle-idea.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project version="4">
3+
<component name="CheckStyle-IDEA">
4+
<option name="configuration">
5+
<map>
6+
<entry key="active-configuration" value="LOCAL_FILE:$PROJECT_DIR$/checkstyle.xml:patchwork-api" />
7+
<entry key="checkstyle-version" value="8.36.2" />
8+
<entry key="copy-libs" value="false" />
9+
<entry key="location-0" value="BUNDLED:(bundled):Sun Checks" />
10+
<entry key="location-1" value="BUNDLED:(bundled):Google Checks" />
11+
<entry key="location-2" value="LOCAL_FILE:$PROJECT_DIR$/checkstyle.xml:patchwork-api" />
12+
<entry key="scan-before-checkin" value="false" />
13+
<entry key="scanscope" value="JavaOnly" />
14+
<entry key="suppress-errors" value="true" />
15+
</map>
16+
</option>
17+
</component>
18+
</project>

idea-docs/codeStyles/Project.xml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<component name="ProjectCodeStyleConfiguration">
2+
<code_scheme name="Project" version="173">
3+
<JavaCodeStyleSettings>
4+
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
5+
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
6+
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
7+
<value />
8+
</option>
9+
<option name="IMPORT_LAYOUT_TABLE">
10+
<value>
11+
<emptyLine />
12+
<package name="java" withSubpackages="true" static="false" />
13+
<emptyLine />
14+
<package name="javax" withSubpackages="true" static="false" />
15+
<emptyLine />
16+
<package name="" withSubpackages="true" static="false" />
17+
<emptyLine />
18+
<package name="net.minecraft" withSubpackages="true" static="false" />
19+
<emptyLine />
20+
<package name="net.fabricmc" withSubpackages="true" static="false" />
21+
<emptyLine />
22+
<package name="net.patchworkmc" withSubpackages="true" static="false" />
23+
<emptyLine />
24+
<package name="" withSubpackages="true" static="true" />
25+
</value>
26+
</option>
27+
</JavaCodeStyleSettings>
28+
<JetCodeStyleSettings>
29+
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
30+
<value>
31+
<package name="java.util" alias="false" withSubpackages="false" />
32+
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
33+
<package name="io.ktor" alias="false" withSubpackages="true" />
34+
</value>
35+
</option>
36+
<option name="PACKAGES_IMPORT_LAYOUT">
37+
<value>
38+
<package name="" alias="false" withSubpackages="true" />
39+
<package name="java" alias="false" withSubpackages="true" />
40+
<package name="javax" alias="false" withSubpackages="true" />
41+
<package name="kotlin" alias="false" withSubpackages="true" />
42+
<package name="" alias="true" withSubpackages="true" />
43+
</value>
44+
</option>
45+
</JetCodeStyleSettings>
46+
</code_scheme>
47+
</component>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<component name="ProjectCodeStyleConfiguration">
2+
<state>
3+
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
4+
</state>
5+
</component>

0 commit comments

Comments
 (0)