Skip to content

Commit 70e0015

Browse files
authored
Merge branch 'main' into main
2 parents 7321d6f + 1b0d489 commit 70e0015

File tree

10 files changed

+96
-4
lines changed

10 files changed

+96
-4
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ This document is intended for Spotless developers.
1010
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`).
1111

1212
## [Unreleased]
13+
### Changes
14+
* Bump default `ktlint` version to latest `1.0.0` -> `1.0.1`. ([#1855](https://github.com/diffplug/spotless/pull/1855))
1315

1416
## [2.42.0] - 2023-09-28
1517
### Added

lib/src/main/java/com/diffplug/spotless/kotlin/KtLintStep.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class KtLintStep {
3636
// prevent direct instantiation
3737
private KtLintStep() {}
3838

39-
private static final String DEFAULT_VERSION = "1.0.0";
39+
private static final String DEFAULT_VERSION = "1.0.1";
4040
static final String NAME = "ktlint";
4141
static final String MAVEN_COORDINATE_0_DOT = "com.pinterest:ktlint:";
4242
static final String MAVEN_COORDINATE_1_DOT = "com.pinterest.ktlint:ktlint-cli:";

plugin-gradle/CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `3.27.0`).
44

55
## [Unreleased]
6+
### Changes
7+
* Bump default `ktlint` version to latest `1.0.0` -> `1.0.1`. ([#1855](https://github.com/diffplug/spotless/pull/1855))
68

79
## [6.22.0] - 2023-09-28
810
### Added

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/KotlinExtensionTest.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,42 @@ void testWithInvalidEditorConfigFile() throws IOException {
105105
assertThat(buildOutput).contains(invalidPath);
106106
}
107107

108+
@Test
109+
void testReadCodeStyleFromEditorConfigFile() throws IOException {
110+
setFile(".editorconfig").toResource("kotlin/ktlint/ktlint_official/.editorconfig");
111+
setFile("build.gradle").toLines(
112+
"plugins {",
113+
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
114+
" id 'com.diffplug.spotless'",
115+
"}",
116+
"repositories { mavenCentral() }",
117+
"spotless {",
118+
" kotlin {",
119+
" ktlint()",
120+
" }",
121+
"}");
122+
checkKtlintOfficialStyle();
123+
}
124+
125+
@Test
126+
void testSetEditorConfigCanOverrideEditorConfigFile() throws IOException {
127+
setFile(".editorconfig").toResource("kotlin/ktlint/intellij_idea/.editorconfig");
128+
setFile("build.gradle").toLines(
129+
"plugins {",
130+
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
131+
" id 'com.diffplug.spotless'",
132+
"}",
133+
"repositories { mavenCentral() }",
134+
"spotless {",
135+
" kotlin {",
136+
" ktlint().editorConfigOverride([",
137+
" ktlint_code_style: \"ktlint_official\",",
138+
" ])",
139+
" }",
140+
"}");
141+
checkKtlintOfficialStyle();
142+
}
143+
108144
@Test
109145
void testWithHeader() throws IOException {
110146
setFile("build.gradle").toLines(
@@ -144,4 +180,11 @@ void testWithCustomMaxWidthDefaultStyleKtfmt() throws IOException {
144180
gradleRunner().withArguments("spotlessApply").build();
145181
assertFile("src/main/kotlin/max-width.kt").sameAsResource("kotlin/ktfmt/max-width.clean");
146182
}
183+
184+
private void checkKtlintOfficialStyle() throws IOException {
185+
String path = "src/main/kotlin/Main.kt";
186+
setFile(path).toResource("kotlin/ktlint/experimentalEditorConfigOverride.dirty");
187+
gradleRunner().withArguments("spotlessApply").build();
188+
assertFile(path).sameAsResource("kotlin/ktlint/experimentalEditorConfigOverride.ktlintOfficial.clean");
189+
}
147190
}

plugin-maven/CHANGES.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`).
44

55
## [Unreleased]
6-
### Fixed
7-
* Fix crash when build dir is a softlink to another directory. ([#1859](https://github.com/diffplug/spotless/pull/1859))
86
### Added
97
* CompileSourceRoots and TestCompileSourceRoots are now respected as default includes. These properties are commonly set when adding extra source directories. ([#1846](https://github.com/diffplug/spotless/issues/1846))
8+
### Fixed
9+
* Fix crash when build dir is a softlink to another directory. ([#1859](https://github.com/diffplug/spotless/pull/1859))
10+
### Changes
11+
* Bump default `ktlint` version to latest `1.0.0` -> `1.0.1`. ([#1855](https://github.com/diffplug/spotless/pull/1855))
1012

1113
## [2.40.0] - 2023-09-28
1214
### Added

plugin-maven/src/test/java/com/diffplug/spotless/maven/kotlin/KtlintTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,29 @@ void testKtlintEditorConfigOverride() throws Exception {
4444
mavenRunner().withArguments("spotless:apply").runNoError();
4545
assertFile(path).sameAsResource("kotlin/ktlint/experimentalEditorConfigOverride.clean");
4646
}
47+
48+
@Test
49+
void testReadCodeStyleFromEditorConfigFile() throws Exception {
50+
setFile(".editorconfig").toResource("kotlin/ktlint/ktlint_official/.editorconfig");
51+
writePomWithKotlinSteps("<ktlint/>");
52+
checkKtlintOfficialStyle();
53+
}
54+
55+
@Test
56+
void testSetEditorConfigCanOverrideEditorConfigFile() throws Exception {
57+
setFile(".editorconfig").toResource("kotlin/ktlint/intellij_idea/.editorconfig");
58+
writePomWithKotlinSteps("<ktlint>\n" +
59+
" <editorConfigOverride>\n" +
60+
" <ktlint_code_style>ktlint_official</ktlint_code_style>\n" +
61+
" </editorConfigOverride>\n" +
62+
"</ktlint>");
63+
checkKtlintOfficialStyle();
64+
}
65+
66+
private void checkKtlintOfficialStyle() throws Exception {
67+
String path = "src/main/kotlin/Main.kt";
68+
setFile(path).toResource("kotlin/ktlint/experimentalEditorConfigOverride.dirty");
69+
mavenRunner().withArguments("spotless:apply").runNoError();
70+
assertFile(path).sameAsResource("kotlin/ktlint/experimentalEditorConfigOverride.ktlintOfficial.clean");
71+
}
4772
}

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ plugins {
2323
// https://github.com/davidburstrom/version-compatibility-gradle-plugin/tags
2424
id 'io.github.davidburstrom.version-compatibility' version '0.5.0' apply false
2525
// https://plugins.gradle.org/plugin/com.gradle.enterprise
26-
id 'com.gradle.enterprise' version '3.15'
26+
id 'com.gradle.enterprise' version '3.15.1'
2727
// https://github.com/equodev/equo-ide/blob/main/plugin-gradle/CHANGELOG.md
2828
id 'dev.equo.ide' version '1.7.3' apply false
2929
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fun main() {
2+
val list =
3+
listOf(
4+
"hello",
5+
)
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
root = true
2+
3+
[*.{kt,kts}]
4+
ij_kotlin_allow_trailing_comma = true
5+
ij_kotlin_allow_trailing_comma_on_call_site = true
6+
ktlint_code_style = intellij_idea
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
root = true
2+
3+
[*.{kt,kts}]
4+
ij_kotlin_allow_trailing_comma = true
5+
ij_kotlin_allow_trailing_comma_on_call_site = true
6+
ktlint_code_style = ktlint_official

0 commit comments

Comments
 (0)