-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathbuild.gradle
50 lines (45 loc) · 1.56 KB
/
build.gradle
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
plugins {
alias libs.plugins.android.application apply false
alias libs.plugins.android.library apply false
alias libs.plugins.kotlin.android apply false
}
tasks.register("clean", Delete) {
delete rootProject.layout.buildDirectory
delete file(".git/hooks/pre-commit")
}
def installQATools = tasks.register("installQATools", Exec) {
def cacheFile = rootProject.layout.buildDirectory.file(".qaToolsInstalled").get().asFile
outputs.file(cacheFile)
commandLine "python3", "-m", "pip", "install", "--upgrade", "editorconfig-checker", "pycodestyle", "cmakelang"
doLast {
cacheFile.createNewFile()
}
}
tasks.register("checkFormat", Exec) {
dependsOn installQATools
group = "Verification"
description = "Checks code format and names"
commandLine "python3", file("tools/scripts/check-format.py")
}
def installGitHook = tasks.register("installGitHook") {
dependsOn installQATools
def hookFile = file(".git/hooks/pre-commit")
outputs.file(hookFile)
doLast {
def scriptFile = file("tools/scripts/check-format.py")
hookFile.text = "#!/bin/sh\npython3 ${scriptFile} --hook\n"
hookFile.setExecutable(true)
}
}
gradle.afterProject { project ->
project.tasks.all { task ->
def lowerName = task.name.toLowerCase()
if ((task.group != "help") &&
(lowerName.indexOf("clean") < 0) &&
(lowerName != "wrapper") &&
(lowerName != "installqatools") &&
(lowerName != "installgithook")) {
task.dependsOn(installGitHook)
}
}
}