File tree Expand file tree Collapse file tree 4 files changed +48
-0
lines changed
Expand file tree Collapse file tree 4 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ plugins {
1212 id(" kotlin-parcelize" )
1313}
1414
15+ apply (from = " ../ktlint.gradle.kts" )
16+
1517android {
1618 compileSdk = 30
1719 buildToolsVersion = " 30.0.3"
Original file line number Diff line number Diff line change 1+
2+ task installGitHook (type : Copy ) {
3+ from new File (rootProject. rootDir, ' pre-commit' )
4+ into { new File (rootProject. rootDir, ' .git/hooks' ) }
5+ fileMode 0777
6+ }
7+ preBuild. dependsOn installGitHook
Original file line number Diff line number Diff line change 1+ val ktlint: Configuration by configurations.creating
2+
3+ dependencies {
4+ ktlint(" com.pinterest:ktlint:0.41.0" )
5+ // additional 3rd party ruleset(s) can be specified here
6+ // just add them to the classpath (e.g. ktlint 'groupId:artifactId:version') and
7+ // ktlint will pick them up
8+ }
9+
10+ tasks.register<JavaExec >(" ktlint" ) {
11+ group = " verification"
12+ description = " Check Kotlin code style."
13+ classpath = ktlint
14+ main = " com.pinterest.ktlint.Main"
15+ args(" src/**/*.kt" )
16+ }
17+
18+ tasks.named(" check" ) {
19+ dependsOn(ktlint)
20+ }
21+
22+ tasks.register<JavaExec >(" ktlintFormat" ) {
23+ group = " formatting"
24+ description = " Fix Kotlin code style deviations."
25+ classpath = ktlint
26+ main = " com.pinterest.ktlint.Main"
27+ args(" -F" , " src/**/*.kt" )
28+ }
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ echo " Running git pre-commit hook"
4+
5+ ./gradlew ktlintFormat
6+
7+ RESULT=$?
8+
9+ # return 1 exit code if running checks fails
10+ [ $RESULT -ne 0 ] && exit 1
11+ exit 0
You can’t perform that action at this time.
0 commit comments