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插件

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

测试一

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:
gradle中仓库repositories 与查看项目依赖dependency,Ctrl+鼠标左键跳转gradle源码_第2张图片
命令行输出到日志:

gradlew -q :app:dependencies >log.txt

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

测试二

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

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

你可能感兴趣的:(gradle)