From 9831c5962a91a7d9eae08a9fea305c632c06bb3f Mon Sep 17 00:00:00 2001 From: Omico Date: Wed, 27 Jul 2022 23:13:36 -0700 Subject: [PATCH 1/3] Support adding license header for classes without package name --- .../main/java/com/diffplug/spotless/kotlin/KotlinConstants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/main/java/com/diffplug/spotless/kotlin/KotlinConstants.java b/lib/src/main/java/com/diffplug/spotless/kotlin/KotlinConstants.java index 5df0231b8d..a7fc413f94 100644 --- a/lib/src/main/java/com/diffplug/spotless/kotlin/KotlinConstants.java +++ b/lib/src/main/java/com/diffplug/spotless/kotlin/KotlinConstants.java @@ -18,7 +18,7 @@ public final class KotlinConstants { // '^' is prepended to the regex in LICENSE_HEADER_DELIMITER later in FormatExtension.licenseHeader(String, String) - public static final String LICENSE_HEADER_DELIMITER = "(package |@file)"; + public static final String LICENSE_HEADER_DELIMITER = "(package |@file|import )"; private KotlinConstants() {} } From 8715f50537479e629df371679b2b1049ee66c9ea Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Thu, 28 Jul 2022 00:13:04 -0700 Subject: [PATCH 2/3] Update changelogs. --- CHANGES.md | 1 + plugin-gradle/CHANGES.md | 1 + plugin-maven/CHANGES.md | 1 + 3 files changed, 3 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index bed2af6281..8c079e0c4d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -12,6 +12,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ## [Unreleased] ### Added * Clang and Black no longer break the build when the binary is unavailable, if they will not be run during that build ([#1257](https://github.com/diffplug/spotless/pull/1257)). +* License header support for Kotlin files without `package` or `@file` but do at least have `import` ([#1263](https://github.com/diffplug/spotless/pull/1263)). ## [2.27.0] - 2022-06-30 ### Added diff --git a/plugin-gradle/CHANGES.md b/plugin-gradle/CHANGES.md index d38d6ee70a..1653838a3a 100644 --- a/plugin-gradle/CHANGES.md +++ b/plugin-gradle/CHANGES.md @@ -5,6 +5,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ## [Unreleased] ### Added * Clang and Black no longer break the build when the binary is unavailable, if they will not be run during that build ([#1257](https://github.com/diffplug/spotless/pull/1257)). +* License header support for Kotlin files without `package` or `@file` but do at least have `import` ([#1263](https://github.com/diffplug/spotless/pull/1263)). ### Fixed * Warnings about missing `Task#usesService` for Gradle 8.0 ([#1262](https://github.com/diffplug/spotless/pull/1262) fixes [#1260](https://github.com/diffplug/spotless/issues/1260)) diff --git a/plugin-maven/CHANGES.md b/plugin-maven/CHANGES.md index 3499aeab36..732489f81f 100644 --- a/plugin-maven/CHANGES.md +++ b/plugin-maven/CHANGES.md @@ -5,6 +5,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ## [Unreleased] ### Added * Clang and Black no longer break the build when the binary is unavailable, if they will not be run during that build ([#1257](https://github.com/diffplug/spotless/pull/1257)). +* License header support for Kotlin files without `package` or `@file` but do at least have `import` ([#1263](https://github.com/diffplug/spotless/pull/1263)). ## [2.23.0] - 2022-06-30 ### Added From 6d6b09d2d3217e0d59aa5327035a4db5eb338e61 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Thu, 28 Jul 2022 00:13:14 -0700 Subject: [PATCH 3/3] spotlessApply --- .../main/java/com/diffplug/spotless/kotlin/KotlinConstants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/main/java/com/diffplug/spotless/kotlin/KotlinConstants.java b/lib/src/main/java/com/diffplug/spotless/kotlin/KotlinConstants.java index a7fc413f94..da2240f16c 100644 --- a/lib/src/main/java/com/diffplug/spotless/kotlin/KotlinConstants.java +++ b/lib/src/main/java/com/diffplug/spotless/kotlin/KotlinConstants.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 DiffPlug + * Copyright 2016-2022 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.