Skip to content

Commit bc19009

Browse files
committed
RUM-16370: Support Android API 37
1 parent 5ad996b commit bc19009

190 files changed

Lines changed: 715 additions & 713 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: 4 additions & 1 deletion
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"
@@ -183,7 +186,6 @@ build,com.fasterxml.jackson.core,Apache-2.0,"Copyright (c) 2007- Tatu Saloranta"
183186
build,com.fasterxml.jackson.dataformat,Apache-2.,"Copyright (c) 2007- Tatu Saloranta"
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"
186-
build,com.github.tschuchortdev,MPL-2.0,"Copyright (C) 2023 Thilo Schuchort"
187189
build,com.google.android,Apache-2.0,Copyright (C) 2013 The Android Open Source Project
188190
build,com.google.api.grpc,Apache-2.0,Copyright 2020 Google LLC
189191
build,com.google.auto,Apache-2.0,"Copyright 2014 Google LLC"
@@ -208,6 +210,7 @@ build,commons-io,Apache-2.0,Copyright 2002-2024 The Apache Software Foundation
208210
build,commons-logging,Apache-2.0,Copyright 2002-2024 The Apache Software Foundation
209211
build,io.github.aakira,Apache-2.0,"Copyright (C) 2019 A.Akira"
210212
build,io.github.classgraph,MIT,"Copyright (c) 2019 Luke Hutchison"
213+
build,io.github.java-diff-utils,Apache-2.0,"Copyright java-diff-utils contributors"
211214
build,io.github.microutils,Apache-2.0,Copyright (c) 2016-2018 Ohad Shai
212215
build,io.gitlab.arturbosch.detekt,Apache-2.0,Copyright 2016-2019 the original author or authors
213216
build,io.grpc,Apache-2.0,Copyright 2014 The gRPC Authors

build.gradle.kts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66
@file:Suppress("StringLiteralDuplication")
77

8-
import com.android.build.gradle.LibraryExtension
98
import com.datadog.gradle.config.AndroidConfig
109
import com.datadog.gradle.config.depotProxied
1110
import com.datadog.gradle.config.registerSubModuleAggregationTask
@@ -29,7 +28,6 @@ plugins {
2928
// don't add these to the classpath, otherwise there will be a conflict, because they are already coming
3029
// from buildSrc classpath. May be solved with convention plugins though.
3130
// alias(libs.plugins.androidLibraryPlugin) apply false
32-
// alias(libs.plugins.kotlinAndroidPlugin) apply false
3331
// alias(libs.plugins.dokkaGradlePlugin) apply false
3432
// alias(libs.plugins.versionsGradlePlugin) apply false
3533
}
@@ -207,20 +205,14 @@ tasks.register("printSdkDebugRuntimeClasspath") {
207205
allprojects.minus(project).forEach { subproject ->
208206
val childTask = subproject.tasks.register("printDebugRuntimeClasspath") {
209207
doLast {
210-
val ext =
211-
subproject.extensions.findByType(LibraryExtension::class.java) ?: return@doLast
212-
val classpath = ext.libraryVariants
213-
.filter { it.name == "jvmDebug" || it.name == "debug" }
214-
.map { libVariant ->
215-
// returns also test part of classpath for now, no idea how to filter it out
216-
libVariant.getCompileClasspath(null).filter { it.exists() }
217-
}
218-
.first()
219-
if (classpath is FileTree) {
220-
fileTreeClassPathCollector.addToUnion(classpath)
221-
} else {
222-
nonFileTreeClassPathCollector += classpath
223-
}
208+
val config = subproject.configurations.findByName("jvmDebugCompileClasspath")
209+
?: subproject.configurations.findByName("debugCompileClasspath")
210+
?: return@doLast
211+
// Use lenient resolution: AGP 9 variant resolution can fail for local project
212+
// dependencies when kotlin.platform.type attributes are missing on providers.
213+
val classpath = config.incoming.artifactView { isLenient = true }.files
214+
.filter { it.exists() }
215+
nonFileTreeClassPathCollector += classpath
224216
}
225217
}
226218
this@register.dependsOn(childTask)

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)

ci/Dockerfile.gitlab

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ RUN set -x \
2626
&& apt-get -y clean \
2727
&& rm -rf /var/lib/apt/lists/*
2828

29-
ENV GRADLE_VERSION 9.4.0
30-
ENV ANDROID_COMPILE_SDK 36
31-
ENV ANDROID_BUILD_TOOLS 36.0.0
29+
ENV GRADLE_VERSION 9.5.1
30+
ENV ANDROID_COMPILE_SDK 37
31+
ENV ANDROID_BUILD_TOOLS 37.0.0
3232
ENV ANDROID_SDK_TOOLS 13114758
3333
ENV NDK_VERSION 28.0.13004108
3434
ENV CMAKE_VERSION 3.22.1
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
kotlin_abi_version=1.8.0
2-
jvm_bytecode_version=11
1+
kotlin_abi_version=2.1.0
2+
jvm_bytecode_version=17

dd-sdk-android-core/build.gradle.kts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ import com.datadog.gradle.config.javadocConfig
1515
import com.datadog.gradle.config.junitConfig
1616
import com.datadog.gradle.config.kotlinConfig
1717
import com.datadog.gradle.config.publishingConfig
18-
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
1918

2019
plugins {
2120
// Build
2221
id("com.android.library")
23-
kotlin("android")
2422
id("com.google.devtools.ksp")
2523

2624
// Publish
@@ -135,7 +133,8 @@ dependencies {
135133
testImplementation(testFixtures(project(":dd-sdk-android-internal")))
136134
unmock(libs.robolectric)
137135

138-
// Test Fixtures
136+
// Test Fixtures — declared explicitly because the testFixtures source set is its own variant
137+
// and does not inherit the main `implementation` classpath (nor the auto-added kotlin-stdlib).
139138
testFixturesImplementation(libs.kotlin)
140139
testFixturesImplementation(libs.bundles.jUnit5)
141140
testFixturesImplementation(libs.okHttp)
@@ -164,7 +163,7 @@ unMock {
164163
keepStartingWith("org.json")
165164
}
166165

167-
kotlinConfig(jvmBytecodeTarget = JvmTarget.JVM_11)
166+
kotlinConfig()
168167
androidLibraryConfig()
169168
junitConfig()
170169
javadocConfig()

0 commit comments

Comments
 (0)