gradle中仓库repositories 与查看项目依赖dependency,Ctrl+鼠标左键跳转gradle源码

查看gradle源码(Ctrl+鼠标左键可跳转)

一、先将all改成bin

distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip

改为:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-bin.zip

二、打开一个build.gradle文件,
Android stuido 会提示
You can configure Gradle wrapper to use distribution with sources.
It will provide IDE with Gradle API/DSL documentation.

三、选择是apply即可。

gradle中仓库:

    repositories {
        google()
        maven { url "https://dl.google.com/dl/android/maven2/" }
        //
        maven { url 'https://maven.google.com' }

        
        jcenter()
        maven { url "https://jcenter.bintray.com/" }

        
        mavenCentral()
        maven { url "https://repo.maven.apache.org/maven2/" }
        //
        maven { url "https://repo1.maven.org/maven2/" }
        maven { url "http://maven.aliyun.com/nexus/content/groups/public/" }
        
        
        maven { url "https://jitpack.io" }

        
        mavenLocal()
    }

一、命令行直接查看gradle依赖:

注意:如果是 Linux / Mac 以下命令请直接用 ./ 前缀。

//命令格式: 
//gradlew 	模块名:dependencies

gradlew 	:app:dependencies 

gradlew -q  :app:dependencies

//只看compile相关的依赖
gradlew -q  :app:dependencies --configuration compile

//只看implementation相关的依赖
gradlew -q  :app:dependencies --configuration implementation

//将结果输出到当前目录下的log.txt文件
gradlew -q  :app:dependencies >log.txt

看结果其中:

//依赖项被忽略(前面列出)
(*) - dependencies omitted (listed previously)
//意味着前边已经有了,这里就不再使用(有可能冲突)


//配置未使用,不考虑
(n) - Not resolved (configuration is not meant to be resolved)

二、命令行利用网页查看gradle依赖:

gradlew build --scan
BUILD SUCCESSFUL in 4m 21s
56 actionable tasks: 56 executed

Publishing a build scan to scans.gradle.com requires 
accepting the Gradle Terms of Service defined at 
https://gradle.com/terms-of-service. 
Do you accept these terms? [yes, no]
yes	//输入yes

Gradle Terms of Service accepted.

Publishing build scan...
https://gradle.com/xxxxxxx

打开链接会发送邮件查看扫描结果即可。

三、gradle view插件

在这里插入图片描述

测试一

retrofit2、okhttp3-integration中都含有OKHTTP的依赖,

implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.0.0'
implementation group: 'com.squareup.retrofit2', name: 'retrofit', version: '2.6.0'
implementation "com.github.bumptech.glide:okhttp3-integration:4.8.0"

gradle view的hierarchy:
在这里插入图片描述
命令行输出到日志:

gradlew -q :app:dependencies >log.txt

在这里插入图片描述

测试二

implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.0.0'
implementation(group: 'com.squareup.retrofit2', name: 'retrofit', version: '2.6.0') {
    exclude group: "com.squareup.okhttp3"
}
implementation("com.github.bumptech.glide:okhttp3-integration:4.8.0") {
    exclude group: "com.squareup.okhttp3"
}

命令行输出到日志:

gradlew -q :app:dependencies >log.txt

在这里插入图片描述

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值