-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #187 from usefulness/updates
Improve configuration-cache compatibility, validate editorconfigs
- Loading branch information
Showing
13 changed files
with
427 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
public final class io/github/usefulness/EditorConfigValidationMode : java/lang/Enum { | ||
public static final field BuildFailure Lio/github/usefulness/EditorConfigValidationMode; | ||
public static final field None Lio/github/usefulness/EditorConfigValidationMode; | ||
public static final field PrintWarningLogs Lio/github/usefulness/EditorConfigValidationMode; | ||
public static fun valueOf (Ljava/lang/String;)Lio/github/usefulness/EditorConfigValidationMode; | ||
public static fun values ()[Lio/github/usefulness/EditorConfigValidationMode; | ||
} | ||
|
||
public class io/github/usefulness/KtlintGradleExtension { | ||
public static final field DEFAULT_CHUNK_SIZE I | ||
public static final field DEFAULT_EXPERIMENTAL_RULES Z | ||
public static final field DEFAULT_IGNORE_FAILURES Z | ||
public final fun editorConfigValidation (Ljava/lang/Object;)V | ||
public final fun getBaselineFile ()Lorg/gradle/api/file/RegularFileProperty; | ||
public final fun getChunkSize ()Lorg/gradle/api/provider/Property; | ||
public final fun getDisabledRules ()Lorg/gradle/api/provider/ListProperty; | ||
public final fun getEditorConfigValidation ()Lorg/gradle/api/provider/Property; | ||
public final fun getExperimentalRules ()Lorg/gradle/api/provider/Property; | ||
public final fun getIgnoreFailures ()Lorg/gradle/api/provider/Property; | ||
public final fun getIgnoreFilesUnderBuildDir ()Lorg/gradle/api/provider/Property; | ||
public final fun getIgnoreKspGeneratedSources ()Lorg/gradle/api/provider/Property; | ||
public final fun getKtlintVersion ()Lorg/gradle/api/provider/Property; | ||
public final fun getReporters ()Lorg/gradle/api/provider/ListProperty; | ||
} | ||
|
||
public final class io/github/usefulness/KtlintGradlePlugin : org/gradle/api/Plugin { | ||
public fun <init> ()V | ||
public synthetic fun apply (Ljava/lang/Object;)V | ||
public fun apply (Lorg/gradle/api/Project;)V | ||
} | ||
|
||
public class io/github/usefulness/tasks/CheckEditorConfigTask : org/gradle/api/DefaultTask { | ||
public fun <init> (Lorg/gradle/api/model/ObjectFactory;)V | ||
public final fun getMode ()Lorg/gradle/api/provider/Property; | ||
public final fun run ()V | ||
} | ||
|
||
public class io/github/usefulness/tasks/FormatTask : io/github/usefulness/tasks/KtlintWorkTask { | ||
public fun <init> (Lorg/gradle/workers/WorkerExecutor;Lorg/gradle/api/model/ObjectFactory;Lorg/gradle/api/file/ProjectLayout;)V | ||
public final fun run (Lorg/gradle/work/InputChanges;)V | ||
} | ||
|
||
public abstract class io/github/usefulness/tasks/KtlintWorkTask : org/gradle/api/DefaultTask, org/gradle/api/tasks/util/PatternFilterable { | ||
public fun <init> (Lorg/gradle/workers/WorkerExecutor;Lorg/gradle/api/file/ProjectLayout;Lorg/gradle/api/model/ObjectFactory;Lorg/gradle/api/tasks/util/PatternFilterable;)V | ||
public synthetic fun <init> (Lorg/gradle/workers/WorkerExecutor;Lorg/gradle/api/file/ProjectLayout;Lorg/gradle/api/model/ObjectFactory;Lorg/gradle/api/tasks/util/PatternFilterable;ILkotlin/jvm/internal/DefaultConstructorMarker;)V | ||
public fun exclude (Lgroovy/lang/Closure;)Lorg/gradle/api/tasks/util/PatternFilterable; | ||
public fun exclude (Ljava/lang/Iterable;)Lorg/gradle/api/tasks/util/PatternFilterable; | ||
public fun exclude (Lorg/gradle/api/specs/Spec;)Lorg/gradle/api/tasks/util/PatternFilterable; | ||
public fun exclude ([Ljava/lang/String;)Lorg/gradle/api/tasks/util/PatternFilterable; | ||
public final fun getBaselineFile ()Lorg/gradle/api/file/RegularFileProperty; | ||
public final fun getChunkSize ()Lorg/gradle/api/provider/Property; | ||
public final fun getDisabledRules ()Lorg/gradle/api/provider/ListProperty; | ||
public fun getExcludes ()Ljava/util/Set; | ||
public final fun getExperimentalRules ()Lorg/gradle/api/provider/Property; | ||
public final fun getIgnoreFailures ()Lorg/gradle/api/provider/Property; | ||
public fun getIncludes ()Ljava/util/Set; | ||
public final fun getJvmArgs ()Lorg/gradle/api/provider/ListProperty; | ||
public final fun getKtlintClasspath ()Lorg/gradle/api/file/ConfigurableFileCollection; | ||
public final fun getReportersConfiguration ()Lorg/gradle/api/file/ConfigurableFileCollection; | ||
public final fun getReports ()Lorg/gradle/api/provider/MapProperty; | ||
public final fun getRuleSetsClasspath ()Lorg/gradle/api/file/ConfigurableFileCollection; | ||
public final fun getSource ()Lorg/gradle/api/file/FileCollection; | ||
public final fun getWorkerMaxHeapSize ()Lorg/gradle/api/provider/Property; | ||
public fun include (Lgroovy/lang/Closure;)Lorg/gradle/api/tasks/util/PatternFilterable; | ||
public fun include (Ljava/lang/Iterable;)Lorg/gradle/api/tasks/util/PatternFilterable; | ||
public fun include (Lorg/gradle/api/specs/Spec;)Lorg/gradle/api/tasks/util/PatternFilterable; | ||
public fun include ([Ljava/lang/String;)Lorg/gradle/api/tasks/util/PatternFilterable; | ||
public fun setExcludes (Ljava/lang/Iterable;)Lorg/gradle/api/tasks/util/PatternFilterable; | ||
public fun setIncludes (Ljava/lang/Iterable;)Lorg/gradle/api/tasks/util/PatternFilterable; | ||
public final fun setSource (Ljava/lang/Object;)V | ||
public final fun source ([Ljava/lang/Object;)Lio/github/usefulness/tasks/KtlintWorkTask; | ||
} | ||
|
||
public class io/github/usefulness/tasks/LintTask : io/github/usefulness/tasks/KtlintWorkTask { | ||
public fun <init> (Lorg/gradle/workers/WorkerExecutor;Lorg/gradle/api/model/ObjectFactory;Lorg/gradle/api/file/ProjectLayout;)V | ||
public final fun run (Lorg/gradle/work/InputChanges;)V | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
ktlint-gradle-plugin/src/main/kotlin/io/github/usefulness/EditorConfigValidationMode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.github.usefulness | ||
|
||
import org.gradle.api.Incubating | ||
|
||
@Incubating | ||
public enum class EditorConfigValidationMode { | ||
None, | ||
PrintWarningLogs, | ||
BuildFailure, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
ktlint-gradle-plugin/src/main/kotlin/io/github/usefulness/tasks/CheckEditorConfigTask.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package io.github.usefulness.tasks | ||
|
||
import io.github.usefulness.EditorConfigValidationMode | ||
import io.github.usefulness.EditorConfigValidationMode.BuildFailure | ||
import io.github.usefulness.EditorConfigValidationMode.None | ||
import io.github.usefulness.EditorConfigValidationMode.PrintWarningLogs | ||
import io.github.usefulness.support.isRootEditorConfig | ||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.GradleException | ||
import org.gradle.api.model.ObjectFactory | ||
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.OutputFile | ||
import org.gradle.api.tasks.PathSensitive | ||
import org.gradle.api.tasks.PathSensitivity | ||
import org.gradle.api.tasks.TaskAction | ||
import javax.inject.Inject | ||
|
||
@CacheableTask | ||
public open class CheckEditorConfigTask @Inject constructor(objectFactory: ObjectFactory) : DefaultTask() { | ||
|
||
@get:InputFiles | ||
@get:PathSensitive(PathSensitivity.RELATIVE) | ||
internal val editorConfigFiles = objectFactory.fileCollection() | ||
|
||
@Input | ||
public val mode: Property<EditorConfigValidationMode> = objectFactory.property<EditorConfigValidationMode>(default = null) | ||
|
||
@get:OutputFile | ||
internal val resultsFile = project.layout.buildDirectory.file("reports/ktlintValidation/result.txt") | ||
|
||
@TaskAction | ||
public fun run() { | ||
val files = editorConfigFiles.files | ||
val messageFn = { | ||
"None of the recognised `.editorconfig` files contain `root=true` entry, this may result in non-deterministic builds. " + | ||
"Please add `root=true` entry to the top-most editorconfig file\n" + | ||
"`.editorconfig` files:\n${files.joinToString(separator = "\n")}" | ||
} | ||
if (files.none { it.isRootEditorConfig }) { | ||
resultsFile.get().asFile.writeText("Failure") | ||
when (mode.get()) { | ||
None -> Unit | ||
PrintWarningLogs -> logger.warn(messageFn()) | ||
|
||
BuildFailure, | ||
null, | ||
-> throw GradleException(messageFn()) | ||
} | ||
} else { | ||
resultsFile.get().asFile.writeText("OK") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.