-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathbuild.gradle.kts
83 lines (63 loc) · 2.48 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
71
72
73
74
75
76
77
78
79
80
81
82
83
import java.nio.file.Paths
subprojects {
repositories {
google()
mavenCentral()
}
}
val installVenv = tasks.register("installVenv", Exec::class.java) {
description = "Install a new virtualenv in ./venv"
outputs.dir(Paths.get(".", "venv"))
commandLine("virtualenv", "venv")
}
val installPreCommit = tasks.register("installPreCommit", Exec::class.java) {
description = "Installs pre-commit in ./venv"
dependsOn(installVenv)
outputs.file(Paths.get(".", "venv", "bin", "pre-commit"))
commandLine(Paths.get(".", "venv", binFolder, "pip"), "install", "pre-commit")
}
val installHooks = tasks.register("installHooks", Exec::class.java) {
description = "Run pre-commit hooks without installing them"
dependsOn(installPreCommit)
outputs.file(Paths.get(".", "venv", binFolder, "pre-commit"))
inputs.file(".pre-commit-config.yaml")
commandLine(Paths.get(".", "venv", binFolder, "pre-commit"), "install", "--install-hooks")
}
val runHooks = tasks.register("runHooks", Exec::class.java) {
description = "Run pre-commit hooks"
dependsOn(installPreCommit)
commandLine(Paths.get(".", "venv", binFolder, "pre-commit"), "run", "--all-files")
}
val preMerge = tasks.register("preMerge") {
description = "Runs pre-commit hooks, build the plugin and sample and execute tests."
dependsOn(runHooks)
dependsOn(gradle.includedBuild("gradle-plugin").task(":plugin:build"))
dependsOn(gradle.includedBuild("gradle-plugin").task(":plugin:check"))
dependsOn(subprojects.filter { it.name != "samples" }.map { it.tasks.named("check") })
}
plugins {
id("com.android.library").version("4.2.2").apply(false)
id("com.yelp.codegen.plugin").version("1.4.1").apply(false)
id("io.gitlab.arturbosch.detekt").version("1.17.1").apply(false)
id("com.github.ben-manes.versions") version "0.39.0"
kotlin("android").version("1.4.32").apply(false)
}
subprojects {
afterEvaluate { // Remove when we have lazy configuration
tasks.all {
if (this is org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
// we need the generated files before we run the kotlin compile task
dependsOn(tasks.named("generateSwagger"))
}
}
}
}
/**
* Python `venv/bin` folder is different based on OS.
* On Windows it's inside the `venv/Scripts` folder.
*/
val binFolder: String get() = if (System.getProperty("os.name").toLowerCase().contains("windows")) {
"Scripts"
} else {
"bin"
}