Repository navigation
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
103 lines (94 loc) · 4.63 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
103 lines (94 loc) · 4.63 KB
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
import org.gradle.testing.jacoco.plugins.JacocoPlugin
import org.gradle.testing.jacoco.plugins.JacocoTaskExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
google()
}
dependencies {
classpath(libs.com.android.tools.build)
classpath(libs.com.google.gms)
classpath(libs.com.google.firebase.gradle)
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath(libs.kotlin.gradlePlugin)
classpath(libs.kotlin.allopen)
classpath(libs.kotlin.serialization)
}
}
plugins {
alias(libs.plugins.compose.compiler) apply false
id(libs.plugins.android.test.get().pluginId) apply false
// Aggregates the per-module coverage into one report.
id("jacoco-aggregation")
}
allprojects {
repositories {
mavenCentral()
google()
// JitPack builds artifacts from GitHub on request. Take from it only the groups that are nowhere else, and take
// those groups from nowhere else, so a library of the same name elsewhere cannot replace them.
exclusiveContent {
forRepository { maven("https://jitpack.io") }
filter { includeGroup("com.github.kenglxn.QRGen") }
}
}
tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
freeCompilerArgs.add("-opt-in=kotlin.ExperimentalUnsignedTypes")
//freeCompilerArgs.add("-XXLanguage:+PropertyParamAnnotationDefaultTargetMode")
// -Xannotation-default-target=param-property removed: it's the default since Kotlin 2.4, so the
// flag is now redundant and the compiler warns about it on every module.
jvmTarget.set(Versions.jvmTarget)
}
}
// The build cache may replay compilation. It may not replay test results.
//
// A cached Test task does not run its tests - it restores the previous outcome and reports green.
// By Gradle's rules that is sound, same inputs give the same result, and in the log it is
// indistinguishable from a real run. This project has twice shipped tests that silently were not
// executing (JUnit 5 skipping expression-body tests; the non-app instrumented step running nothing
// for months), and both times the signal was a green build that proved nothing. For an app that
// doses insulin that is not a trade worth making for a few seconds.
//
// This disables cache *reuse* only. Up-to-date checks still skip genuinely unchanged tests on a
// local incremental build, and CI checks out fresh where nothing is up to date anyway. Compile
// tasks keep the cache, and they are where nearly all of the saving is.
tasks.withType<AbstractTestTask>().configureEach {
outputs.doNotCacheIf("tests must actually run, not be replayed from a previous build") { true }
}
gradle.projectsEvaluated {
tasks.withType<JavaCompile> {
val compilerArgs = options.compilerArgs
compilerArgs.add("-Xlint:deprecation")
compilerArgs.add("-Xlint:unchecked")
}
}
apply<JacocoPlugin>()
// Robolectric loads classes through its own sandbox classloader and rewrites their bytecode, so
// the JaCoCo agent sees classes with no source location and skips them. Without this the tests
// still run and still pass - only the coverage silently disappears, which is the worst shape for
// a problem to have.
//
// It lives here, next to the apply that gives every project the plugin, because putting it in a
// convention means a module can miss it. That already happened: `jacoco-module-dependencies` had
// it, but that convention applies `com.android.library`, which AGP 9 refuses next to the
// multiplatform plugin - so :core:graph and :plugins:calibration lost it the moment they flipped
// to KMP, and reported 0% and 33.5% for Compose screens their Robolectric tests were already
// driving. :core:ui kept a hand-copied version and was the only one unaffected. One place, every
// project, nothing to remember on the next flip.
tasks.withType<Test>().configureEach {
extensions.configure<JacocoTaskExtension> {
isIncludeNoLocationClasses = true
excludes = listOf("jdk.internal.*")
}
}
}
tasks.register<Delete>("clean") {
description = "Cleanup generated code"
}.configure {
delete(rootProject.layout.buildDirectory)
}