Gradle:让依赖项的版本依赖于可传递依赖项的版本

Gradle:让依赖项的版本依赖于可传递依赖项的版本,gradle,versioning,dependency-management,transitive-dependency,Gradle,Versioning,Dependency Management,Transitive Dependency,我们假设有一个库libraryA,可以选择与各种“插件”、助手或集成库libraryA-plugin1、libraryA-adapter2等一起使用。但是,它们必须与匹配版本一起使用,即如果x.y.z版本中使用了libraryA,则可选库必须在同一版本中使用 让我们进一步假设,有另一个库libraryB,它依赖于libraryA,我想在我自己的项目中使用它。因此,libraryA只是我的项目的一个可传递依赖项。如何在正确的版本中将依赖项添加到库a-plugin1 问题:我如何告诉Gradle使用

我们假设有一个库
libraryA
,可以选择与各种“插件”、助手或集成库
libraryA-plugin1
libraryA-adapter2
等一起使用。但是,它们必须与匹配版本一起使用,即如果
x.y.z
版本中使用了
libraryA
,则可选库必须在同一版本中使用

让我们进一步假设,有另一个库
libraryB
,它依赖于
libraryA
,我想在我自己的项目中使用它。因此,
libraryA
只是我的项目的一个可传递依赖项。如何在正确的版本中将依赖项添加到
库a-plugin1

问题:我如何告诉Gradle使用与作为传递依赖项拉入的
libraryA
版本相匹配的
libraryA-plugin1
版本

具体例子

我的Android项目使用
com.squareup.reformation2:reformation:2.9.0
,这取决于
com.squareup.okhttp3:okhttp:3.14.9
。此外,我使用
com.squareup.okhttp3:logging interceptor
作为OkHttp的插件。目前,我的依赖项文件看起来是这样的

implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
// We must use version 3.14.9, because Retrofit 2.9.0 depends on OkHttp 3.14.9 and we must
// pull in the same version
implementation("com.squareup.okhttp3:logging-interceptor:3.14.9")