Created
January 20, 2019 23:28
-
-
Save talenguyen/0072017e7b987564ba3a05dc72fedf0c to your computer and use it in GitHub Desktop.
ktlint configuration
This file contains hidden or 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
// kotlin-gradle-plugin must be applied for configuration below to work | |
// (see https://kotlinlang.org/docs/reference/using-gradle.html) | |
repositories { | |
jcenter() | |
} | |
configurations { | |
ktlint | |
} | |
dependencies { | |
ktlint "com.github.shyiko:ktlint:0.29.0" | |
// additional 3rd party ruleset(s) can be specified here | |
// just add them to the classpath (e.g. ktlint 'groupId:artifactId:version') and | |
// ktlint will pick them up | |
} | |
def outputDir = "${project.buildDir}/reports/ktlint/" | |
def outputFile = "${outputDir}ktlint-checkstyle-report.xml" | |
def inputFiles = project.fileTree(dir: "src", include: "**/*.kt") | |
tasks.register("ktlint", JavaExec) { | |
inputs.files(inputFiles) | |
outputs.dir(outputDir) | |
group = "verification" | |
description = "Check Kotlin code style." | |
classpath = configurations.ktlint | |
main = "com.github.shyiko.ktlint.Main" | |
args = [ | |
"--reporter=plain", | |
"--reporter=checkstyle,output=${outputFile}", | |
"**/src/**/*.kt" | |
] | |
// to generate report in checkstyle format prepend following args: | |
// "--reporter=plain", "--reporter=checkstyle,output=${buildDir}/ktlint.xml" | |
// see https://github.com/shyiko/ktlint#usage for more | |
} | |
tasks.register("ktlintFormat", JavaExec) { | |
group = "verification" | |
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