Skip to content

Commit

Permalink
Switch to org.jlleitschuh.gradle.ktlint plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
tbroyer committed May 21, 2020
1 parent ff99d5a commit c4da62c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 23 deletions.
28 changes: 6 additions & 22 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import nl.javadude.gradle.plugins.license.LicenseExtension
plugins {
base
id("com.github.sherter.google-java-format") version "0.8"
id("org.jlleitschuh.gradle.ktlint") version "9.2.1"

id("com.github.hierynomus.license") version "0.15.0" apply false
// Used by "local.java-library"
Expand Down Expand Up @@ -36,29 +37,12 @@ subprojects {
}
}

val ktlint by configurations.creating
allprojects {
apply(plugin = "org.jlleitschuh.gradle.ktlint")

dependencies {
ktlint("com.pinterest:ktlint:0.36.0")
}

tasks {
val verifyKtlint by registering(JavaExec::class) {
description = "Check Kotlin code style."
classpath = ktlint
main = "com.pinterest.ktlint.Main"
args("**/*.gradle.kts", "**/*.kt", "!**/build/**")
}

check {
dependsOn(verifyKtlint)
}

register("ktlint", JavaExec::class) {
description = "Fix Kotlin code style violations."
classpath = ktlint
main = "com.pinterest.ktlint.Main"
args("-F", "**/*.gradle.kts", "**/*.kt", "!**/build/**")
ktlint {
version.set("0.36.0")
enableExperimentalRules.set(true)
}
}

Expand Down
16 changes: 16 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
`kotlin-dsl`
id("org.jlleitschuh.gradle.ktlint") version "9.2.1"
}

repositories {
Expand All @@ -9,3 +10,18 @@ repositories {
kotlinDslPluginOptions {
experimentalWarning.set(false)
}

ktlint {
version.set("0.36.0")
enableExperimentalRules.set(true)
filter {
exclude {
it.file in fileTree(buildDir)
}
}
}

dependencies {
// Workaround for https://github.com/JLLeitschuh/ktlint-gradle/issues/239
runtimeOnly(embeddedKotlin("gradle-plugin"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ class IncrementalAnnotationProcessorProcessorIntegrationTest {
).run {
parentFile.mkdirs()
writeText(
"""package ${packageNames.joinToString(separator = ".")};
"""
package ${packageNames.joinToString(separator = ".")};
import static net.ltgt.gradle.incap.IncrementalAnnotationProcessorType.*;
import java.util.Set;
Expand Down

0 comments on commit c4da62c

Please sign in to comment.