From 57788b87e745f9b1f01682aaa36565faada5e6c1 Mon Sep 17 00:00:00 2001 From: Tormod Alf Try Tufteland Date: Fri, 16 Sep 2022 15:33:48 +0200 Subject: [PATCH 1/4] feat: ktlint editorConfigOverrides for plugin-maven --- plugin-maven/README.md | 4 ++++ .../com/diffplug/spotless/maven/kotlin/Ktlint.java | 14 +++++++++++++- .../diffplug/spotless/maven/kotlin/KtlintTest.java | 10 ++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/plugin-maven/README.md b/plugin-maven/README.md index 19796770ef..a6a8491784 100644 --- a/plugin-maven/README.md +++ b/plugin-maven/README.md @@ -359,6 +359,10 @@ Groovy-Eclipse formatting errors/warnings lead per default to a build failure. T ```xml 0.43.2 + + true + true + ``` diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/kotlin/Ktlint.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/kotlin/Ktlint.java index 796523d315..5792ee0611 100644 --- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/kotlin/Ktlint.java +++ b/plugin-maven/src/main/java/com/diffplug/spotless/maven/kotlin/Ktlint.java @@ -22,14 +22,26 @@ import com.diffplug.spotless.maven.FormatterStepConfig; import com.diffplug.spotless.maven.FormatterStepFactory; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + public class Ktlint implements FormatterStepFactory { @Parameter private String version; + @Parameter + private Map editorConfigOverride; + @Override public FormatterStep newFormatterStep(FormatterStepConfig config) { String ktlintVersion = version != null ? version : KtLintStep.defaultVersion(); - return KtLintStep.create(ktlintVersion, config.getProvisioner()); + + if (editorConfigOverride == null) { + editorConfigOverride = new HashMap<>(); + } + + return KtLintStep.create(ktlintVersion, config.getProvisioner(), false, Collections.emptyMap(), editorConfigOverride); } } diff --git a/plugin-maven/src/test/java/com/diffplug/spotless/maven/kotlin/KtlintTest.java b/plugin-maven/src/test/java/com/diffplug/spotless/maven/kotlin/KtlintTest.java index 887f7a3f50..ba6f1d8e2c 100644 --- a/plugin-maven/src/test/java/com/diffplug/spotless/maven/kotlin/KtlintTest.java +++ b/plugin-maven/src/test/java/com/diffplug/spotless/maven/kotlin/KtlintTest.java @@ -29,4 +29,14 @@ void testKtlint() throws Exception { mavenRunner().withArguments("spotless:apply").runNoError(); assertFile(path).sameAsResource("kotlin/ktlint/basic.clean"); } + + @Test + void testKtlintEditorConfigOverride() throws Exception { + writePomWithKotlinSteps("truetrue"); + + String path = "src/main/kotlin/Main.kt"; + setFile(path).toResource("kotlin/ktlint/experimentalEditorConfigOverride.dirty"); + mavenRunner().withArguments("spotless:apply").runNoError(); + assertFile(path).sameAsResource("kotlin/ktlint/experimentalEditorConfigOverride.clean"); + } } From e4f1fc92a1c280c6b370530e6f64a69b8daa8296 Mon Sep 17 00:00:00 2001 From: Tormod Alf Try Tufteland Date: Fri, 16 Sep 2022 16:43:53 +0200 Subject: [PATCH 2/4] doc: add changes --- CHANGES.md | 2 ++ plugin-maven/CHANGES.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 23c20dc957..b0117a4bd5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,6 +10,8 @@ This document is intended for Spotless developers. We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`). ## [Unreleased] +### Added +* Support for `editorConfigOverride` in `ktlint`, `plugin-maven`. ([#1335](https://github.com/diffplug/spotless/pull/1335) fixes [#1334](https://github.com/diffplug/spotless/issues/1334)) ## [2.30.0] - 2022-09-14 ### Added diff --git a/plugin-maven/CHANGES.md b/plugin-maven/CHANGES.md index 1ce37116a1..6046e7aed1 100644 --- a/plugin-maven/CHANGES.md +++ b/plugin-maven/CHANGES.md @@ -3,6 +3,8 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`). ## [Unreleased] +### Added +* Support for `editorConfigOverride` in `ktlint`, `plugin-maven`. ([#1335](https://github.com/diffplug/spotless/pull/1335) fixes [#1334](https://github.com/diffplug/spotless/issues/1334)) ## [2.26.0] - 2022-09-14 ### Added From 96803ae88ff4d0d4de554dc4a5f00fb1d4b47cdf Mon Sep 17 00:00:00 2001 From: Tormod Alf Try Tufteland Date: Sat, 17 Sep 2022 10:57:17 +0200 Subject: [PATCH 3/4] fix: linting --- .../com/diffplug/spotless/maven/kotlin/Ktlint.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/kotlin/Ktlint.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/kotlin/Ktlint.java index 5792ee0611..45bda05065 100644 --- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/kotlin/Ktlint.java +++ b/plugin-maven/src/main/java/com/diffplug/spotless/maven/kotlin/Ktlint.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. @@ -15,6 +15,10 @@ */ package com.diffplug.spotless.maven.kotlin; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + import org.apache.maven.plugins.annotations.Parameter; import com.diffplug.spotless.FormatterStep; @@ -22,10 +26,6 @@ import com.diffplug.spotless.maven.FormatterStepConfig; import com.diffplug.spotless.maven.FormatterStepFactory; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - public class Ktlint implements FormatterStepFactory { @Parameter From 59c166a369e77867d28b453b94787111f36a96a7 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Mon, 19 Sep 2022 13:02:20 -0700 Subject: [PATCH 4/4] Only changes are in plugin-maven, so that's the only changelog that should change. --- CHANGES.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b0117a4bd5..23c20dc957 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,8 +10,6 @@ This document is intended for Spotless developers. We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`). ## [Unreleased] -### Added -* Support for `editorConfigOverride` in `ktlint`, `plugin-maven`. ([#1335](https://github.com/diffplug/spotless/pull/1335) fixes [#1334](https://github.com/diffplug/spotless/issues/1334)) ## [2.30.0] - 2022-09-14 ### Added