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

1
2
3
4
// build.gradle
plugins {
id 'com.example.plugin', version '1.0'
}

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

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

1
2
3
4
5
6
7
* 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

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

直接修改根目录(root project)的settings.gradle来添加其它仓库:

1
2
3
4
5
6
7
8
9
// settings.gradle
pluginManagement {
repositories {
maven {
url 'http://examle.com/maven-repo'
}
gradlePluginPortal()
}
}

比如使用阿里云提供的镜像

1
2
3
maven {
url 'https://maven.aliyun.com/repository/gradle-plugin'
}

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

1
2
3
4
5
6
7
8
9
10
11
12
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)的更多相关文章

  1. Jenkins插件、war下载地址

    1.jenkins的war包下载地址 地址:http://mirrors.jenkins-ci.org/,打开链接后,表格有war列,Releases行是短期更新包.LTS是长期更新包.一般选择Rel ...

  2. m2e插件的新下载地址

    今天在按照<Maven实战>这本书给eclipse配置maven的m2eclipse插件的时候发现,书中写的老的下载地址http://m2eclipse.sonatype.org/site ...

  3. Gradle插件详解

    参考[1]Gradle 插件       [2]修改 Gradle 插件(Plugins)的下载地址(repositories)

  4. Android Studio中由于gradle插件版本和gradle版本对应关系导致的编译失败的问题

    今天在Android Studio中导入新项目,import之后编译报错,报错信息基本都是和版本相关,查询gradle版本相关知识,了解到gradle插件版本和gradle版本有相应的匹配关系,对应如 ...

  5. 构建工具-----Gradle(二)-----myeclipse 10和myeclipse2015安装gradle插件----其他版本的myeclipse类似

    我们需要给myeclipse安装gradle的插件.这样myeclipse就能识别到gradle项目了,直接加载进去即可. 我们先安装配置系统命令行的gradle,挺简单的,下载后配置环境变量即可,详 ...

  6. 【Android 应用开发】Android 开发环境下载地址 -- 百度网盘 adt-bundle android-studio sdk adt 下载

    19af543b068bdb7f27787c2bc69aba7f Additional Download (32-, 64-bit) Package r10 STL debug info androi ...

  7. Intellij:用Intellij出的Gradle插件进行开发

    前言:之前看到网上大部分的Intellij开发教程都是采用Intellij官方文档的那个版本,配置Intellij SDK一大堆的. 现在给大家介绍简单的方法吧,我们组内大神找到的.我们需要用到的是I ...

  8. MyEclpse 2015在线安装Gradle插件图解

    MyEclpse 2015 安装Gradle插件 安装方式:在线安装 一.如何获得Gradle插件在线安装地址 Gradle插件最新在线安装地址可在如下网址中查找: https://github.co ...

  9. gradle: 修改gradle-xx-bin.zip下载地址

    进入gradle/wrapper/目录,修改gradle-wrapper.properties文件, 将distributionUrl修改为自己的下载地址即可. 另外修改gradle reposito ...

随机推荐

  1. eclipse javaEE版下载过程中选择镜像(Select Another Mirror)无反应解决办法,附带eclipse javaEE版下载教程。

    1.eclipse javaEE版下载过程中选择镜像(Select Another Mirror)无反应 (复制该网址下载即可 https://mirrors.neusoft.edu.cn/eclip ...

  2. Win10自动备份oracle数据库

    1.环境 操作系统:win10 数据库: 2.创建backup.bat文件 [ @echo offset name=%date:~0,4%%date:~5,2%%date:~8,2%set backu ...

  3. vue2-admin-mpa vue2多页面应用系统【开源项目】

    1. 项目介绍 一个基于Vue2.0的多页面应用系统. 技术栈包含:Vue.VueX.Vue Router.Element UI. 2. 功能介绍 2.1 多页面切换功能 说明:采用 tabs  +  ...

  4. Linux&C 线程控制 课后习题

    Q1:多线程与多进程相比有什么优势? 多进程程序耗费的资源大,因为fork()的时候子进程需要继承父进程的几乎所有东西,但是多线程程序线程只继承一部分,即自己的私有数据,例如自己的线程ID,一组寄存器 ...

  5. Linux配置2个Tomcat同时运行

    先说一下怎么遇到的这个问题,在练习linux中部署web项目时,linux系统安装了两个tomcat. 操作步骤: 1.配置profile#vi /etc/profile 输入以下内容: 这是两个to ...

  6. JMeter学习笔记--JDBC测试计划-连接Mysql

    1.首先要下载jar包,mysql-connector-java-5.1.7-bin.jar 放到Jmeter的lib文件下ext下 2.添加JDBC Connection Configuration ...

  7. Could not set property 'id' of 'class com.xxx.xxEntity'

    使用mybatisplus的save功能时,系统报错如下: Could not set property 'id' of 'class com.xxx.xxEntity' with value '13 ...

  8. newInstance方法

    1.new 是java中的关键字,是创建一个新对象的关键字.用new这个关键字的话,是调用new指令创建一个对象,然后调用构造方法来初始化这个对象,如果反编译class的话,会看到一个Object o ...

  9. Part 23 to 26 Routing in Angular

    Part 23 AngularJS routing tutorial In general, as the application becomes complex you will have more ...

  10. Python介绍和安装

    python介绍和安装 目录 python介绍和安装 1. Python简介 2. 解释器 2.1 Python解释器的种类 2.2 Python解释器版本 3. Windows下安装Python 3 ...