From cd6a158ded1a86a3927d15dba04e76c082cc42c5 Mon Sep 17 00:00:00 2001 From: Giovanni Ciatto Date: Fri, 11 Sep 2020 22:54:34 +0200 Subject: [PATCH] + ktlint-gradle plugin --- build.gradle.kts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index c850e8d6f..b6e4de8e0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -22,6 +22,7 @@ plugins { id("org.danilopianini.git-sensitive-semantic-versioning") version Versions.org_danilopianini_git_sensitive_semantic_versioning_gradle_plugin id("de.fayard.buildSrcVersions") version Versions.de_fayard_buildsrcversions_gradle_plugin id("com.github.breadmoirai.github-release") version Versions.com_github_breadmoirai_github_release_gradle_plugin + id("org.jlleitschuh.gradle.ktlint") version "9.4.0" } repositories { @@ -175,6 +176,7 @@ ktSubprojects.forEachProject { } } + configureKtLint() configureDokka("jvm", "js") configureMavenPublications("packDokka") configureUploadToMavenCentral() @@ -192,6 +194,7 @@ jvmSubprojects.forEachProject { apply(plugin = "org.jetbrains.dokka") apply(plugin = "com.jfrog.bintray") + configureKtLint() configureDokka() createMavenPublications("jvm", "java", docArtifact = "packDokka") configureUploadToMavenCentral() @@ -207,6 +210,7 @@ jsSubprojects.forEachProject { apply(plugin = "org.jetbrains.dokka") apply(plugin = "com.jfrog.bintray") + configureKtLint() configureDokka() createMavenPublications("js", "kotlin", docArtifact = "packDokka") configureUploadToMavenCentral() @@ -214,7 +218,7 @@ jsSubprojects.forEachProject { configureSigning() } -configure { +githubRelease { if (githubToken != null) { token(githubToken) owner(githubOwner) @@ -237,6 +241,20 @@ configure { } } +fun Project.configureKtLint() { + apply(plugin = "org.jlleitschuh.gradle.ktlint") + + ktlint { + debug.set(false) + ignoreFailures.set(false) + enableExperimentalRules.set(true) + filter { + exclude("**/generated/**") + include("**/kotlin/**") + } + } +} + fun Project.configureUploadToGithub( jarTaskPositiveFilter: (String) -> Boolean = { "jar" in it }, jarTaskNegativeFilter: (String) -> Boolean = { "dokka" in it || "source" in it }