forked from google/ringdroid
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
60 lines (52 loc) · 1.58 KB
/
build.gradle.kts
File metadata and controls
60 lines (52 loc) · 1.58 KB
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
import com.android.build.gradle.internal.crash.afterEvaluate
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.spotless)
}
spotless {
java {
removeUnusedImports()
eclipse()
leadingSpacesToTabs(2)
leadingTabsToSpaces(4)
target("src/**/*.java")
}
format("xml") {
target("src/**/*.xml")
targetExclude("**/build/", ".idea/")
trimTrailingWhitespace()
leadingTabsToSpaces()
}
kotlin {
target("src/**/*.kt")
ktlint()
}
}
subprojects {
project.tasks.register("createPreCommitHook") {
description = "Creates the .git/hooks/pre-commit file with predefined content."
doLast {
val gitHooksDir = File(project.rootDir, ".git/hooks")
if (!gitHooksDir.exists()) {
gitHooksDir.mkdirs()
}
val preCommitFile = File(gitHooksDir, "pre-commit")
if (preCommitFile.exists()) return@doLast
val content =
"""
#!/usr/bin/env bash
[ -f ./hooks/pre-commit.sh ] && ./hooks/pre-commit.sh
"""
.trimIndent()
preCommitFile.writeText(content)
preCommitFile.setExecutable(true)
}
}
afterEvaluate { project ->
project.tasks.named("preBuild") {
dependsOn("spotlessCheck")
dependsOn("createPreCommitHook")
}
}
}