Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ variables:

CACHE_FALLBACK_KEY: "develop"

# Unify the Gradle user home across ALL jobs so every Gradle invocation shares one
# GitLab-cacheable location ($CI_PROJECT_DIR/cache) instead of some jobs using the default,
# non-cached /root/.gradle. Jobs that pass --gradle-user-home cache/ already match this.
GRADLE_USER_HOME: "$CI_PROJECT_DIR/cache"

# Magic Mirror Depot proxy URLs. The depot proxies both Maven Central and the Gradle
# Plugin Portal for the Java ecosystem from the same endpoint. Setting these routes
# dependency/plugin resolution through Datadog's internal mirror to avoid HTTP 429
Expand Down
9 changes: 7 additions & 2 deletions LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ import,androidx.versionedparcelable,Apache-2.0,Copyright 2018 The Android Open S
import,androidx.viewpager,Apache-2.0,Copyright 2018 The Android Open Source Project
import,androidx.wear,Apache-2.0,Copyright 2018 The Android Open Source Project
import,androidx.work,Apache-2.0,Copyright 2018 The Android Open Source Project
import,app.cash.sql-psi,Apache-2.0,"Copyright 2016 Square, Inc"
import,app.cash.sqldelight,Apache-2.0,"Copyright 2016 Square, Inc"
import,com.android.tools,Apache-2.0,Copyright 2018 The Android Open Source Project
import,com.apollographql.apollo,MIT,"Copyright (c) 2016-2024 Apollo Graph, Inc. (Formerly Meteor Development Group, Inc.)"
import,com.benasher44,MIT,"Copyright (c) 2019 Ben Asher"
Expand Down Expand Up @@ -140,6 +142,7 @@ import(test),com.jakewharton.android.repackaged,Apache-2.0,"Copyright (C) 2007 T
import(test),com.parse.bolts,"BSD License","Copyright (c) Facebook, Inc. and its affiliates."
import(test),com.squareup,Apache-2.0,"Copyright 2015 Square, Inc."
import(test),dev.drewhamilton.poko,Apache-2.0,Copyright 2020-Present Drew Hamilton
import(test),dev.zacsweers.kctfork,MPL-2.0,Copyright (C) 2022 Zac Sweers
import(test),greatest,ICT,"Copyright (c) 2011-2018 Scott Vokes <vokes.s@gmail.com>"
import(test),io.github.davidburstrom.contester,Apache-2.0,"Copyright 2022-2024 David Burström"
import(test),io.github.detekt.sarif4k,Apache-2.0,"Copyright 2021 Artur Bosch & Contributors"
Expand Down Expand Up @@ -184,7 +187,7 @@ build,com.fasterxml.jackson.dataformat,Apache-2.,"Copyright (c) 2007- Tatu Salor
build,com.fasterxml.jackson.module,Apache-2.0,"Copyright (c) 2007- Tatu Saloranta"
build,com.fasterxml.woodstox,Apache-2.0,"Copyright (c) 2007- Tatu Saloranta"
build,com.github.ajalt.clikt,Apache-2.0,"Copyright clikt authors"
build,com.github.tschuchortdev,MPL-2.0,"Copyright (C) 2023 Thilo Schuchort"
build,com.github.ben-manes.caffeine,Apache-2.0,"Copyright 2014 Ben Manes"
build,com.google.android,Apache-2.0,Copyright (C) 2013 The Android Open Source Project
build,com.google.api.grpc,Apache-2.0,Copyright 2020 Google LLC
build,com.google.auto,Apache-2.0,"Copyright 2014 Google LLC"
Expand All @@ -208,11 +211,12 @@ build,commons-cli,Apache-2.0,Copyright 2002-2024 The Apache Software Foundation
build,commons-codec,Apache-2.0,Copyright 2002-2024 The Apache Software Foundation
build,commons-io,Apache-2.0,Copyright 2002-2024 The Apache Software Foundation
build,commons-logging,Apache-2.0,Copyright 2002-2024 The Apache Software Foundation
build,dev.detekt,Apache-2.0,Copyright 2016-2019 the original author or authors
build,io.github.aakira,Apache-2.0,"Copyright (C) 2019 A.Akira"
build,io.github.classgraph,MIT,"Copyright (c) 2019 Luke Hutchison"
build,io.github.java-diff-utils,Apache-2.0,"Copyright java-diff-utils contributors"
build,io.github.microutils,Apache-2.0,Copyright (c) 2016-2018 Ohad Shai
build,io.github.oshai,Apache-2.0,"Copyright oshai authors"
build,io.gitlab.arturbosch.detekt,Apache-2.0,Copyright 2016-2019 the original author or authors
build,io.grpc,Apache-2.0,Copyright 2014 The gRPC Authors
build,io.netty,Apache-2.0,Copyright 2014 The Netty Project
build,io.opencensus,Apache-2.0,"Copyright 2017, OpenCensus Authors"
Expand Down Expand Up @@ -240,6 +244,7 @@ build,org.glassfish.jaxb,"Eclipse Distribution License - v 1.0","Copyright (c) 2
build,org.jcommander,Apache-2.0,"Copyright (C) 2010 the original author or authors"
build,org.jetbrains.dokka,Apache-2.0,"Copyright 2014-2019 JetBrains s.r.o. and Dokka project contributors."
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"
build,org.jetbrains.intellij.deps.kotlinx,Apache-2.0,Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors
build,org.jlleitschuh.gradle,MIT,"Copyright (c) 2023 Jonathan Leitschuh"
build,org.jvnet.staxex,"Eclipse Distribution License - v 1.0","Copyright (c) 1997-2015 Oracle and/or its affiliates"
build,org.ow2.asm,BSD-3-Clause,"Copyright (c) 2000-2011 INRIA, France Telecom"
Expand Down
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ plugins {
// don't add these to the classpath, otherwise there will be a conflict, because they are already coming
// from buildSrc classpath. May be solved with convention plugins though.
// alias(libs.plugins.androidLibraryPlugin) apply false
// alias(libs.plugins.kotlinAndroidPlugin) apply false
// alias(libs.plugins.dokkaGradlePlugin) apply false
// alias(libs.plugins.versionsGradlePlugin) apply false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,23 @@ package com.datadog.gradle.config

import com.android.build.api.dsl.CompileOptions
import com.android.build.api.dsl.LibraryExtension
import com.android.build.api.variant.HostTestBuilder
import com.android.build.api.variant.LibraryAndroidComponentsExtension
import com.android.build.api.variant.LibraryVariantBuilder
import com.datadog.gradle.utils.Version
import org.gradle.api.JavaVersion
import org.gradle.api.Project

object AndroidConfig {

const val TARGET_SDK = 36
const val TARGET_SDK = 37
const val MIN_SDK = 23
const val MIN_SDK_FOR_AUTO = 29
const val BUILD_TOOLS_VERSION = "36.0.0"
const val BUILD_TOOLS_VERSION = "37.0.0"

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

// TODO RUM-628 Switch to Java 17 bytecode
fun CompileOptions.java11() {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

fun CompileOptions.java17() {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
Expand All @@ -43,17 +40,16 @@ fun Project.androidLibraryConfig() {
}

compileOptions {
java11()
java17()
}

sourceSets.all {
java.srcDir("src/$name/kotlin")
java.directories.add("src/$name/kotlin")
}
sourceSets.named("main") {
java.srcDir("build/generated/json2kotlin/main/kotlin")
kotlin.directories.add("build/generated/json2kotlin/main/kotlin")
}

@Suppress("UnstableApiUsage")
testOptions {
unitTests.isReturnDefaultValues = true
}
Expand Down Expand Up @@ -86,4 +82,9 @@ fun Project.androidLibraryConfig() {
}
}
}
extensionConfig<LibraryAndroidComponentsExtension> {
beforeVariants { variant: LibraryVariantBuilder ->
variant.hostTests[HostTestBuilder.UNIT_TEST_TYPE]?.enable = true
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fun Project.junitConfig() {
"--add-opens=java.base/java.util.concurrent=ALL-UNNAMED"
)
useJUnitPlatform {
includeEngines("spek", "junit-jupiter", "junit-vintage")
includeEngines("junit-jupiter", "junit-vintage")
}
reports {
junitXml.required.set(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ fun Project.kotlinConfig(
jvmTarget.set(jvmBytecodeTarget)
val isCI = System.getenv("CI").toBoolean()
allWarningsAsErrors.set(evaluateWarningsAsErrors && isCI)
apiVersion.set(KotlinVersion.KOTLIN_1_8)
languageVersion.set(KotlinVersion.KOTLIN_1_8)
apiVersion.set(KotlinVersion.KOTLIN_2_1)
languageVersion.set(KotlinVersion.KOTLIN_2_1)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ApiSurfacePlugin : Plugin<Project> {
this.kotlinSurfaceFile.set(generateApiSurfaceTask.flatMap { it.surfaceFile })
if (target.plugins.hasPlugin(GEN_JAVA_API_LAYOUT_PLUGIN)) {
this.javaSurfaceFile.set(javaSurfaceFile)
dependsOn(TASK_GEN_JAVA_API_SURFACE)
dependsOn(target.tasks.matching { it.name == TASK_GEN_JAVA_API_SURFACE })
} else {
logger.info(
"No Java API layout plugin found, skipping API surface" +
Expand Down Expand Up @@ -72,15 +72,16 @@ class ApiSurfacePlugin : Plugin<Project> {
// Java API generation task does a clean-up of all files in the output
// folder, so let it run first
if (target.plugins.hasPlugin(GEN_JAVA_API_LAYOUT_PLUGIN)) {
val apiDumpTasks = target.tasks.matching { it.name == TASK_GEN_JAVA_API_SURFACE }
val isCi = target.providers.environmentVariable("CI").isPresent
if (isCi) {
// Java API generation wires to the release build type, so we can afford triggering compilation
// of release type locally when we run debug compilation, but we would like to avoid it on CI
if (name == "compileReleaseKotlin") {
finalizedBy(TASK_GEN_JAVA_API_SURFACE)
finalizedBy(apiDumpTasks)
}
} else {
finalizedBy(TASK_GEN_JAVA_API_SURFACE)
finalizedBy(apiDumpTasks)
}
}
finalizedBy(generateApiSurfaceTask)
Expand Down
36 changes: 10 additions & 26 deletions buildSrc/src/main/kotlin/detekt-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import com.android.build.api.variant.LibraryAndroidComponentsExtension
import io.gitlab.arturbosch.detekt.Detekt
import dev.detekt.gradle.Detekt

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

plugins {
id("io.gitlab.arturbosch.detekt")
id("dev.detekt")
}

dependencies {
Expand All @@ -24,44 +23,29 @@ val detektConfigFiles = listOf(

detekt {
config.setFrom(detektConfigFiles)
ignoredVariants = listOf("release")
ignoredVariants.set(listOf("release"))
}

tasks.withType<Detekt>().configureEach {
jvmTarget = "17"
reports {
sarif.required = false
html.required = false
xml.required = false
txt.required = false
md.required = false
checkstyle.required = false
markdown.required = false
}
}

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

dependsOn(
tasks.named("detektMain"),
tasks.named("detektTest")
)
}

// testFixtures is an Android source set and isn't picked up by the detekt/AGP on AGP 8, this should
// be able to be deleted in AGP 9 and covered by `detektTest`
extensions.getByType<LibraryAndroidComponentsExtension>().onVariants { variant ->
if (variant.name == "debug") {
variant.testFixtures?.let { testFixtures ->
val detektTestFixtures = tasks.register<Detekt>("detektTestFixtures") {
source(layout.projectDirectory.dir("src/testFixtures/kotlin"))
config.setFrom(detektConfigFiles)
classpath.setFrom(testFixtures.compileClasspath)
}
tasks.detekt {
dependsOn(detektTestFixtures)
}
}
}
}
33 changes: 27 additions & 6 deletions buildSrc/src/main/kotlin/test-pyramid-api-surface.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@
*/

import com.android.build.api.variant.LibraryAndroidComponentsExtension
import io.gitlab.arturbosch.detekt.Detekt
import dev.detekt.gradle.Detekt
import dev.detekt.gradle.extensions.FailOnSeverity
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.api.attributes.Usage
import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.named
import org.gradle.kotlin.dsl.the

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

// This plugin deliberately does not apply `dev.detekt`, so the conventions the plugin would put
// on every Detekt task are not applied either. These mirror `setDetektTaskDefaults` in the Detekt
// plugin and must be kept in sync with it: without them Gradle fails task validation because the
// properties have no value. Only the ones this task does not set explicitly are listed.
debug = false
parallel = false
autoCorrect = false
ignoreFailures = false
failOnSeverity = FailOnSeverity.Error
allRules = false
noJdk = false
multiPlatformEnabled = false
basePath = rootProject.projectDir.absolutePath

reports {
// outputLocation has to be set even for a disabled report, otherwise Gradle task validation
// fails on it; the Detekt plugin normally supplies these conventions. Nothing is written.
val unusedReports = layout.buildDirectory.dir("reports/detekt-test-pyramid/unused")
sarif.required = false
sarif.outputLocation = unusedReports.map { it.file("report.sarif") }
html.required = false
xml.required = false
txt.required = false
md.required = false
html.outputLocation = unusedReports.map { it.file("report.html") }
checkstyle.required = false
checkstyle.outputLocation = unusedReports.map { it.file("report.xml") }
markdown.required = false
markdown.outputLocation = unusedReports.map { it.file("report.md") }
}

// Internal working state regenerated every run, not a published output - LocalState, not @OutputFile.
Expand Down
33 changes: 27 additions & 6 deletions buildSrc/src/main/kotlin/test-pyramid-api-usage.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import com.android.build.api.variant.ApplicationAndroidComponentsExtension
import com.android.build.api.variant.HasUnitTest
import com.android.build.api.variant.LibraryAndroidComponentsExtension
import com.android.build.api.variant.Variant
import io.gitlab.arturbosch.detekt.Detekt
import dev.detekt.gradle.Detekt
import dev.detekt.gradle.extensions.FailOnSeverity
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.api.attributes.Usage
import org.gradle.api.file.RegularFile
Expand All @@ -17,12 +18,12 @@ import org.gradle.kotlin.dsl.findByType
import org.gradle.kotlin.dsl.named
import org.gradle.kotlin.dsl.the

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

// This plugin deliberately does not apply `dev.detekt`, so the conventions the plugin would put
// on every Detekt task are not applied either. These mirror `setDetektTaskDefaults` in the Detekt
// plugin and must be kept in sync with it: without them Gradle fails task validation because the
// properties have no value. Only the ones this task does not set explicitly are listed.
debug = false
parallel = false
autoCorrect = false
ignoreFailures = false
failOnSeverity = FailOnSeverity.Error
allRules = false
noJdk = false
multiPlatformEnabled = false
basePath = rootProject.projectDir.absolutePath

reports {
// outputLocation has to be set even for a disabled report, otherwise Gradle task validation
// fails on it; the Detekt plugin normally supplies these conventions. Nothing is written.
val unusedReports = layout.buildDirectory.dir("reports/detekt-test-pyramid/unused")
sarif.required = false
sarif.outputLocation = unusedReports.map { it.file("report.sarif") }
html.required = false
xml.required = false
txt.required = false
md.required = false
html.outputLocation = unusedReports.map { it.file("report.html") }
checkstyle.required = false
checkstyle.outputLocation = unusedReports.map { it.file("report.xml") }
markdown.required = false
markdown.outputLocation = unusedReports.map { it.file("report.md") }
}

localState.register(generatedConfigFile)
Expand Down
6 changes: 3 additions & 3 deletions ci/Dockerfile.gitlab
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ RUN set -x \
&& apt-get -y clean \
&& rm -rf /var/lib/apt/lists/*

ENV GRADLE_VERSION 9.4.0
ENV ANDROID_COMPILE_SDK 36
ENV ANDROID_BUILD_TOOLS 36.0.0
ENV GRADLE_VERSION 9.5.1
ENV ANDROID_COMPILE_SDK 37
ENV ANDROID_BUILD_TOOLS 37.0.0
ENV ANDROID_SDK_TOOLS 13114758
ENV NDK_VERSION 28.0.13004108
ENV CMAKE_VERSION 3.22.1
Expand Down
4 changes: 2 additions & 2 deletions dd-sdk-android-core/api/compiler-meta.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
kotlin_abi_version=1.8.0
jvm_bytecode_version=11
kotlin_abi_version=2.1.0
jvm_bytecode_version=17
Loading
Loading