Android buildscript 存储库:jcenter VS mavencentral

我上次使用 Android Studio 时,它使用 mavencentral() buildscript 存储库生成 .gradle 文件,而现在有 jcenter().

The last time I used Android Studio, it generated .gradle files with mavencentral() buildscript repositories whereas now there's jcenter().

谁能解释与此相关的问题.还有其他回购吗?我们什么时候应该切换它们?它们对项目、模块、库有什么影响?Android 开发人员还有其他必需品吗?

Could anyone explain the issues connected with this. Are there any other repos? When should we switch them? What impact do they have on projects, modules, libs? Any other essentials for Android developers?

谁负责维护这些存储库?

Who's responsible for maintaining those repos?

推荐答案

在 Bintray 我刚刚转发了 一篇非常详细的博文,描述了谷歌做出这一改变的原因.以下是最重要的几点:

At Bintray I just rebloged a very detailed blog post describing the reasons why Google made this change. Here are the most important points:

  • JCenter 是一个 Bintray 中的 Java 存储库,这是世界上最大的 Java 和 Android OSS 库、包和组件的存储库.
  • JCenter 中的所有内容都通过 CDN 提供,并具有安全的 HTTPS 连接.回到迁移时(Android Studio 0.8)中央 maven 2 存储库仅支持 HTTP,不支持 HTTPS.参考:51.6.2.Maven 中央存储库.
  • jcenter()mavenCentral() 的超集,包含许多额外的存储库和工件.
  • 在不同的场景和不同的国家,Bintray 比 Maven Central 更快(例如来自以色列).在其他情况下,它非常接近.由于 Maven Central 和 Bintray 使用自适应偏爱区域的不同 CDN,这可能会同时改变.
  • Bintray 的包识别方法与传统的 Maven Central 不同.这是一个重大而严重的安全问题.这很重要.
  • 如果你真的需要将你的包放到 Maven Central(用于支持遗留工具),你也可以从 Bintray 中完成,点击按钮甚至自动.
  • JCenter is a Java repository in Bintray, which is the largest repo in the world for Java and Android OSS libraries, packages and components.
  • All the content in JCenter is served over a CDN, with a secure HTTPS connection. Back in the time of the migration (Android Studio 0.8) The central maven 2 repository was HTTP only and HTTPS wasn't supported. Reference: 51.6.2. Maven central repository.
  • jcenter() is a superset of mavenCentral(), that encompasses many additional repositories and artifacts.
  • In different scenarios and from different countries Bintray is faster than Maven Central (e.g. from Israel). In others it is very close. Since Maven Central and Bintray use different CDNs which adaptively favor regions, this might change to both ways.
  • Bintray has a different approach to package identification than the legacy Maven Central. This is a big and serious security matter. It is important.
  • If you really need to get your package to Maven Central (for supporting legacy tools) you can do it from Bintray as well, in a click of a button or even automatically.

关于性能改进,一些 android 开发者倡导者已经面临/注意到使用 maven Central 的巨大索引问题.

Regarding performance improvements, couple of android developer advocates had faced/noticed the issue of huge indexing with maven central.

用 托诺拜:

我使用全新的设置目录运行 AndroidStudio,因此它连接了 maven Central 并下载了可用工件的索引.

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.

我的 ~/Library/Cache/AndroidStudioPreview 是 1.5G,其中 1.2G 被Maven"子目录占用.

My ~/Library/Cache/AndroidStudioPreview is 1.5G, and 1.2G of those are taken by the "Maven" subdirectory.

这太荒谬了.我们几乎不使用索引.它的主要用途是项目结构对话框中的依赖关系编辑器,但我们真的不需要为它预先计算索引.MavenCentral 有一个快速的在线 JSON 搜索,我们可以在有人搜索工件时按需使用.在 https://android-review.googlesource.com/#/c/94843/ 我们添加了一个 lint 检查来检查依赖项是否是最新的,并且对少数工件的搜索是几乎瞬间.

That’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 don’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.

简而言之,我们真的不需要缓存;它可能有助于 .gradle 和 maven .pom 文件中的代码完成,但这不是一个超级重要的用例,当然也不是所有用户都应该牺牲 1.5G 的下载速度和磁盘空间来获得一天的可能性.阅读更多:Maven 索引巨大!

In short, we really don’t need the cache; it may help with code completion in .gradle and maven .pom files, but that’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!

另外,您可能会发现这个 关于黑客新闻的简短讨论(1Q 和 1A) 很有趣.

Also, you might find this very short (1Q and 1A) discussion on Hacker News interesting.

我在 JFrog,这是 bintray 和 artifactory,有关详细信息,请参阅 我的个人资料链接.

I am with JFrog, the company behind bintray and artifactory, see my profile for details and links.

相关文章