Created
December 7, 2018 12:53
-
-
Save ditn/a5152308e113c7cdbe6221fd030c5060 to your computer and use it in GitHub Desktop.
ktlint with Gradle Kotlin DSL
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
val ktlint by configurations.creating | |
dependencies { | |
ktlint(Libraries.ktlint) | |
} | |
tasks.register<JavaExec>("ktlint") { | |
group = "verification" | |
description = "Check Kotlin code style." | |
classpath = ktlint | |
main = "com.github.shyiko.ktlint.Main" | |
args("--android", "src/**/*.kt") | |
} | |
tasks.named("check") { | |
dependsOn(ktlint) | |
} | |
tasks.register<JavaExec>("ktlintFormat") { | |
group = "formatting" | |
description = "Fix Kotlin code style deviations." | |
classpath = ktlint | |
main = "com.github.shyiko.ktlint.Main" | |
args("--android", "-F", "src/**/*.kt") | |
} |
If the dependence of tasks do not work, try this:
tasks.named("check") {
dependsOn(tasks.named("ktlint"))
}
awesome, thank you
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Either declare using
buildSrc
, or just replaceLibraries.ktlint
with"com.github.shyiko:ktlint:0.29.0"
.