-
Notifications
You must be signed in to change notification settings - Fork 16
/
build.gradle.kts
120 lines (103 loc) · 3.59 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
/*
* Copyright (c) 2022 Proton Technologies AG
* This file is part of Proton Technologies AG and Proton Mail.
*
* Proton Mail 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.
*
* Proton Mail 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 Proton Mail. If not, see <https://www.gnu.org/licenses/>.
*/
buildscript {
repositories {
google()
}
dependencies {
classpath(libs.android.tools.build)
classpath(libs.kotlin.gradle)
classpath(libs.hilt.android.gradle)
classpath(libs.google.services)
classpath(libs.sentry.gradle)
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
plugins {
alias(libs.plugins.google.devtools.ksp) apply false
alias(libs.plugins.kotlin.serialization) apply false
alias(libs.plugins.proton.core.detekt)
alias(libs.plugins.proton.core.coverage.config)
alias(libs.plugins.proton.core.coverage) apply false
alias(libs.plugins.proton.core.global.coverage) apply false
}
subprojects {
if (project.findProperty("enableComposeCompilerReports") == "true") {
kotlinCompilerArgs(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" +
project.layout.buildDirectory.asFile.get().absolutePath + "/compose_reports",
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=" +
project.layout.buildDirectory.asFile.get().absolutePath + "/compose_metrics"
)
}
afterEvaluate {
dependencies {
configurations.findByName("detektPlugins")?.let {
add("detektPlugins", project(":detekt-rules"))
}
}
tasks.findByName("detekt")?.dependsOn(":detekt-rules:assemble")
}
}
protonDetekt {
threshold = 0
}
tasks.register("clean", Delete::class) {
delete(rootProject.layout.buildDirectory)
}
setupTests()
kotlinCompilerArgs(
"-opt-in=kotlin.RequiresOptIn",
// Enables experimental Coroutines API.
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
// Enables experimental Time (Turbine).
"-opt-in=kotlin.time.ExperimentalTime"
)
fun Project.kotlinCompilerArgs(vararg extraCompilerArgs: String) {
for (sub in subprojects) {
sub.tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions { freeCompilerArgs = freeCompilerArgs + extraCompilerArgs }
}
}
}
fun Project.setupTests() {
fun Project.isRootProject() = this@isRootProject.subprojects.size != 0
for (sub in subprojects) {
// Apply coverage plugin to non subprojects.
if (!sub.isRootProject()) {
sub.afterEvaluate { pluginManager.apply("me.proton.core.gradle-plugins.coverage") }
}
sub.tasks.withType<Test> {
// Test logging
testLogging {
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
}
// Additional JVM args to bypass strong encapsulation (needed for mocking)
jvmArgs(
"--add-opens", "java.base/java.util=ALL-UNNAMED"
)
}
}
}