问题描述
实际上,我正在研究build.gradle
文件.在某些情况下,我知道有时它们在存储库部分中使用mavenCentral()
,jCenter()
和mavenLocal()
.有时他们也使用URL.所以在我的脑海中出现了一些问题吗?
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?
ii)我最应该使用哪个?
ii) Which one should I use most?
iii)是否存在与性能相关的问题?
iii) Is there any performance related issue?
推荐答案
实际上,所有3个都是Maven存储库.我们通过使用其Maven存储库的URL地址或在本地文件系统中的位置来将其用于构建.
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.
使用URL:
repositories {
maven { url("https://plugins.gradle.org/m2/") }
}
通过使用本地文件系统:
repositories {
maven { url '../maven-repo' }
}
Gradle具有三个别名" ,当我们向构建中添加Maven存储库时可以使用它们.这些别名是:
Gradle has three "aliases" which we can use when we are adding Maven repositories to our build. These aliases are:
mavenCentral()别名意味着从中央Maven 2存储库中获取依赖项.
The mavenCentral() alias means that dependencies are fetched from the central Maven 2 repository.
repositories {
mavenCentral()
}
用于访问此存储库的URL为 https://repo.maven.apache.org/maven2 /.该存储库的名称为MavenRepo.
The URL used to access this repository is https://repo.maven.apache.org/maven2/. The name of the repository is MavenRepo.
jcenter()别名表示从 Bintray的JCenter Maven存储库中获取依赖项
The jcenter() alias means that dependencies are fetched from the Bintray’s JCenter Maven repository
mavenLocal()别名意味着从本地Maven存储库中获取依赖项.
The mavenLocal() alias means that dependencies are fetched from the local Maven repository.
Jcenter vs. mavenCentral
jcenter()和mavenCentral()是Android Studio中Gradle插件的存储库
Jcenter vs. mavenCentral
jcenter() and mavenCentral() is a repository for the Gradle plugin in Android Studio
早期的Android Studio版本使用mavenCentral(),并在一段时间后切换到jcenter.
Earlier versions of Android Studio used mavenCentral(), and after some time, it switched to jcenter.
这是因为在性能和内存占用方面,jcenter()优于mavenCentral():
This is because jcenter() is superior to mavenCentral() in terms of performance and memory footprint:
- Jcenter是世界上最大的Java存储库
- 通过 https协议通过CDN服务实现Jcenter安全和使用 http的Android Studio 0.8版本mavenCentral()协议
- Jcenter是mavenCentral的超集,其中包括许多其他功能罐子
- Jcenter性能优于mavenCentral
- mavenCentral将自动下载许多与IDE相关的索引,而且不需要的次数较少.
- Jcenter is the world's largest Java repository
- Jcenter through the CDN service, using the https protocol, highlysecured, and Android Studio 0.8 version mavenCentral() using the httpprotocol
- Jcenter is a superset of mavenCentral, including many additionaljars
- Jcenter performance is better than mavenCentral
- mavenCentral will automatically download many IDE-related indexes,and these are used less often which are not required.
资源链接: https://www.jianshu.com/p/bce437eeb3d3
这篇关于mavenCentral(),jCenter()和mavenLocal()之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!