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
This commit is contained in:
tonihei 2022-01-05 09:50:07 +00:00
parent bb81c4969d
commit 3b1b25068c

View File

@ -13,6 +13,16 @@
// limitations under the License. // limitations under the License.
apply from: "$gradle.ext.androidxMediaSettingsDir/common_library_config.gradle" 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 { android {
buildTypes { buildTypes {
debug { debug {
@ -22,6 +32,15 @@ android {
} }
dependencies { 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) { api ('com.google.guava:guava:' + guavaVersion) {
// Exclude dependencies that are only used by Guava at compile time // Exclude dependencies that are only used by Guava at compile time
// (but declared as runtime deps) [internal b/168188131]. // (but declared as runtime deps) [internal b/168188131].