-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbase.gradle.kts
155 lines (135 loc) · 4.24 KB
/
base.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
package buildsrc.conventions
import java.time.Duration
import org.gradle.api.tasks.testing.logging.TestLogEvent
/**
* A convention plugin that sets up common config and sensible defaults for all subprojects.
*/
plugins {
base
}
if (project != rootProject) {
project.version = rootProject.version
project.group = rootProject.group
}
tasks.withType<AbstractArchiveTask>().configureEach {
// https://docs.gradle.org/current/userguide/working_with_files.html#sec:reproducible_archives
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}
tasks.withType<AbstractTestTask>().configureEach {
timeout = Duration.ofMinutes(60)
testLogging {
showCauses = true
showExceptions = true
showStackTraces = true
showStandardStreams = true
events(
TestLogEvent.PASSED,
TestLogEvent.FAILED,
TestLogEvent.SKIPPED,
TestLogEvent.STARTED,
TestLogEvent.STANDARD_ERROR,
TestLogEvent.STANDARD_OUT,
)
}
}
tasks.withType<AbstractCopyTask>().configureEach {
includeEmptyDirs = false
}
val updateTestReportCss by tasks.registering {
description = "Hack so the Gradle test reports have dark mode"
// the CSS is based on https://github.com/gradle/gradle/pull/12177
mustRunAfter(tasks.withType<Test>())
mustRunAfter(tasks.withType<TestReport>())
val cssFiles = layout.buildDirectory.asFileTree.matching {
include("reports/**/css/base-style.css")
include("reports/**/css/style.css")
}
outputs.files(cssFiles.files)
doLast {
cssFiles.forEach { cssFile ->
val fileContent = cssFile.readText()
if ("/* Dark mode */" in fileContent) {
return@forEach
} else {
when (cssFile.name) {
"base-style.css" -> cssFile.writeText(
fileContent + """
/* Dark mode */
@media (prefers-color-scheme: dark) {
html {
background: black;
}
body, a, a:visited {
color: #E7E7E7FF;
}
#footer, #footer a {
color: #cacaca;
}
ul.tabLinks li {
border: solid 1px #cacaca;
background-color: #151515;
}
ul.tabLinks li:hover {
background-color: #383838;
}
ul.tabLinks li.selected {
background-color: #002d32;
border-color: #007987;
}
div.tab th, div.tab table {
border-bottom: solid #d0d0d0 1px;
}
span.code pre {
background-color: #0a0a0a;
border: solid 1px #5f5f5f;
}
}
""".trimIndent()
)
"style.css" -> cssFile.writeText(
fileContent + """
/* Dark mode */
@media (prefers-color-scheme: dark) {
.breadcrumbs, .breadcrumbs a {
color: #9b9b9b;
}
#successRate, .summaryGroup {
border: solid 2px #d0d0d0;
}
.success, .success a {
color: #7fff7f;
}
div.success, #successRate.success {
background-color: #001c00;
border-color: #7fff7f;
}
.failures, .failures a {
color: #a30000;
}
.skipped, .skipped a {
color: #a26d13;
}
div.failures, #successRate.failures {
background-color: #170000;
border-color: #a30000;
}
}
""".trimIndent()
)
}
}
}
}
}
tasks.withType<Test>().configureEach {
finalizedBy(updateTestReportCss)
}
tasks.withType<TestReport>().configureEach {
finalizedBy(updateTestReportCss)
}
tasks.matching { it.name == "validatePlugins" }.configureEach {
// prevent warning
// Task ':validatePlugins' uses this output of task ':updateTestReportCss' without declaring an explicit or implicit dependency.
mustRunAfter(updateTestReportCss)
}