-
Notifications
You must be signed in to change notification settings - Fork 38
/
build.gradle.kts
134 lines (117 loc) · 4.19 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
import com.getkeepsafe.dexcount.DexMethodCountPlugin
import de.aaschmid.gradle.plugins.cpd.Cpd
import de.aaschmid.gradle.plugins.cpd.CpdExtension
import de.aaschmid.gradle.plugins.cpd.CpdPlugin
import io.gitlab.arturbosch.detekt.DetektPlugin
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.dokka.Platform.jvm
import org.jetbrains.dokka.gradle.DokkaMultiModuleTask
import org.jetbrains.dokka.gradle.DokkaTask
import org.jmailen.gradle.kotlinter.KotlinterPlugin
plugins {
// Android
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
// Kotlin
alias(libs.plugins.jetbrains.kotlin.android) apply false
// Build
alias(libs.plugins.google.ksp) apply false
alias(libs.plugins.google.dagger.hilt.android) apply false
// Static Analysis
alias(libs.plugins.cpd) apply false
alias(libs.plugins.detekt) apply false
alias(libs.plugins.dexcount) apply false
alias(libs.plugins.kotlinter) apply false
// Documentation
alias(libs.plugins.jetbrains.dokka) apply false
}
allprojects {
tasks.withType(Test::class).configureEach {
/*
* Run tests in parallel (https://docs.gradle.org/nightly/userguide/performance.html).
* Must be less than the number of CPU cores.
*/
maxParallelForks = Runtime.getRuntime().availableProcessors().div(2)
testLogging {
// Log events
events = setOf(
TestLogEvent.STARTED,
TestLogEvent.FAILED,
TestLogEvent.SKIPPED,
TestLogEvent.PASSED
)
exceptionFormat = TestExceptionFormat.FULL
showExceptions = true
showCauses = true
showStackTraces = true
}
}
}
subprojects {
// Static Analysis
@Suppress("UnstableApiUsage")
plugins.apply(CpdPlugin::class)
configure<CpdExtension> {
language = "kotlin"
group = "reporting"
isIgnoreFailures = false
minimumTokenCount = 75
}
tasks.withType<Cpd>().configureEach {
source = fileTree("$projectDir/src/main/java")
reports {
text.required.set(false)
xml.required.set(true)
}
exclude(
"**/*Delegate.kt",
"**/*Api.kt"
)
}
plugins.apply(DetektPlugin::class)
configure<io.gitlab.arturbosch.detekt.extensions.DetektExtension> {
config.setFrom(files("${project.rootDir}/config/detekt.yml"))
}
plugins.apply(DexMethodCountPlugin::class)
plugins.apply(KotlinterPlugin::class)
if (this.name != "bom") {
// Code coverage
apply(from = "${rootProject.projectDir}/gradle/jacoco.gradle.kts")
}
/**
* Ideally this would be migrated out of the project level build.gradle.kts to the [DocumentationPlugin],
* but currently the buildSrc directory cannot see [DokkaTask] or [jvm] and unsure why.
*/
tasks.withType<DokkaTask>().configureEach {
outputDirectory.set(project.projectDir.resolve("dokka"))
moduleName.set(project.name)
suppressObviousFunctions.set(false)
dokkaSourceSets {
configureEach {
offlineMode.set(false)
includeNonPublic.set(true)
skipDeprecated.set(false)
reportUndocumented.set(true)
skipEmptyPackages.set(false)
platform.set(jvm)
jdkVersion.set(21)
noStdlibLink.set(false)
noJdkLink.set(false)
noAndroidSdkLink.set(false)
}
}
}
tasks.withType<DokkaMultiModuleTask>().configureEach {
outputDirectory.set(rootProject.projectDir.resolve("dokka"))
moduleName.set(project.name)
suppressObviousFunctions.set(false)
}
configurations.all {
// Check for updates every build
resolutionStrategy.cacheChangingModulesFor(0, "seconds")
}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile>().configureEach {
jvmTargetValidationMode.set(org.jetbrains.kotlin.gradle.dsl.jvm.JvmTargetValidationMode.ERROR)
}