-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.gradle.kts
224 lines (194 loc) · 6.67 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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/*
* Wire
* Copyright (C) 2024 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
import io.github.leandroborgesferreira.dagcommand.DagCommandPlugin
import io.github.leandroborgesferreira.dagcommand.extension.CommandExtension
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockMismatchReport
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:${libs.versions.agp.get()}")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${libs.versions.kotlin.get()}")
classpath("app.cash.sqldelight:gradle-plugin:${libs.versions.sqldelight.get()}")
classpath("org.jetbrains.dokka:dokka-gradle-plugin:${libs.versions.dokka.get()}")
classpath("com.google.protobuf:protobuf-gradle-plugin:${libs.versions.protobufCodegen.get()}")
classpath("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:${libs.versions.detekt.get()}")
classpath("io.gitlab.arturbosch.detekt:detekt-cli:${libs.versions.detekt.get()}")
classpath("io.github.leandroborgesferreira:dag-command:${libs.versions.dagCommand.get()}")
}
}
repositories {
wireDetektRulesRepo()
google()
mavenCentral()
}
plugins {
id("org.jetbrains.dokka")
alias(libs.plugins.kover)
id("scripts.testing")
id("scripts.detekt")
alias(libs.plugins.moduleGraph)
alias(libs.plugins.completeKotlin)
}
dependencies {
dokkaHtmlPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:${libs.versions.dokka.get()}")
}
tasks.withType<Test> {
useJUnitPlatform {
reports.junitXml.required.set(true)
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
apply<DagCommandPlugin>()
the<CommandExtension>().run {
filter = "all"
defaultBranch = "origin/develop"
outputType = "json"
printModulesInfo = true
}
kover {
useJacoco()
}
koverReport {
filters {
includes {
packages("com.wire.kalium")
}
}
}
fun Project.configureKover() {
pluginManager.apply("org.jetbrains.kotlinx.kover")
kover {
useJacoco()
}
koverReport {
filters {
includes {
packages("com.wire.kalium")
}
}
}
}
subprojects {
// We only want coverage reports of actual Kalium
// Samples and other side-projects can have their own rules
if (name in setOf("monkeys", "testservice", "cli", "android")) {
return@subprojects
}
configureKover()
}
rootProject.plugins.withType(org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin::class.java) {
// For unknown reasons, yarn.lock checks are failing on Github Actions
// Considering JS support is quite experimental for us, we can live with this for now
rootProject.the<YarnRootExtension>().yarnLockMismatchReport =
YarnLockMismatchReport.WARNING
}
dependencies {
kover(project(":logic"))
kover(project(":cryptography"))
kover(project(":util"))
kover(project(":network"))
kover(project(":network-util"))
kover(project(":persistence"))
kover(project(":logger"))
kover(project(":calling"))
kover(project(":protobuf"))
}
rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin> {
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().nodeVersion = "17.6.0"
}
tasks.dokkaHtmlMultiModule.configure {}
moduleGraphConfig {
readmePath.set("./README.md")
heading.set("#### Dependency Graph")
}
tasks.register("runAllUnitTests") {
description = "Runs all Unit Tests."
rootProject.subprojects {
if (tasks.findByName("testDebugUnitTest") != null) {
println("Adding $name to runUnitTests")
dependsOn(":$name:testDebugUnitTest")
}
if (name != "cryptography") {
if (tasks.findByName("jvmTest") != null) {
println("Adding $name to jvmTest")
dependsOn(":$name:jvmTest")
}
}
}
}
tasks.register("aggregateTestResults") {
description = "Aggregates all Unit Test results into a single report."
doLast {
val testResultsDir = rootProject.layout.buildDirectory.dir("testResults").get().asFile
testResultsDir.deleteRecursively()
testResultsDir.mkdirs()
val indexHtmlFile = File(testResultsDir, "index.html")
indexHtmlFile.writeText(
"""
<html>
<head>
<title>Aggregated Test Reports</title>
</head>
<body>
<h1>Aggregated Test Reports</h1>
<ul>
""".trimIndent()
)
rootProject.subprojects {
val testResultsParentDir = layout.buildDirectory.dir("reports/tests").get().asFile
if (testResultsParentDir.exists()) {
testResultsParentDir.listFiles()?.forEach { testDir ->
if (testDir.isDirectory) {
val subprojectDir = File(testResultsDir, "$name/${testDir.name}")
subprojectDir.mkdirs()
testDir.copyRecursively(subprojectDir, overwrite = true)
indexHtmlFile.appendText(
"""
<li><a href="./$name/${testDir.name}/index.html">$name - ${testDir.name} Report</a></li>
""".trimIndent()
)
}
}
}
}
indexHtmlFile.appendText(
"""
</ul>
</body>
</html>
""".trimIndent()
)
// Print the location of the aggregated test results directory
// relative to the current terminal working dir
val currentWorkingDir = File(System.getProperty("user.dir"))
val relativePath = testResultsDir.relativeTo(currentWorkingDir).path
println("Aggregated test reports are available at: $relativePath")
}
}
tasks.wrapper {
distributionType = Wrapper.DistributionType.ALL
}