Gradle之依赖配置

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u014780554/article/details/72898095

关于依赖包后缀@aar和@jar的区别

com.android.support:appcompat-v7:25.3.1

1、当不指定@后缀时:会下载库中的默认格式(由它的作者定义,如果没有则默认jar)及其所有依赖一起。

2、当指定@后缀时:会下载库中的指定格式(可能存在或可能不存在),如果依赖库不存在则不会下载,所以你必须手动确认。例如当笔者忘了指定该库是aar和jar时,Maven会默认将其作为jar格式。


关于依赖传递性和排除依赖

例如以下项目依赖

+— org.springframework:spring-web:4.3.4.RELEASE
| | +— org.springframework:spring-aop:4.3.4.RELEASE
| | +— org.springframework:spring-beans:4.3.4.RELEASE
| | +— org.springframework:spring-context:4.3.4.RELEASE
| | — org.springframework:spring-core:4.3.4.RELEASE

该代码表示依赖所有

compile("org.springframework:spring-web:4.3.4.RELEASE") {
    transitive = true
}

下面的语句,可以全局性的关闭依赖传递特性。

configurations.all {
   transitive = false
}

猜你喜欢

转载自blog.csdn.net/u014780554/article/details/72898095