-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle.kts
70 lines (62 loc) · 1.82 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
dependencies {
classpath(Dependencies.ClassPaths.GRADLE)
classpath(Dependencies.ClassPaths.KOTLIN_GRADLE_PLUGIN)
classpath(Dependencies.Linters.KT_LINT)
}
}
plugins {
id(Dependencies.Linters.KT_LINT_PLUGIN) version (Dependencies.Versions.KLINT_GRADLE)
}
allprojects {
repositories {
google()
mavenCentral()
maven { setUrl("https://jitpack.io") }
}
}
// task that copy the pre-commit hook to .git/hooks
// this task is executed when gradle is executed
// this task is executed only if the pre-commit hook does not exist
tasks.register<Copy>("copyGitHooks") {
val preCommitHook = ".git/hooks/pre-commit"
val preCommitHookFile = File(preCommitHook)
if (!preCommitHookFile.exists()) {
from("pre-commit")
into(".git/hooks")
rename("pre-commit.sample", "pre-commit")
preCommitHookFile.setExecutable(true)
}
}
// task that runs ktlint on all kotlin files
// this task is executed only from the pre-commit hook
tasks.register("preCommit") {
dependsOn("ktlint")
doLast {
exec {
commandLine("ktlintCheck", "app/src/**/*.kt")
commandLine("ktlintCheck", "core/**/*.kt")
// Uncomment this line to run linter on example folder
// commandLine("ktlintCheck", "example/**/*.kt")
}
}
}
tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}
subprojects {
apply(plugin = Dependencies.Linters.KT_LINT_PLUGIN)
}
ktlint {
debug.set(true)
verbose.set(true)
android.set(true)
outputToConsole.set(true)
ignoreFailures.set(false)
}