Skip to content
Merged
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
21 changes: 0 additions & 21 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,6 @@ plugins {
alias(libs.plugins.ktlintGradlePlugin)
}

buildscript {
repositories {
// Magic Mirror Depot proxy (only set in CI via `.gitlab-ci.yml`).
listOf("gradlePluginProxy", "mavenRepositoryProxy")
.mapNotNull { providers.gradleProperty(it).orNull?.takeIf { url -> url.isNotBlank() } }
.forEach { url -> maven { setUrl(url) } }
mavenCentral()
}
}

repositories {
// Magic Mirror Depot proxy (only set in CI via `.gitlab-ci.yml`).
listOf("gradlePluginProxy", "mavenRepositoryProxy")
.mapNotNull { providers.gradleProperty(it).orNull?.takeIf { url -> url.isNotBlank() } }
.forEach { url -> maven { setUrl(url) } }
mavenCentral()
google()
gradlePluginPortal()
maven { setUrl("https://jitpack.io") }
}

dependencies {

// Plugins whose types are only referenced when configuring a consuming project. They are
Expand Down
32 changes: 23 additions & 9 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@
* Copyright 2016-Present Datadog, Inc.
*/

import com.datadog.gradle.repositories.DatadogRepositories

pluginManagement {
repositories {
// Magic Mirror Depot proxy (only set in CI via `.gitlab-ci.yml`).
listOf("gradlePluginProxy", "mavenRepositoryProxy")
.mapNotNull { providers.gradleProperty(it).orNull?.takeIf { url -> url.isNotBlank() } }
.forEach { url -> maven(url) }
gradlePluginPortal()
google()
mavenCentral()
}
includeBuild("../gradle/settings-plugin")
}

plugins {
id("com.datadog.gradle.repositories")
}

val datadogRepositories = DatadogRepositories(providers)

pluginManagement.repositories {
datadogRepositories.gradlePluginPortalDepotProxied(this)
datadogRepositories.mavenCentralDepotProxied(this)
datadogRepositories.googleConstrained(this)
}

dependencyResolutionManagement {
Expand All @@ -22,4 +28,12 @@ dependencyResolutionManagement {
from(files("../gradle/libs.versions.toml"))
}
}
@Suppress("UnstableApiUsage")
repositories {
repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS
datadogRepositories.mavenCentralDepotProxied(this)
datadogRepositories.gradlePluginPortalDepotProxied(this)
datadogRepositories.googleConstrained(this)
datadogRepositories.jitpackConstrained(this)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,4 @@ object GradlePropertiesKeys {

// you can set this property from your gradle.properties as: forceEnableLogcat = true | false
const val FORCE_ENABLE_LOGCAT = "forceEnableLogcat"

/**
* Maven repository proxy URL (Magic Mirror Depot). When set, prepended to dependency
* repositories so artifact resolution goes through Datadog's internal mirror instead of
* hitting public registries (e.g. Maven Central) directly. Used in CI to avoid 429s.
* Set via -PmavenRepositoryProxy=... or in gradle.properties.
*/
const val MAVEN_REPOSITORY_PROXY = "mavenRepositoryProxy"

/**
* Gradle plugin portal proxy URL (Magic Mirror Depot). When set, prepended to plugin
* resolution repositories so plugin resolution goes through Datadog's internal mirror
* instead of hitting plugins.gradle.org directly. Used in CI to avoid 429s.
* Set via -PgradlePluginProxy=... or in gradle.properties.
*/
const val GRADLE_PLUGIN_PROXY = "gradlePluginProxy"
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ class AarMetadataPlugin : Plugin<Project> {

target.tasks
.register<CheckAarMetadataInfoTask>(TASK_CHECK_AAR_METADATA) {
this.aarMetadataFile.set(aarMetadataFile)
dependsOn(generateAarMetadataTask)
this.aarMetadataFile.set(generateAarMetadataTask.flatMap { it.aarMetadataFile })
}

target.extensions.configure<LibraryAndroidComponentsExtension>("androidComponents") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ class ApiSurfacePlugin : Plugin<Project> {

target.tasks
.register<CheckCompilerMetaTask>(TASK_CHECK_COMPILER_METADATA) {
this.metadataInfoFile.set(compilerMetaFile)
dependsOn(TASK_GEN_COMPILER_METADATA)
this.metadataInfoFile.set(generateCompilerMetaTask.flatMap { it.metadataInfoFile })
}

target.taskConfig<KotlinCompilationTask<KotlinJvmCompilerOptions>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
class TransitiveDependenciesPlugin : Plugin<Project> {

override fun apply(target: Project) {
target.tasks.register<GenerateTransitiveDependenciesTask>(TASK_GEN_TRANSITIVE_DEPS) {
dependenciesFile.set(target.layout.projectDirectory.file(FILE_NAME))
resolvedArtifacts.from(
target.configurations.named("releaseCompileClasspath").map {
it.incoming.artifactView {
componentFilter { it !is ProjectComponentIdentifier }
}.files
}
)
}
val generateTransitiveDependenciesTask = target.tasks
.register<GenerateTransitiveDependenciesTask>(TASK_GEN_TRANSITIVE_DEPS) {
dependenciesFile.set(target.layout.projectDirectory.file(FILE_NAME))
resolvedArtifacts.from(
target.configurations.named("releaseCompileClasspath").map {
it.incoming.artifactView {
componentFilter { it !is ProjectComponentIdentifier }
}.files
}
)
}

target.tasks.register<CheckTransitiveDependenciesTask>(TASK_CHECK_TRANSITIVE_DEPS) {
dependenciesFile.set(target.layout.projectDirectory.file(FILE_NAME))
dependsOn(TASK_GEN_TRANSITIVE_DEPS)
dependenciesFile.set(generateTransitiveDependenciesTask.flatMap { it.dependenciesFile })
}

target.taskConfig<KotlinCompilationTask<KotlinJvmCompilerOptions>> {
Expand Down
28 changes: 1 addition & 27 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
@file:Suppress("StringLiteralDuplication")

import com.datadog.gradle.config.AndroidConfig
import com.datadog.gradle.config.depotProxied
import com.datadog.gradle.config.registerSubModuleAggregationTask
import com.datadog.gradle.utils.CLONE_RUM_EVENTS_FORMAT_SCHEMAS_TASK_NAME
import com.datadog.gradle.utils.GENERATE_JSON_MODELS_TASK_NAME
Expand All @@ -29,36 +28,11 @@ plugins {
alias(libs.plugins.kotlinAndroidPlugin) apply false
alias(libs.plugins.dokkaGradlePlugin) apply false
alias(libs.plugins.detektGradlePlugin) apply false
alias(libs.plugins.unmockGradlePlugin) apply false
}

version = AndroidConfig.VERSION.name

buildscript {
repositories {
// Magic Mirror Depot proxy (only set in CI via `.gitlab-ci.yml`).
// Inlined here because `buildscript {}` is resolved before the `build-logic`
// convention plugins are on the classpath.
listOf("gradlePluginProxy", "mavenRepositoryProxy")
.mapNotNull { providers.gradleProperty(it).orNull?.takeIf { url -> url.isNotBlank() } }
.forEach { url -> maven { setUrl(url) } }
google()
mavenCentral()
gradlePluginPortal()
}

dependencies {
classpath(libs.unmockGradlePlugin)
}
}

allprojects {
repositories.depotProxied(providers) {
google()
mavenCentral()
maven { setUrl("https://jitpack.io") }
}
}

nexusPublishing {
this.repositories {
sonatype {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ dependencies {

implementation(platform(libs.androidXComposeBom))
implementation(libs.bundles.androidXCompose)
implementation(libs.androidXComposeMaterial)

testImplementation(project(":tools:unit")) {
attributes {
Expand Down
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ cmake = "3.22.1"
ndk = "28.0.13004108"

# Commons
apollo = "4.3.3"
cronetApi = "143.7445.0"
cronetPlayServices = "18.1.1"
gson = "2.10.1"
# We have 2 different versions of Kotlin: one is for the buildscript classpath - Gradle Plugin,
# Buildscript runtime dependency; another is for the SDK compile/runtime classpath.
Expand Down Expand Up @@ -108,6 +105,9 @@ kotlinxSerializationCore = "1.8.1"
lifecycleViewmodelNav3 = "1.0.0-alpha01"
openFeature = "0.6.2"
retrofit = "2.11.0"
apollo = "4.3.3"
cronetApi = "143.7445.0"
cronetPlayServices = "18.1.1"

# Local Server
ktor = "2.3.13"
Expand All @@ -128,7 +128,6 @@ apolloRuntime = { module = "com.apollographql.apollo:apollo-runtime", version.re
kotlinGradlePluginApi = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin-api", version.ref = "kotlinBuildscript" }
dokkaGradlePlugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" }
detektGradlePlugin = { module = "dev.detekt:detekt-gradle-plugin", version.ref = "detekt" }
unmockGradlePlugin = { module = "com.github.bjoernq:unmockplugin", version.ref = "unmock" }

# Annotation processors
glideKsp = { module = "com.github.bumptech.glide:ksp", version.ref = "glide" }
Expand Down Expand Up @@ -407,3 +406,4 @@ kotlinxSerializationPlugin = { id = "org.jetbrains.kotlin.plugin.serialization",
koverPlugin = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
ktlintGradlePlugin = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlintGradlePlugin" }
detektGradlePlugin = { id = "dev.detekt", version.ref = "detekt" }
unmockGradlePlugin = { id = "de.mobilej.unmock", version.ref = "unmock" }
18 changes: 18 additions & 0 deletions gradle/settings-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2016-Present Datadog, Inc.
*/

plugins {
`java-gradle-plugin`
}

gradlePlugin {
plugins {
create("repositories") {
id = "com.datadog.gradle.repositories"
implementationClass = "com.datadog.gradle.repositories.RepositoriesPlugin"
}
}
}
9 changes: 9 additions & 0 deletions gradle/settings-plugin/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2016-Present Datadog, Inc.
*/

// Only uses core Gradle plugins, so this build resolves nothing from remote repositories and can
// hold the repository definitions shared by the root build and build-logic.
rootProject.name = "settings-plugin"
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2016-Present Datadog, Inc.
*/

package com.datadog.gradle.repositories;

import org.gradle.api.artifacts.dsl.RepositoryHandler;
import org.gradle.api.provider.ProviderFactory;

/**
* Repository definitions shared by the settings scripts.
* <p>
* When the Magic Mirror Depot proxy properties are set (only in CI, via `.gitlab-ci.yml`), the
* proxy replaces Maven Central and the Gradle Plugin Portal.
*/
public final class DatadogRepositories {

/**
* Maven repository proxy URL (Magic Mirror Depot). When set, prepended to dependency
* repositories so artifact resolution goes through Datadog's internal mirror instead of
* hitting public registries (e.g. Maven Central) directly. Used in CI to avoid 429s.
* Set via -PmavenRepositoryProxy=... or in gradle.properties.
*/
private static final String MAVEN_REPOSITORY_PROXY = "mavenRepositoryProxy";

/**
* Gradle plugin portal proxy URL (Magic Mirror Depot). When set, prepended to plugin
* resolution repositories so plugin resolution goes through Datadog's internal mirror
* instead of hitting plugins.gradle.org directly. Used in CI to avoid 429s.
* Set via -PgradlePluginProxy=... or in gradle.properties.
*/
private static final String GRADLE_PLUGIN_PROXY = "gradlePluginProxy";

private static final String GOOGLE_GROUPS_REGEX = ".*(google|android|chromium).*";
private static final String JITPACK_URL = "https://jitpack.io";
private static final String JITPACK_GROUPS_REGEX = "^com\\.github\\..*";

private final String mavenProxy;
private final String gradlePluginProxy;

public DatadogRepositories(ProviderFactory providers) {
this.mavenProxy = readProxy(providers, MAVEN_REPOSITORY_PROXY);
this.gradlePluginProxy = readProxy(providers, GRADLE_PLUGIN_PROXY);
}

public void mavenCentralDepotProxied(RepositoryHandler repositories) {
if (mavenProxy != null) {
repositories.maven(repository -> {
repository.setName("Maven Datadog Depot");
repository.setUrl(mavenProxy);
});
} else {
repositories.mavenCentral();
}
}

public void gradlePluginPortalDepotProxied(RepositoryHandler repositories) {
if (gradlePluginProxy != null) {
repositories.maven(repository -> {
repository.setName("Gradle Plugin Datadog Depot");
repository.setUrl(gradlePluginProxy);
});
}
// Gradle Plugins repo is not cached by Depot but there are _some_ artifacts there.
// So try to hit Depot first, and if not found use fallback, unlike in case of Maven Central.
repositories.gradlePluginPortal();
}

public void googleConstrained(RepositoryHandler repositories) {
repositories.google(repository ->
repository.mavenContent(content -> content.includeGroupByRegex(GOOGLE_GROUPS_REGEX))
);
}

public void jitpackConstrained(RepositoryHandler repositories) {
repositories.maven(repository -> {
repository.setUrl(JITPACK_URL);
repository.mavenContent(content -> content.includeGroupByRegex(JITPACK_GROUPS_REGEX));
});
}

private static String readProxy(ProviderFactory providers, String propertyName) {
String value = providers.gradleProperty(propertyName).getOrNull();
return value == null || value.isBlank() ? null : value;
}
}
Loading
Loading