From 3b1b25068cdf074949b143184e80a9ec81fec4f8 Mon Sep 17 00:00:00 2001 From: tonihei Date: Wed, 5 Jan 2022 09:50:07 +0000 Subject: [PATCH] Add Gradle constraints to common module to enforce matching versions The common module now defines all other released targets as constraints, which ensures they must have matching versions. As all other libraries indirectly depend on the common module, this declaration is only needed in here. PiperOrigin-RevId: 419776578 --- libraries/common/build.gradle | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/libraries/common/build.gradle b/libraries/common/build.gradle index 6ca075b170..43139bffc8 100644 --- a/libraries/common/build.gradle +++ b/libraries/common/build.gradle @@ -13,6 +13,16 @@ // limitations under the License. apply from: "$gradle.ext.androidxMediaSettingsDir/common_library_config.gradle" +// Make sure this project is evaluated after all other libraries. This ensures +// the Gradle properties of each library are populated and we can automatically +// check if a 'releaseArtifactId' exists. +rootProject.allprojects.forEach { + if ((it.name.contains('lib-') || it.name.contains('test-')) + && !it.name.endsWith('-common')) { + evaluationDependsOn(modulePrefix + it.name) + } +} +// copybara:media3-only android { buildTypes { debug { @@ -22,6 +32,15 @@ android { } dependencies { + constraints { + // List all released targets as constraints. This ensures they are all + // resolved to the same version. + rootProject.allprojects.forEach { + if (it.hasProperty('releaseArtifactId')) { + implementation project(modulePrefix + it.name) + } + } + } api ('com.google.guava:guava:' + guavaVersion) { // Exclude dependencies that are only used by Guava at compile time // (but declared as runtime deps) [internal b/168188131].