From 9a795712843aa8907a3087fc6003e000960db5ad Mon Sep 17 00:00:00 2001 From: ibaker Date: Tue, 23 May 2023 17:55:48 +0100 Subject: [PATCH] Ensure `rootProject.name` is only set from `settings.gradle` I moved this assignment in https://github.com/androidx/media/commit/0888dfbd05e1f22436137d93a67e56d06b8928cc in order to provide a single source-of-truth for `publish.gradle`, but as pointed out in Issue: androidx/media#416 this breaks apps that are depending on our project locally using the instructions we publish. Instead we can remove the `rootProject.name` check from `publish.gradle`, and check an explicit boolean value instead to indicate if the root project is 'ours' (with this boolean only set from `settings.gradle`, so it doesn't get picked up by apps depending on us locally). #minor-release PiperOrigin-RevId: 534459085 --- core_settings.gradle | 2 -- publish.gradle | 2 +- settings.gradle | 3 ++- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/core_settings.gradle b/core_settings.gradle index e2935c9110..15b52a5189 100644 --- a/core_settings.gradle +++ b/core_settings.gradle @@ -21,8 +21,6 @@ if (gradle.ext.has('androidxMediaModulePrefix')) { modulePrefix += gradle.ext.androidxMediaModulePrefix } -rootProject.name = gradle.ext.androidxMediaProjectName - include modulePrefix + 'lib-common' project(modulePrefix + 'lib-common').projectDir = new File(rootDir, 'libraries/common') diff --git a/publish.gradle b/publish.gradle index bd59d32492..57662bb85c 100644 --- a/publish.gradle +++ b/publish.gradle @@ -16,7 +16,7 @@ apply plugin: 'maven-publish' apply from: "$gradle.ext.androidxMediaSettingsDir/missing_aar_type_workaround.gradle" afterEvaluate { - if (rootProject.name == gradle.ext.androidxMediaProjectName) { + if (gradle.ext.has('rootProjectIsAndroidXMedia3') && gradle.ext.rootProjectIsAndroidXMedia3) { publishing { repositories { maven { diff --git a/settings.gradle b/settings.gradle index 9feebe7fce..f1b3347913 100644 --- a/settings.gradle +++ b/settings.gradle @@ -18,7 +18,8 @@ if (gradle.ext.has('androidxMediaModulePrefix')) { modulePrefix += gradle.ext.androidxMediaModulePrefix } -gradle.ext.androidxMediaProjectName = 'androidx.media3' +rootProject.name = 'androidx.media3' +gradle.ext.rootProjectIsAndroidXMedia3 = true include modulePrefix + 'demo' project(modulePrefix + 'demo').projectDir = new File(rootDir, 'demos/main')