From 3e339c7740b10a2715c773c01562998ed807596d Mon Sep 17 00:00:00 2001 From: Kirill Sinyuk Date: Thu, 18 Jan 2024 20:33:39 +0300 Subject: [PATCH] #356 move ignoreFailures to parent class --- .../gradle/kotlinter/tasks/ConfigurableKtLintTask.kt | 5 +++++ .../kotlin/org/jmailen/gradle/kotlinter/tasks/FormatTask.kt | 3 --- .../kotlin/org/jmailen/gradle/kotlinter/tasks/LintTask.kt | 6 ------ 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/org/jmailen/gradle/kotlinter/tasks/ConfigurableKtLintTask.kt b/src/main/kotlin/org/jmailen/gradle/kotlinter/tasks/ConfigurableKtLintTask.kt index 74c6d3bb..4c809d70 100644 --- a/src/main/kotlin/org/jmailen/gradle/kotlinter/tasks/ConfigurableKtLintTask.kt +++ b/src/main/kotlin/org/jmailen/gradle/kotlinter/tasks/ConfigurableKtLintTask.kt @@ -6,6 +6,7 @@ import org.gradle.api.model.ObjectFactory import org.gradle.api.provider.ListProperty import org.gradle.api.provider.MapProperty import org.gradle.api.provider.Property +import org.gradle.api.tasks.Input import org.gradle.api.tasks.InputFiles import org.gradle.api.tasks.PathSensitive import org.gradle.api.tasks.PathSensitivity @@ -14,6 +15,7 @@ import org.gradle.internal.exceptions.MultiCauseException import org.gradle.work.FileChange import org.gradle.work.Incremental import org.gradle.work.InputChanges +import org.jmailen.gradle.kotlinter.KotlinterExtension.Companion.DEFAULT_IGNORE_FAILURES import org.jmailen.gradle.kotlinter.support.findApplicableEditorConfigFiles abstract class ConfigurableKtLintTask( @@ -28,6 +30,9 @@ abstract class ConfigurableKtLintTask( from(projectLayout.findApplicableEditorConfigFiles().toList()) } + @Input + open val ignoreFailures: Property = objectFactory.property(default = DEFAULT_IGNORE_FAILURES) + protected fun getChangedEditorconfigFiles(inputChanges: InputChanges) = inputChanges.getFileChanges(editorconfigFiles).map(FileChange::getFile) } diff --git a/src/main/kotlin/org/jmailen/gradle/kotlinter/tasks/FormatTask.kt b/src/main/kotlin/org/jmailen/gradle/kotlinter/tasks/FormatTask.kt index 0169bb99..decea3d7 100644 --- a/src/main/kotlin/org/jmailen/gradle/kotlinter/tasks/FormatTask.kt +++ b/src/main/kotlin/org/jmailen/gradle/kotlinter/tasks/FormatTask.kt @@ -31,9 +31,6 @@ open class FormatTask @Inject constructor( @Optional val report: RegularFileProperty = objectFactory.fileProperty() - @Input - val ignoreFailures: Property = objectFactory.property(default = KotlinterExtension.DEFAULT_IGNORE_FAILURES) - @Input val failBuildWhenCannotAutoFormat: Property = objectFactory.property( default = KotlinterExtension.DEFAULT_FAIL_BUILD_WHEN_CANNOT_AUTO_FORMAT, diff --git a/src/main/kotlin/org/jmailen/gradle/kotlinter/tasks/LintTask.kt b/src/main/kotlin/org/jmailen/gradle/kotlinter/tasks/LintTask.kt index 3762b57f..c6f33886 100644 --- a/src/main/kotlin/org/jmailen/gradle/kotlinter/tasks/LintTask.kt +++ b/src/main/kotlin/org/jmailen/gradle/kotlinter/tasks/LintTask.kt @@ -5,9 +5,7 @@ import org.gradle.api.file.FileTree import org.gradle.api.file.ProjectLayout import org.gradle.api.model.ObjectFactory import org.gradle.api.provider.MapProperty -import org.gradle.api.provider.Property import org.gradle.api.tasks.CacheableTask -import org.gradle.api.tasks.Input import org.gradle.api.tasks.InputFiles import org.gradle.api.tasks.OutputFiles import org.gradle.api.tasks.PathSensitive @@ -16,7 +14,6 @@ import org.gradle.api.tasks.TaskAction import org.gradle.work.InputChanges import org.gradle.workers.WorkerExecutor import org.jetbrains.kotlin.utils.addToStdlib.ifNotEmpty -import org.jmailen.gradle.kotlinter.KotlinterExtension.Companion.DEFAULT_IGNORE_FAILURES import org.jmailen.gradle.kotlinter.support.KotlinterError import org.jmailen.gradle.kotlinter.support.LintFailure import org.jmailen.gradle.kotlinter.tasks.lint.LintWorkerAction @@ -40,9 +37,6 @@ open class LintTask @Inject constructor( @PathSensitive(PathSensitivity.RELATIVE) override fun getSource(): FileTree = super.getSource() - @Input - val ignoreFailures: Property = objectFactory.property(default = DEFAULT_IGNORE_FAILURES) - @TaskAction fun run(inputChanges: InputChanges) { val result = with(workerExecutor.noIsolation()) {