项目根目录,输入命令: ./gradlew :module名称:dependencies –configuration api
或者进入module目录,输入命令: ./gradlew dependencies –configuration api
–configuration是查看具体的哪种依赖,比如api implementation compileOnly等。
在各个moudle中的build.gradle文件配置需要统一的依赖库版本号
configurations.all() {
Configuration configuration ->
configuration.resolutionStrategy.force(
[
'com.xxx:component:3.0.0.alpha',
'com.xxx:appcashier:3.0.0.alpha'
])
}
subprojects {
//修改别的字段看这个官方文档:https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.AppExtension.html
project.afterEvaluate {
project.plugins.withId('com.android.library') {
println("start change config ,libName========" + project.name)
// project.android.compileSdkVersion rootProject.ext.compileSdkVersion
// project.android.defaultConfig.minSdkVersion rootProject.ext.minSdkVersion
// project.android.defaultConfig.targetSdkVersion rootProject.ext.targetSdkVersion
// project.apply from: mavenScriptPath
}
}
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.xxx') {
println("eachDependency========" + details.requested.name)
if(details.requested.name.contains('component') ) {
details.useVersion '3.0.0.alpha'
}
if(details.requested.name.contains('appcashier') ) {
details.useVersion '3.0.0.alpha'
}
}
}
resolutionStrategy {
// force certain versions of dependencies (including transitive)
force 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:1.3.4'
// cache dynamic versions for 10 minutes
cacheDynamicVersionsFor 10*60, 'seconds'
// don't cache changing modules at all
cacheChangingModulesFor 0, 'seconds'
}
// 用源码替换maven
resolutionStrategy.dependencySubstitution {
// Substitute project and module dependencies
substitute module('com.xxx:component') with project(':component')
}
}
}