mavenCentral()、jCenter() 和 mavenLocal() 的区别? [英] Difference among mavenCentral(), jCenter() and mavenLocal()?

查看:31
本文介绍了mavenCentral()、jCenter() 和 mavenLocal() 的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

其实,我正在研究 build.gradle 文件.在某些情况下,我知道他们有时会在存储库部分使用 mavenCentral()jCenter()mavenLocal().有时他们也使用 URL.所以我的脑海里出现了一些问题?

<块引用>

i) mavenCentral()、jCenter() 和 mavenLocal() 的区别?

ii) 我最应该使用哪一个?

iii) 是否存在任何与性能相关的问题?

解决方案

其实这3个都是Maven仓库.我们将这些 maven 存储库用于我们的构建,方法是使用它的 URL 地址或它在本地文件系统中的位置.

使用网址:

存储库{maven { url("https://plugins.gradle.org/m2/") }}

使用本地文件系统:

存储库{maven { url '../maven-repo' }}

Gradle 有三个别名",我们可以在将 Maven 存储库添加到构建时使用它们.这些别名是:

  1. mavenCentral():


mavenCentral() 别名表示从

公告链接: https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/

Maven 中央链接: https://maven.apache.org/repository/index.html

解决方法:

存储库{mavenLocal()//jcenter()//<- 删除它mavenCentral()//<- 添加它maven { url https://plugins.gradle.org/m2/"}maven { url https://repo.spring.io/plugins-release/"}}

Actually, I am studying on build.gradle file. In some cases, I got that sometimes they are using mavenCentral(), jCenter() and mavenLocal() in repositories section. Sometimes they also using URL. So some question arises in my mind?

i) Difference among mavenCentral(), jCenter() and mavenLocal()?

ii) Which one should I use most?

iii) Is there any performance related issue?

解决方案

Actually, all 3 are Maven repository. We use these maven repositories to our build by using its URL address or its location in the local file system.

By using URL:

repositories {
    maven { url("https://plugins.gradle.org/m2/") }
}

By using local file system:

repositories {
    maven { url '../maven-repo' }
}

Gradle has three "aliases" which we can use when we are adding Maven repositories to our build. These aliases are:

  1. mavenCentral():


The mavenCentral() alias means that dependencies are fetched from the central Maven 2 repository.

repositories {
    mavenCentral()
}

The URL used to access this repository is https://repo.maven.apache.org/maven2/. The name of the repository is MavenRepo.

  1. jcenter():


The jcenter() alias means that dependencies are fetched from the Bintray’s JCenter Maven repository

  1. mavenLocal():


The mavenLocal() alias means that dependencies are fetched from the local Maven repository.

Resource Link:

  1. Gradle: Dependency Management

  2. Maven RepositoryHandler


Jcenter vs. mavenCentral

jcenter() and mavenCentral() is a repository for the Gradle plugin in Android Studio

Earlier versions of Android Studio used mavenCentral(), and after some time, it switched to jcenter.

This is because jcenter() is superior to mavenCentral() in terms of performance and memory footprint:

  • Jcenter is the world's largest Java repository
  • Jcenter through the CDN service, using the https protocol, highly secured, and Android Studio 0.8 version mavenCentral() using the http protocol
  • Jcenter is a superset of mavenCentral, including many additional jars
  • Jcenter performance is better than mavenCentral
  • mavenCentral will automatically download many IDE-related indexes, and these are used less often which are not required.

Resource Link: https://www.jianshu.com/p/bce437eeb3d3


Last Update: Into the Sunset on May 1st: Bintray, JCenter, GoCenter, and ChartCenter

Update: 24-02-2021 of Android Developers Page:

Announcement Link: https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/

Maven Central Link: https://maven.apache.org/repository/index.html

Work Around:

repositories {
    mavenLocal()
    
//  jcenter()       // <- remove it
    mavenCentral()  // <- add it
    
    maven { url "https://plugins.gradle.org/m2/" }
    maven { url "https://repo.spring.io/plugins-release/" }
}

这篇关于mavenCentral()、jCenter() 和 mavenLocal() 的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆