-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
57 lines (50 loc) · 1.47 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
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath(libs.android.gradle.plugin)
classpath(libs.kotlin.gradle.plugin)
classpath(libs.hilt.android.gradle.plugin)
classpath(libs.jacoco)
}
}
plugins {
id("org.jlleitschuh.gradle.ktlint") version "11.6.1"
}
tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}
// For Git hooks
tasks {
register<Copy>("copyGitHooks") {
description = "Copies the git hooks from scripts/git-hooks to the .git folder."
group = "git hooks"
from("${rootProject.rootDir}/pre-commit")
into(".git/hooks")
}
register<Exec>("installGitHooks") {
description = "Installs the pre-commit git hooks from scripts/git-hooks."
group = "git hooks"
workingDir(rootDir)
commandLine("chmod")
args("-R", "+x", ".git/hooks/")
dependsOn(named("copyGitHooks"))
onlyIf {
isLinuxOrMacOs()
}
doLast {
logger.info("Git hooks installed successfully.")
}
}
register<Delete>("deleteGitHooks") {
description = "Delete the pre-commit git hooks."
group = "git hooks"
delete(fileTree(".git/hooks/"))
}
}
afterEvaluate {
tasks["clean"].dependsOn(tasks.named("installGitHooks"))
}
fun isLinuxOrMacOs() = System.getProperty("os.name").lowercase(java.util.Locale.ROOT) in listOf("linux", "mac os", "macos")