From 4ce43ec8a23f66d14324a7c09828ca68f879d025 Mon Sep 17 00:00:00 2001 From: Hannes Lerchl Date: Tue, 10 Oct 2023 20:21:31 +0200 Subject: [PATCH 1/2] Add a unit test which passes on Linux but fails on Windows (#715) --- .../gradle/ktlint/KtlintPluginTest.kt | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/KtlintPluginTest.kt b/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/KtlintPluginTest.kt index 1ff5f3ff3..c7963c525 100644 --- a/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/KtlintPluginTest.kt +++ b/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/KtlintPluginTest.kt @@ -196,6 +196,37 @@ class KtlintPluginTest : AbstractPluginTest() { } } + @DisplayName("Should ignore excluded sources which are generated during build") + @CommonTest + fun ignoreExcludedSourcesGeneratedByBuild(gradleVersion: GradleVersion) { + project(gradleVersion) { + withCleanSources() + + //language=Groovy + buildGradle.appendText( + """ + ktlint.filter { exclude { it.file.path.contains("Failing") } } + + task createExtraFile() { + def rootDir = project.getRootDir().toString() + def fileDir = rootDir + "/src/main/kotlin" + def fileName = "FailingSource.kt" + doLast { + file(fileDir).mkdirs() + file(fileDir + "/" + fileName) << "val foo = \"bar\"\n" + } + } + + $CHECK_PARENT_TASK_NAME.dependsOn createExtraFile + """.trimIndent() + ) + + build(CHECK_PARENT_TASK_NAME) { + assertThat(task(":$mainSourceSetCheckTaskName")?.outcome).isEqualTo(TaskOutcome.SUCCESS) + } + } + } + @DisplayName("Should fail on additional source set directories files style violation") @CommonTest fun additionalSourceSetsViolations(gradleVersion: GradleVersion) { From 49e1c0aa3dab3f3e4466aa382b718bf0ed3790f7 Mon Sep 17 00:00:00 2001 From: Hannes Lerchl Date: Wed, 11 Oct 2023 22:20:39 +0200 Subject: [PATCH 2/2] Added CHANGELOG entry for the upcoming fix (required for test suite) --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d852aac1..1c105f4ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/). - fix "additionalEditorconfig not supported until ktlint 0.49" warning [#712](https://github.com/JLLeitschuh/ktlint-gradle/pull/712) - update latest version text file manually [#709](https://github.com/JLLeitschuh/ktlint-gradle/pull/709) - Improve error logging [#711](https://github.com/JLLeitschuh/ktlint-gradle/pull/711) +- Fixed a case, when -on Windows- an exclude filter is ignored [#715](https://github.com/JLLeitschuh/ktlint-gradle/pull/715) ## [11.6.0] - 2023-09-18