Android buildscript repositories: jcenter VS mavencentral
我上次使用Android Studio时,它使用
任何人都可以解释与此有关的问题。还有其他回购吗?我们什么时候应该切换它们?它们对项目,模块,库有什么影响? Android开发人员还有其他必要条件吗?
谁负责维护这些存储库?
在Bintray,我刚刚重新整理了一篇非常详细的博客文章,描述了Google进行此更改的原因。以下是最重要的几点:
- JCenter是Bintray中的Java存储库,它是Java和Android OSS库,程序包和组件的世界上最大的存储库。
- JCenter中的所有内容都通过具有安全HTTPS连接的CDN提供。在迁移时(Android Studio 0.8),中央maven 2存储库仅是HTTP,不支持HTTPS。参考:51.6.2。 Maven中央存储库。
-
jcenter() 是mavenCentral() 的超集,其中包含许多其他存储库和工件。 - 在不同的情况下和来自不同的国家/地区,Bintray比Maven Central(例如来自以色列)要快。在其他情况下,它非常接近。由于Maven Central和Bintray使用不同的CDN来自适应地偏爱区域,因此这可能会改变为两种方式。
- 与传统的Maven Central相比,Bintray具有不同的软件包识别方法。这是一个重大而严重的安全问题。这很重要。
- 如果确实需要将软件包发送到Maven Central(用于支持旧版工具),则也可以从Bintray进行处理,只需单击一个按钮,甚至自动完成。
关于性能改进,几个Android开发者拥护者已经/注意到使用maven Central进行巨大索引的问题。
用Tor Norbye的话说:
I ran AndroidStudio with a brand new settings directory, so it went and connected maven central and downloaded an index of the available artifacts.
Then I happened to look at the size of my directory.
My ~/Library/Cache/AndroidStudioPreview is 1.5G, and 1.2G of those are taken by the a€?Mavena€? subdirectory.
Thata€?s ridiculous. We barely use the index at all. The primary use for it is the Dependency editor in the Project Structure Dialog, but we really dona€?t need to have a precomputed index for it. MavenCentral has a fast online JSON search we can use on demand when somebody searches for artifacts. In https://android-review.googlesource.com/#/c/94843/ we added a lint check which checks whether the dependencies are up to date, and the search for a handful of artifacts is near instant.
In short, we really dona€?t need the cache; it may help with code completion in .gradle and maven .pom files, but thata€?s not a super important usecase, and certainly not something all users should have to sacrifice 1.5G of download speed and diskspace to have the possibility of one day doing.
Read more on: The Maven index is huge!
此外,您可能会发现关于Hacker News的简短讨论(1Q和1A)很有趣。
我在Bintray和artifactory背后的公司JFrog工作,请参阅我的个人资料以获取详细信息和链接。
我也在想同样的事情,我没有确切的答案,但认为分享(一点点)我学到的东西可能是值得的。我发现在Google Code的一期中提到了从Maven Central到JCenter的转移,但是没有找到确切的发生时间的详细信息-在Android Studio的最新更改列表中找不到提及。
通过在JCenter上阅读,它是JFrog公司(我以前见过,我猜这是\\'J \\'的来源)Bintray背后的存储库。根据Bintray博客的说法,Bintray是Maven Central的超集,因此,如果的确如此,那么应该不会缺少依赖项,但是我想这将取决于您使用的是什么。在您的项目中-您总是可以直接检查存储库,因为它们都有易于搜索的漂亮网站。因此,据我所知,对于谁维护这些存储库,取决于依赖关系的生产者将其依赖关系添加到每个存储库中,而取决于存储库所有者只是为了维护服务。
就何时切换而言,很难解决。我认为AOSP仍在使用Maven Central(从在"用于新Android应用程序的模板"中查找),但是该模板也仍在使用非常旧的Gradle版本(0.4)。关于其他人存在与jcenter的依赖项有关的问题,但并没有很多报道,而且Google可能会在发布AS final之前再次切换到其他回购协议。如果Maven Central现在仍然适合您,则可以推迟切换,直到那时为止,尤其是在构建大型商业解决方案时。
无论build.gradle文件中的默认值是什么-在基于团队的开发工作中,您都应该真正使用诸如Sonatype Nexus或JFrog Artifactory之类的存储库管理器,而不要直接引用这些上游存储库。
这将使您节省大量带宽,将两个和许多其他存储库合并在一起,并在自己的网络中进行全部管理。
关于Maven Central与JCenter。 JCenter是JFrog努力拥抱,扩展(和消除?)Maven Central的努力。 Maven Central是Maven,SBT和其他版本中的默认存储库,而Gradle已切换到JCenter。考虑到JFrog和Gradleware作为公司一起工作,这不足为奇。由于Android SDK现在使用Gradle作为构建系统,因此迁移到JCenter是下一步的逻辑。
JCenter本身是Maven Central顶部的薄单板。它代理(或多或少成功)并添加其他组件。两者都托管在CDN网络上并且性能很高。 Maven Central本身是所有Eclipse,Apache和大多数其他开源项目的目标,如果没有它,JCenter几乎将是空的。
使用它们中的任何一个都可以很好地工作,但是我建议您直接去可能的地方,并在此之上通过使用存储库管理器对其进行控制。例如,Nexus Open Source是免费的,并支持Maven,Gradle,SBT,Ivy等使用的Maven存储库,以及NuGet,NPM和RubyGems支持。
免责声明:我是Nexus的存储库管理和Sonatype的Nexus培训者的作者,免费的Central Repository的赞助商,Android Maven插件的项目负责人,并通过从AOSP进行重建将一些Android库推向Central。铅>
http://inthecheesefactory.com/blog/how-to-upload-library-to-jcenter-maven-central-as-dependency/en
本文可以回答您的问题。
At first, Android Studio chose Maven Central as a default repository. Once you create a new project from old version of Android Studio, mavenCentral() would be automatically defined in build.gradle.
But the big problem of Maven Central is it is not developer-friendly. It is surprisingly hard to upload the library to. To be able to do so, developer has to be at some level of geeky. And with some more reason for example a security concern and etc, Android Studio team decided to switch the default repository to jcenter instead as you can see that once you create a new project from latest version of Android Studio, jcenter() would be automatically defined instead of mavenCentral().