修改 Gradle 插件(Plugins)的下载地址(repositories)

栏目: 编程工具 · 发布时间: 6年前

内容简介:Gradle 也可以用下面的方式声明使用的插件:其实是从 Gradle 官方的插件仓库但是,众所周知的原因,某些地区会连不上,导致下载不到需要的插件,例如出现如下错误:

Gradle 也可以用下面的方式声明使用的插件:

// build.gradle
plugins {
    id 'com.example.plugin', version '1.0'
}

其实是从 Gradle 官方的插件仓库 https://plugins.gradle.org/m2/ 下载的。

但是,众所周知的原因,某些地区会连不上,导致下载不到需要的插件,例如出现如下错误:

* What went wrong:
A problem occurred configuring root project 'MyApp'.
> Could not resolve all files for configuration ':classpath'.
   > Could not download jimfs.jar (com.google.jimfs:jimfs:1.1)
      > Could not get resource 'https://plugins.gradle.org/m2/com/google/jimfs/jimfs/1.1/jimfs-1.1.jar'.
         > Could not HEAD 'https://plugins.gradle.org/m2/com/google/jimfs/jimfs/1.1/jimfs-1.1.jar'.
            > Connect to d29vzk4ow07wi7.cloudfront.net:443 [d29vzk4ow07wi7.cloudfront.net/54.192.84.6, d29vzk4ow07wi7.cloudfront.net/54.192.84.168, d29vzk4ow07wi7.cloudfront.net/54.192.84.128, d29vzk4ow07wi7.cloudfront.net/54.192.84.173] failed: Read timed out

又或者,插件是不对外的,存在某个私有仓库的,该如何修改或者添加额外的私有仓库地址呢?

直接修改 settings.gradle 来添加其它仓库:

// settings.gradle
pluginManagement {
    repositories {
        maven {
            url 'http://examle.com/maven-repo'
        }
        gradlePluginPortal()
    }
}

当然你也可以使用老的方式应用插件:

buildscript {
    repositories {
        maven {
            url 'http://examle.com/maven-repo'
        }
    }
    dependencies {
        classpath 'com.example.plugin:gradle-plugin:1.0'
    }
}

apply plugin: 'com.example.plugin'

references:


以上所述就是小编给大家介绍的《修改 Gradle 插件(Plugins)的下载地址(repositories)》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Bandit Algorithms for Website Optimization

Bandit Algorithms for Website Optimization

John Myles White / O'Reilly Media / 2013-1-3 / USD 19.99

This book shows you how to run experiments on your website using A/B testing - and then takes you a huge step further by introducing you to bandit algorithms for website optimization. Author John Myle......一起来看看 《Bandit Algorithms for Website Optimization》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具