Skip to content

Instantly share code, notes, and snippets.

@toidv
Created November 19, 2018 04:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toidv/73669640f90aab476f4585b668e27257 to your computer and use it in GitHub Desktop.
Save toidv/73669640f90aab476f4585b668e27257 to your computer and use it in GitHub Desktop.
configurations {
ktlint
}
dependencies {
ktlint "com.github.shyiko:ktlint:$KTLINT_VERSION"
}
task ktlint(type: JavaExec, group: "verification") {
description = "Check Kotlin code style."
classpath = configurations.ktlint
main = "com.github.shyiko.ktlint.Main"
args "src/**/*.kt", "--reporter=checkstyle"
def outputDirectory = "$buildDir/reports/ktlint"
def outputFile = "${outputDirectory}/ktlint-checkstyle-report.xml"
ignoreExitValue = true
doFirst {
new File(outputDirectory).mkdirs()
standardOutput = new FileOutputStream(outputFile)
}
}
check.dependsOn ktlint
task ktlintFormat(type: JavaExec, group: "formatting") {
description = "Fix Kotlin code style deviations."
classpath = configurations.ktlint
main = "com.github.shyiko.ktlint.Main"
args "-F", "src/**/*.kt"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment