-
Notifications
You must be signed in to change notification settings - Fork 52
/
build.gradle.kts
92 lines (78 loc) · 2.74 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
84
85
86
87
88
89
90
91
92
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import org.gradle.api.tasks.testing.TestResult.ResultType
plugins {
id("com.github.ben-manes.versions") version Versions.gradleVersionsPluginVersion
}
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath(ClassPaths.gradle)
classpath(ClassPaths.kotlinGradlePlugin)
classpath(ClassPaths.daggerHiltGradlePlugin)
}
}
allprojects {
repositories {
google()
mavenCentral()
maven("https://jitpack.io")
}
}
subprojects {
tasks.withType(Test::class.java) {
testLogging {
showCauses = false
showExceptions = false
showStackTraces = false
showStandardStreams = false
val ansiReset = "\u001B[0m"
val ansiGreen = "\u001B[32m"
val ansiRed = "\u001B[31m"
val ansiYellow = "\u001B[33m"
fun getColoredResultType(resultType: ResultType): String {
return when (resultType) {
ResultType.SUCCESS -> "$ansiGreen $resultType $ansiReset"
ResultType.FAILURE -> "$ansiRed $resultType $ansiReset"
ResultType.SKIPPED -> "$ansiYellow $resultType $ansiReset"
}
}
beforeSuite(
KotlinClosure1<TestDescriptor, Unit>({
if (this.className != null) {
println()
println(this.className?.substringAfterLast(".").orEmpty())
}
})
)
afterTest(
KotlinClosure2({ desc: TestDescriptor, result: TestResult ->
println("${desc.displayName} = ${getColoredResultType(result.resultType)}")
})
)
afterSuite(
KotlinClosure2({ desc: TestDescriptor, result: TestResult ->
if (desc.parent == null) {
println("Result: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} passed, ${result.failedTestCount} failed, ${result.skippedTestCount} skipped)")
}
})
)
}
}
}
tasks.register("clean", Delete::class.java) {
delete(rootProject.buildDir)
}
fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return isStable.not()
}
tasks.named<DependencyUpdatesTask>("dependencyUpdates").configure {
rejectVersionIf {
isNonStable(candidate.version)
}
}