Skip to content

Commit 670bf2d

Browse files
committed
RUM-16370: Support Android API 37
1 parent f1be7ec commit 670bf2d

272 files changed

Lines changed: 1736 additions & 1847 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitlab-ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ variables:
2020

2121
CACHE_FALLBACK_KEY: "develop"
2222

23+
# Unify the Gradle user home across ALL jobs so every Gradle invocation shares one
24+
# GitLab-cacheable location ($CI_PROJECT_DIR/cache) instead of some jobs using the default,
25+
# non-cached /root/.gradle. Jobs that pass --gradle-user-home cache/ already match this.
26+
GRADLE_USER_HOME: "$CI_PROJECT_DIR/cache"
27+
2328
# Magic Mirror Depot proxy URLs. The depot proxies both Maven Central and the Gradle
2429
# Plugin Portal for the Java ecosystem from the same endpoint. Setting these routes
2530
# dependency/plugin resolution through Datadog's internal mirror to avoid HTTP 429

LICENSE-3rdparty.csv

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ import,androidx.versionedparcelable,Apache-2.0,Copyright 2018 The Android Open S
5252
import,androidx.viewpager,Apache-2.0,Copyright 2018 The Android Open Source Project
5353
import,androidx.wear,Apache-2.0,Copyright 2018 The Android Open Source Project
5454
import,androidx.work,Apache-2.0,Copyright 2018 The Android Open Source Project
55+
import,app.cash.sql-psi,Apache-2.0,"Copyright 2016 Square, Inc"
56+
import,app.cash.sqldelight,Apache-2.0,"Copyright 2016 Square, Inc"
5557
import,com.android.tools,Apache-2.0,Copyright 2018 The Android Open Source Project
5658
import,com.apollographql.apollo,MIT,"Copyright (c) 2016-2024 Apollo Graph, Inc. (Formerly Meteor Development Group, Inc.)"
5759
import,com.benasher44,MIT,"Copyright (c) 2019 Ben Asher"
@@ -140,6 +142,7 @@ import(test),com.jakewharton.android.repackaged,Apache-2.0,"Copyright (C) 2007 T
140142
import(test),com.parse.bolts,"BSD License","Copyright (c) Facebook, Inc. and its affiliates."
141143
import(test),com.squareup,Apache-2.0,"Copyright 2015 Square, Inc."
142144
import(test),dev.drewhamilton.poko,Apache-2.0,Copyright 2020-Present Drew Hamilton
145+
import(test),dev.zacsweers.kctfork,MPL-2.0,Copyright (C) 2022 Zac Sweers
143146
import(test),greatest,ICT,"Copyright (c) 2011-2018 Scott Vokes <vokes.s@gmail.com>"
144147
import(test),io.github.davidburstrom.contester,Apache-2.0,"Copyright 2022-2024 David Burström"
145148
import(test),io.github.detekt.sarif4k,Apache-2.0,"Copyright 2021 Artur Bosch & Contributors"
@@ -184,7 +187,7 @@ build,com.fasterxml.jackson.dataformat,Apache-2.,"Copyright (c) 2007- Tatu Salor
184187
build,com.fasterxml.jackson.module,Apache-2.0,"Copyright (c) 2007- Tatu Saloranta"
185188
build,com.fasterxml.woodstox,Apache-2.0,"Copyright (c) 2007- Tatu Saloranta"
186189
build,com.github.ajalt.clikt,Apache-2.0,"Copyright clikt authors"
187-
build,com.github.tschuchortdev,MPL-2.0,"Copyright (C) 2023 Thilo Schuchort"
190+
build,com.github.ben-manes.caffeine,Apache-2.0,"Copyright 2014 Ben Manes"
188191
build,com.google.android,Apache-2.0,Copyright (C) 2013 The Android Open Source Project
189192
build,com.google.api.grpc,Apache-2.0,Copyright 2020 Google LLC
190193
build,com.google.auto,Apache-2.0,"Copyright 2014 Google LLC"
@@ -208,11 +211,12 @@ build,commons-cli,Apache-2.0,Copyright 2002-2024 The Apache Software Foundation
208211
build,commons-codec,Apache-2.0,Copyright 2002-2024 The Apache Software Foundation
209212
build,commons-io,Apache-2.0,Copyright 2002-2024 The Apache Software Foundation
210213
build,commons-logging,Apache-2.0,Copyright 2002-2024 The Apache Software Foundation
214+
build,dev.detekt,Apache-2.0,Copyright 2016-2019 the original author or authors
211215
build,io.github.aakira,Apache-2.0,"Copyright (C) 2019 A.Akira"
212216
build,io.github.classgraph,MIT,"Copyright (c) 2019 Luke Hutchison"
217+
build,io.github.java-diff-utils,Apache-2.0,"Copyright java-diff-utils contributors"
213218
build,io.github.microutils,Apache-2.0,Copyright (c) 2016-2018 Ohad Shai
214219
build,io.github.oshai,Apache-2.0,"Copyright oshai authors"
215-
build,io.gitlab.arturbosch.detekt,Apache-2.0,Copyright 2016-2019 the original author or authors
216220
build,io.grpc,Apache-2.0,Copyright 2014 The gRPC Authors
217221
build,io.netty,Apache-2.0,Copyright 2014 The Netty Project
218222
build,io.opencensus,Apache-2.0,"Copyright 2017, OpenCensus Authors"
@@ -240,6 +244,7 @@ build,org.glassfish.jaxb,"Eclipse Distribution License - v 1.0","Copyright (c) 2
240244
build,org.jcommander,Apache-2.0,"Copyright (C) 2010 the original author or authors"
241245
build,org.jetbrains.dokka,Apache-2.0,"Copyright 2014-2019 JetBrains s.r.o. and Dokka project contributors."
242246
build,org.jetbrains.intellij.deps,LGPL-2.1-only,"Copyright (c) 2001-2002, Eric D. Friedman, Jason Baldridge, Copyright (c) 1999 CERN - European Organization for Nuclear Research"
247+
build,org.jetbrains.intellij.deps.kotlinx,Apache-2.0,Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors
243248
build,org.jlleitschuh.gradle,MIT,"Copyright (c) 2023 Jonathan Leitschuh"
244249
build,org.jvnet.staxex,"Eclipse Distribution License - v 1.0","Copyright (c) 1997-2015 Oracle and/or its affiliates"
245250
build,org.ow2.asm,BSD-3-Clause,"Copyright (c) 2000-2011 INRIA, France Telecom"

build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ plugins {
2727
// don't add these to the classpath, otherwise there will be a conflict, because they are already coming
2828
// from buildSrc classpath. May be solved with convention plugins though.
2929
// alias(libs.plugins.androidLibraryPlugin) apply false
30-
// alias(libs.plugins.kotlinAndroidPlugin) apply false
3130
// alias(libs.plugins.dokkaGradlePlugin) apply false
3231
// alias(libs.plugins.versionsGradlePlugin) apply false
3332
}

buildSrc/src/main/kotlin/com/datadog/gradle/config/AndroidConfig.kt

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,23 @@ package com.datadog.gradle.config
88

99
import com.android.build.api.dsl.CompileOptions
1010
import com.android.build.api.dsl.LibraryExtension
11+
import com.android.build.api.variant.HostTestBuilder
12+
import com.android.build.api.variant.LibraryAndroidComponentsExtension
13+
import com.android.build.api.variant.LibraryVariantBuilder
1114
import com.datadog.gradle.utils.Version
1215
import org.gradle.api.JavaVersion
1316
import org.gradle.api.Project
1417

1518
object AndroidConfig {
1619

17-
const val TARGET_SDK = 36
20+
const val TARGET_SDK = 37
1821
const val MIN_SDK = 23
1922
const val MIN_SDK_FOR_AUTO = 29
20-
const val BUILD_TOOLS_VERSION = "36.0.0"
23+
const val BUILD_TOOLS_VERSION = "37.0.0"
2124

2225
val VERSION = Version(3, 13, 0, Version.Type.Snapshot)
2326
}
2427

25-
// TODO RUM-628 Switch to Java 17 bytecode
26-
fun CompileOptions.java11() {
27-
sourceCompatibility = JavaVersion.VERSION_11
28-
targetCompatibility = JavaVersion.VERSION_11
29-
}
30-
3128
fun CompileOptions.java17() {
3229
sourceCompatibility = JavaVersion.VERSION_17
3330
targetCompatibility = JavaVersion.VERSION_17
@@ -43,17 +40,16 @@ fun Project.androidLibraryConfig() {
4340
}
4441

4542
compileOptions {
46-
java11()
43+
java17()
4744
}
4845

4946
sourceSets.all {
50-
java.srcDir("src/$name/kotlin")
47+
java.directories.add("src/$name/kotlin")
5148
}
5249
sourceSets.named("main") {
53-
java.srcDir("build/generated/json2kotlin/main/kotlin")
50+
kotlin.directories.add("build/generated/json2kotlin/main/kotlin")
5451
}
5552

56-
@Suppress("UnstableApiUsage")
5753
testOptions {
5854
unitTests.isReturnDefaultValues = true
5955
}
@@ -86,4 +82,9 @@ fun Project.androidLibraryConfig() {
8682
}
8783
}
8884
}
85+
extensionConfig<LibraryAndroidComponentsExtension> {
86+
beforeVariants { variant: LibraryVariantBuilder ->
87+
variant.hostTests[HostTestBuilder.UNIT_TEST_TYPE]?.enable = true
88+
}
89+
}
8990
}

buildSrc/src/main/kotlin/com/datadog/gradle/config/JUnitConfig.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fun Project.junitConfig() {
2222
"--add-opens=java.base/java.util.concurrent=ALL-UNNAMED"
2323
)
2424
useJUnitPlatform {
25-
includeEngines("spek", "junit-jupiter", "junit-vintage")
25+
includeEngines("junit-jupiter", "junit-vintage")
2626
}
2727
reports {
2828
junitXml.required.set(true)

buildSrc/src/main/kotlin/com/datadog/gradle/config/KotlinConfig.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ fun Project.kotlinConfig(
2121
jvmTarget.set(jvmBytecodeTarget)
2222
val isCI = System.getenv("CI").toBoolean()
2323
allWarningsAsErrors.set(evaluateWarningsAsErrors && isCI)
24-
apiVersion.set(KotlinVersion.KOTLIN_1_8)
25-
languageVersion.set(KotlinVersion.KOTLIN_1_8)
24+
apiVersion.set(KotlinVersion.KOTLIN_2_1)
25+
languageVersion.set(KotlinVersion.KOTLIN_2_1)
2626
}
2727
}
2828
}

buildSrc/src/main/kotlin/com/datadog/gradle/plugin/apisurface/ApiSurfacePlugin.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ApiSurfacePlugin : Plugin<Project> {
4040
this.kotlinSurfaceFile.set(generateApiSurfaceTask.flatMap { it.surfaceFile })
4141
if (target.plugins.hasPlugin(GEN_JAVA_API_LAYOUT_PLUGIN)) {
4242
this.javaSurfaceFile.set(javaSurfaceFile)
43-
dependsOn(TASK_GEN_JAVA_API_SURFACE)
43+
dependsOn(target.tasks.matching { it.name == TASK_GEN_JAVA_API_SURFACE })
4444
} else {
4545
logger.info(
4646
"No Java API layout plugin found, skipping API surface" +
@@ -72,15 +72,16 @@ class ApiSurfacePlugin : Plugin<Project> {
7272
// Java API generation task does a clean-up of all files in the output
7373
// folder, so let it run first
7474
if (target.plugins.hasPlugin(GEN_JAVA_API_LAYOUT_PLUGIN)) {
75+
val apiDumpTasks = target.tasks.matching { it.name == TASK_GEN_JAVA_API_SURFACE }
7576
val isCi = target.providers.environmentVariable("CI").isPresent
7677
if (isCi) {
7778
// Java API generation wires to the release build type, so we can afford triggering compilation
7879
// of release type locally when we run debug compilation, but we would like to avoid it on CI
7980
if (name == "compileReleaseKotlin") {
80-
finalizedBy(TASK_GEN_JAVA_API_SURFACE)
81+
finalizedBy(apiDumpTasks)
8182
}
8283
} else {
83-
finalizedBy(TASK_GEN_JAVA_API_SURFACE)
84+
finalizedBy(apiDumpTasks)
8485
}
8586
}
8687
finalizedBy(generateApiSurfaceTask)
Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import com.android.build.api.variant.LibraryAndroidComponentsExtension
2-
import io.gitlab.arturbosch.detekt.Detekt
1+
import dev.detekt.gradle.Detekt
32

43
/*
54
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
@@ -8,7 +7,7 @@ import io.gitlab.arturbosch.detekt.Detekt
87
*/
98

109
plugins {
11-
id("io.gitlab.arturbosch.detekt")
10+
id("dev.detekt")
1211
}
1312

1413
dependencies {
@@ -24,44 +23,29 @@ val detektConfigFiles = listOf(
2423

2524
detekt {
2625
config.setFrom(detektConfigFiles)
27-
ignoredVariants = listOf("release")
26+
ignoredVariants.set(listOf("release"))
2827
}
2928

3029
tasks.withType<Detekt>().configureEach {
3130
jvmTarget = "17"
3231
reports {
3332
sarif.required = false
3433
html.required = false
35-
xml.required = false
36-
txt.required = false
37-
md.required = false
34+
checkstyle.required = false
35+
markdown.required = false
3836
}
3937
}
4038

4139
// Disable the default task named "detekt" since it does not run type resolution
42-
// Use it purely as a nicely named umbrella task
43-
tasks.detekt {
40+
// Use it purely as a nicely named umbrella task.
41+
// `detektMain`/`detektTest` are the per-variant aggregate tasks registered by the Detekt Android
42+
// integration; they carry the compile classpath, so they do run type resolution. Their nested
43+
// components (unit tests, android tests, test fixtures) are covered by `detektTest`.
44+
tasks.named<Detekt>("detekt") {
4445
isEnabled = false
4546

4647
dependsOn(
4748
tasks.named("detektMain"),
4849
tasks.named("detektTest")
4950
)
5051
}
51-
52-
// testFixtures is an Android source set and isn't picked up by the detekt/AGP on AGP 8, this should
53-
// be able to be deleted in AGP 9 and covered by `detektTest`
54-
extensions.getByType<LibraryAndroidComponentsExtension>().onVariants { variant ->
55-
if (variant.name == "debug") {
56-
variant.testFixtures?.let { testFixtures ->
57-
val detektTestFixtures = tasks.register<Detekt>("detektTestFixtures") {
58-
source(layout.projectDirectory.dir("src/testFixtures/kotlin"))
59-
config.setFrom(detektConfigFiles)
60-
classpath.setFrom(testFixtures.compileClasspath)
61-
}
62-
tasks.detekt {
63-
dependsOn(detektTestFixtures)
64-
}
65-
}
66-
}
67-
}

buildSrc/src/main/kotlin/test-pyramid-api-surface.gradle.kts

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@
55
*/
66

77
import com.android.build.api.variant.LibraryAndroidComponentsExtension
8-
import io.gitlab.arturbosch.detekt.Detekt
8+
import dev.detekt.gradle.Detekt
9+
import dev.detekt.gradle.extensions.FailOnSeverity
910
import org.gradle.api.artifacts.VersionCatalogsExtension
1011
import org.gradle.api.attributes.Usage
1112
import org.gradle.kotlin.dsl.getByType
1213
import org.gradle.kotlin.dsl.named
1314
import org.gradle.kotlin.dsl.the
1415

15-
// Applying `io.gitlab.arturbosch.detekt` would also register its own detekt tasks and apply detekt.yml
16+
// Applying `dev.detekt` would also register its own detekt tasks and apply detekt.yml
1617
// - unwanted, since this plugin isn't linting, only using Detekt as an engine. All our own task actually needs
1718
// from the plugin is the engine classpath, so provide that directly via detached configurations instead of applying it.
1819
val detektVersion = the<VersionCatalogsExtension>().named("libs").findVersion("detekt").get().requiredVersion
1920
val detektEngineClasspath = configurations.detachedConfiguration(
20-
dependencies.create("io.gitlab.arturbosch.detekt:detekt-cli:$detektVersion")
21+
dependencies.create("dev.detekt:detekt-cli:$detektVersion")
2122
)
2223
val detektPluginClasspath = configurations.detachedConfiguration(
2324
dependencies.create(project(":tools:detekt"))
@@ -55,12 +56,32 @@ androidComponents.onVariants(androidComponents.selector().withBuildType("debug")
5556
// Only `datadog-test-pyramid` matters here - skip Detekt's bundled default rule sets.
5657
disableDefaultRuleSets = true
5758

59+
// This plugin deliberately does not apply `dev.detekt`, so the conventions the plugin would put
60+
// on every Detekt task are not applied either. These mirror `setDetektTaskDefaults` in the Detekt
61+
// plugin and must be kept in sync with it: without them Gradle fails task validation because the
62+
// properties have no value. Only the ones this task does not set explicitly are listed.
63+
debug = false
64+
parallel = false
65+
autoCorrect = false
66+
ignoreFailures = false
67+
failOnSeverity = FailOnSeverity.Error
68+
allRules = false
69+
noJdk = false
70+
multiPlatformEnabled = false
71+
basePath = rootProject.projectDir.absolutePath
72+
5873
reports {
74+
// outputLocation has to be set even for a disabled report, otherwise Gradle task validation
75+
// fails on it; the Detekt plugin normally supplies these conventions. Nothing is written.
76+
val unusedReports = layout.buildDirectory.dir("reports/detekt-test-pyramid/unused")
5977
sarif.required = false
78+
sarif.outputLocation = unusedReports.map { it.file("report.sarif") }
6079
html.required = false
61-
xml.required = false
62-
txt.required = false
63-
md.required = false
80+
html.outputLocation = unusedReports.map { it.file("report.html") }
81+
checkstyle.required = false
82+
checkstyle.outputLocation = unusedReports.map { it.file("report.xml") }
83+
markdown.required = false
84+
markdown.outputLocation = unusedReports.map { it.file("report.md") }
6485
}
6586

6687
// Internal working state regenerated every run, not a published output - LocalState, not @OutputFile.

buildSrc/src/main/kotlin/test-pyramid-api-usage.gradle.kts

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import com.android.build.api.variant.ApplicationAndroidComponentsExtension
88
import com.android.build.api.variant.HasUnitTest
99
import com.android.build.api.variant.LibraryAndroidComponentsExtension
1010
import com.android.build.api.variant.Variant
11-
import io.gitlab.arturbosch.detekt.Detekt
11+
import dev.detekt.gradle.Detekt
12+
import dev.detekt.gradle.extensions.FailOnSeverity
1213
import org.gradle.api.artifacts.VersionCatalogsExtension
1314
import org.gradle.api.attributes.Usage
1415
import org.gradle.api.file.RegularFile
@@ -17,12 +18,12 @@ import org.gradle.kotlin.dsl.findByType
1718
import org.gradle.kotlin.dsl.named
1819
import org.gradle.kotlin.dsl.the
1920

20-
// Applying `io.gitlab.arturbosch.detekt` would also register its own detekt tasks and apply detekt.yml
21+
// Applying `dev.detekt` would also register its own detekt tasks and apply detekt.yml
2122
// - unwanted, since this plugin isn't linting, only using Detekt as an engine. All our own task actually needs
2223
// from the plugin is the engine classpath, so provide that directly via detached configurations instead of applying it.
2324
val detektVersion = the<VersionCatalogsExtension>().named("libs").findVersion("detekt").get().requiredVersion
2425
val detektEngineClasspath = configurations.detachedConfiguration(
25-
dependencies.create("io.gitlab.arturbosch.detekt:detekt-cli:$detektVersion")
26+
dependencies.create("dev.detekt:detekt-cli:$detektVersion")
2627
)
2728
val detektPluginClasspath = configurations.detachedConfiguration(
2829
dependencies.create(project(":tools:detekt"))
@@ -49,12 +50,32 @@ fun configureApiUsageVariant(variant: Variant, bootClasspath: Provider<List<Regu
4950
// Only `datadog-test-pyramid` matters here - skip Detekt's bundled default rule sets.
5051
disableDefaultRuleSets = true
5152

53+
// This plugin deliberately does not apply `dev.detekt`, so the conventions the plugin would put
54+
// on every Detekt task are not applied either. These mirror `setDetektTaskDefaults` in the Detekt
55+
// plugin and must be kept in sync with it: without them Gradle fails task validation because the
56+
// properties have no value. Only the ones this task does not set explicitly are listed.
57+
debug = false
58+
parallel = false
59+
autoCorrect = false
60+
ignoreFailures = false
61+
failOnSeverity = FailOnSeverity.Error
62+
allRules = false
63+
noJdk = false
64+
multiPlatformEnabled = false
65+
basePath = rootProject.projectDir.absolutePath
66+
5267
reports {
68+
// outputLocation has to be set even for a disabled report, otherwise Gradle task validation
69+
// fails on it; the Detekt plugin normally supplies these conventions. Nothing is written.
70+
val unusedReports = layout.buildDirectory.dir("reports/detekt-test-pyramid/unused")
5371
sarif.required = false
72+
sarif.outputLocation = unusedReports.map { it.file("report.sarif") }
5473
html.required = false
55-
xml.required = false
56-
txt.required = false
57-
md.required = false
74+
html.outputLocation = unusedReports.map { it.file("report.html") }
75+
checkstyle.required = false
76+
checkstyle.outputLocation = unusedReports.map { it.file("report.xml") }
77+
markdown.required = false
78+
markdown.outputLocation = unusedReports.map { it.file("report.md") }
5879
}
5980

6081
localState.register(generatedConfigFile)

0 commit comments

Comments
 (0)