Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
## [Unreleased]
### Changed
* Added support and bump Eclipse formatter default versions to `4.21` for `eclipse-groovy`. Change is only applied for JVM 11+.
* Added support for ktlint's FilenameRule ([#974](https://github.com/diffplug/spotless/pull/974)).

### Fixed
* Temporary workspace deletion for Eclipse based formatters on JVM shutdown ([#967](https://github.com/diffplug/spotless/issues/967)). Change is only applied for Eclipse versions using JVM 11+, no back-port to older versions is planned.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ FormatterFunc createFormat() throws Exception {
/* editorConfigPath, nullable */ String.class,
/* debug */ boolean.class);
Method formatterMethod = ktlintClass.getMethod("format", paramsClass);
formatterFunc = input -> {
FormatterFunc.NeedsFile needsFile = (input, file) -> {
try {
Object params = constructor.newInstance(
/* fileName, nullable */ null,
/* fileName, nullable */ file.getName(),
/* text */ input,
/* ruleSets */ ruleSets,
/* userData */ userData,
Expand All @@ -170,6 +170,7 @@ FormatterFunc createFormat() throws Exception {
throw ThrowingEx.unwrapCause(e);
}
};
formatterFunc = FormatterFunc.needsFile(needsFile);
} else {
// and its format method
String formatterMethodName = isScript ? "formatScript" : "format";
Expand Down
1 change: 1 addition & 0 deletions plugin-gradle/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
## [Unreleased]
### Changed
* Added support and bump Eclipse formatter default versions to `4.21` for `eclipse-groovy`. Change is only applied for JVM 11+.
* Added support for ktlint's FilenameRule ([#974](https://github.com/diffplug/spotless/pull/974)).

### Fixed
* Temporary workspace deletion for Eclipse based formatters on JVM shutdown ([#967](https://github.com/diffplug/spotless/issues/967)). Change is only applied for Eclipse versions using JVM 11+, no back-port to older versions is planned.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ void testWithHeader() throws IOException {
" ktlint()",
" }",
"}");
setFile("src/main/kotlin/test.kt").toResource("kotlin/licenseheader/KotlinCodeWithoutHeader.test");
setFile("src/main/kotlin/AnObject.kt").toResource("kotlin/licenseheader/KotlinCodeWithoutHeader.test");
gradleRunner().withArguments("spotlessApply").build();
assertFile("src/main/kotlin/test.kt").hasContent(HEADER + "\n" + getTestResource("kotlin/licenseheader/KotlinCodeWithoutHeader.test"));
assertFile("src/main/kotlin/AnObject.kt").hasContent(HEADER + "\n" + getTestResource("kotlin/licenseheader/KotlinCodeWithoutHeader.test"));
}

@Test
Expand All @@ -173,9 +173,9 @@ void testWithHeaderKtfmt() throws IOException {
" ktfmt()",
" }",
"}");
setFile("src/main/kotlin/test.kt").toResource("kotlin/licenseheader/KotlinCodeWithoutHeader.test");
setFile("src/main/kotlin/AnObject.kt").toResource("kotlin/licenseheader/KotlinCodeWithoutHeader.test");
gradleRunner().withArguments("spotlessApply").build();
assertFile("src/main/kotlin/test.kt").hasContent(HEADER + "\n" + getTestResource("kotlin/licenseheader/KotlinCodeWithoutHeaderKtfmt.test"));
assertFile("src/main/kotlin/AnObject.kt").hasContent(HEADER + "\n" + getTestResource("kotlin/licenseheader/KotlinCodeWithoutHeaderKtfmt.test"));
}

@Test
Expand All @@ -192,9 +192,9 @@ void testWithCustomHeaderSeparator() throws IOException {
" ktlint()",
" }",
"}");
setFile("src/main/kotlin/test.kt").toResource("kotlin/licenseheader/KotlinCodeWithoutHeader.test");
setFile("src/main/kotlin/AnObject.kt").toResource("kotlin/licenseheader/KotlinCodeWithoutHeader.test");
gradleRunner().withArguments("spotlessApply").build();
assertFile("src/main/kotlin/test.kt").hasContent(HEADER + "\n" + getTestResource("kotlin/licenseheader/KotlinCodeWithoutHeader.test"));
assertFile("src/main/kotlin/AnObject.kt").hasContent(HEADER + "\n" + getTestResource("kotlin/licenseheader/KotlinCodeWithoutHeader.test"));
}

@Test
Expand All @@ -212,9 +212,9 @@ void testWithCustomHeaderSeparatorKtfmt() throws IOException {
" ktfmt()",
" }",
"}");
setFile("src/main/kotlin/test.kt").toResource("kotlin/licenseheader/KotlinCodeWithoutHeader.test");
setFile("src/main/kotlin/AnObject.kt").toResource("kotlin/licenseheader/KotlinCodeWithoutHeader.test");
gradleRunner().withArguments("spotlessApply").build();
assertFile("src/main/kotlin/test.kt").hasContent(HEADER + "\n" + getTestResource("kotlin/licenseheader/KotlinCodeWithoutHeaderKtfmt.test"));
assertFile("src/main/kotlin/AnObject.kt").hasContent(HEADER + "\n" + getTestResource("kotlin/licenseheader/KotlinCodeWithoutHeaderKtfmt.test"));
}

@Test
Expand All @@ -232,13 +232,13 @@ void testWithNonStandardYearSeparator() throws IOException {
" }",
"}");

setFile("src/main/kotlin/test.kt").toResource("kotlin/licenseheader/KotlinCodeWithMultiYearHeader.test");
setFile("src/main/kotlin/test2.kt").toResource("kotlin/licenseheader/KotlinCodeWithMultiYearHeader2.test");
setFile("src/main/kotlin/AnObject.kt").toResource("kotlin/licenseheader/KotlinCodeWithMultiYearHeader.test");
setFile("src/main/kotlin/AnObject2.kt").toResource("kotlin/licenseheader/KotlinCodeWithMultiYearHeader2.test");
gradleRunner().withArguments("spotlessApply").build();
assertFile("src/main/kotlin/test.kt").matches(matcher -> {
assertFile("src/main/kotlin/AnObject.kt").matches(matcher -> {
matcher.startsWith("// License Header 2012, 2014");
});
assertFile("src/main/kotlin/test2.kt").matches(matcher -> {
assertFile("src/main/kotlin/AnObject2.kt").matches(matcher -> {
matcher.startsWith("// License Header 2012, 2014");
});
}
Expand All @@ -259,13 +259,13 @@ void testWithNonStandardYearSeparatorKtfmt() throws IOException {
" }",
"}");

setFile("src/main/kotlin/test.kt").toResource("kotlin/licenseheader/KotlinCodeWithMultiYearHeader.test");
setFile("src/main/kotlin/test2.kt").toResource("kotlin/licenseheader/KotlinCodeWithMultiYearHeader2.test");
setFile("src/main/kotlin/AnObject.kt").toResource("kotlin/licenseheader/KotlinCodeWithMultiYearHeader.test");
setFile("src/main/kotlin/AnObject2.kt").toResource("kotlin/licenseheader/KotlinCodeWithMultiYearHeader2.test");
gradleRunner().withArguments("spotlessApply").build();
assertFile("src/main/kotlin/test.kt").matches(matcher -> {
assertFile("src/main/kotlin/AnObject.kt").matches(matcher -> {
matcher.startsWith("// License Header 2012, 2014");
});
assertFile("src/main/kotlin/test2.kt").matches(matcher -> {
assertFile("src/main/kotlin/AnObject2.kt").matches(matcher -> {
matcher.startsWith("// License Header 2012, 2014");
});
}
Expand Down
2 changes: 2 additions & 0 deletions plugin-maven/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
## [Unreleased]
### Changed
* Added support and bump Eclipse formatter default versions to `4.21` for `eclipse-groovy`. Change is only applied for JVM 11+.
* Added support for ktlint's FilenameRule ([#974](https://github.com/diffplug/spotless/pull/974)).

### Fixed
* Revert change from 2.17.2 regarding [skip bug](https://github.com/diffplug/spotless/pull/969) because fixing the skip bug caused inconsistent behavior between `check.skip` and `apply.skip`.
* [skip bug](https://github.com/diffplug/spotless/issues/968) if ratchetFrom is specified, the build will still fail in if no Git repository is found, even if `skip` is true (new fix).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
@file:JvmName("SomeFileName")
package my.test

object AnObject
object AnObject2