Skip to content

Commit 215bc02

Browse files
committed
Change "setSource", so it also applies the configured filter
1 parent cf3bcf7 commit 215bc02

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
1010
- fix "additionalEditorconfig not supported until ktlint 0.49" warning [#712](https://github.com/JLLeitschuh/ktlint-gradle/pull/712)
1111
- update latest version text file manually [#709](https://github.com/JLLeitschuh/ktlint-gradle/pull/709)
1212
- Improve error logging [#711](https://github.com/JLLeitschuh/ktlint-gradle/pull/711)
13+
- Fixed a case, when -on Windows- an exclude filter is ignored [#715](https://github.com/JLLeitschuh/ktlint-gradle/pull/715)
1314

1415
## [11.6.0] - 2023-09-18
1516

plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/TaskCreation.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.jlleitschuh.gradle.ktlint
22

33
import org.gradle.api.Project
4+
import org.gradle.api.file.FileCollection
45
import org.gradle.api.file.FileTree
56
import org.gradle.api.tasks.TaskCollection
67
import org.gradle.api.tasks.TaskProvider
@@ -28,7 +29,7 @@ internal fun KtlintPlugin.PluginHolder.addGenerateReportsTaskToProjectMetaFormat
2829
internal fun createFormatTask(
2930
pluginHolder: KtlintPlugin.PluginHolder,
3031
sourceSetName: String,
31-
kotlinSourceDirectories: Iterable<*>
32+
kotlinSourceDirectories: FileCollection
3233
): TaskProvider<KtLintFormatTask> = pluginHolder
3334
.target
3435
.registerTask(
@@ -56,7 +57,7 @@ internal fun createFormatTask(
5657
internal fun createCheckTask(
5758
pluginHolder: KtlintPlugin.PluginHolder,
5859
sourceSetName: String,
59-
kotlinSourceDirectories: Iterable<*>
60+
kotlinSourceDirectories: FileCollection
6061
): TaskProvider<KtLintCheckTask> = pluginHolder
6162
.target
6263
.registerTask(

plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/tasks/BaseKtLintCheckTask.kt

+18-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import org.gradle.api.GradleException
77
import org.gradle.api.JavaVersion
88
import org.gradle.api.file.ConfigurableFileCollection
99
import org.gradle.api.file.FileCollection
10+
import org.gradle.api.file.FileTree
1011
import org.gradle.api.file.FileTreeElement
1112
import org.gradle.api.file.FileType
1213
import org.gradle.api.file.ProjectLayout
@@ -119,15 +120,29 @@ abstract class BaseKtLintCheckTask @Inject constructor(
119120
.from({ sourceFiles.asFileTree.matching(patternFilterable) })
120121

121122
/**
122-
* Sets the source from this task.
123+
* Sets the source for this task from a given file tree.
124+
*
125+
* Filters from configuration will be applied
123126
*
124127
* @param source given source objects will be evaluated as per [org.gradle.api.Project.file].
125128
*/
126-
fun setSource(source: Any): BaseKtLintCheckTask {
127-
sourceFiles = objectFactory.fileCollection().from(source)
129+
fun setSource(source: FileTree): BaseKtLintCheckTask {
130+
sourceFiles = objectFactory
131+
.fileCollection()
132+
.from({ source.matching(patternFilterable) })
128133
return this
129134
}
130135

136+
/**
137+
* Sets the source for this task from a given file collection.
138+
*
139+
* Filters from configuration will be applied
140+
*
141+
* @param source given source objects will be evaluated as per [org.gradle.api.Project.file].
142+
*/
143+
fun setSource(source: FileCollection): BaseKtLintCheckTask =
144+
setSource(source.asFileTree)
145+
131146
/**
132147
* Adds some source to this task.
133148
*

0 commit comments

Comments
 (0)