为什么 Apache Commons 库的 groupId 不一致,具体取决于项目? [英] Why do Apache Commons libraries have inconsistent groupIds, depending on the project?

查看:27
本文介绍了为什么 Apache Commons 库的 groupId 不一致,具体取决于项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apache Commons 是一组各种不同的库.在 Maven Central Repository 上,它们有两种不同的 groupIds 命名约定,具体取决于项目,例如

Apache Commons is a set of many various libraries. On Maven Central Repository they have two different naming conventions for groupIds, depending on the project, e.g.

  • 对于Commons Lang、Commons Compress、Commons Weaver - 'org.apache.commons'
  • 对于Commons CLI、Commons IO - 'commons-[library_name]'
  • for Commons Lang, Commons Compress, Commons Weaver - 'org.apache.commons'
  • for Commons CLI, Commons IO - 'commons-[library_name]'

它们之间有什么区别?

推荐答案

commons-[library_name] 命名约定是较旧的遗留约定.org.apache.commons 样式的名称遵循 当前操作惯例基于域名的 groupId.在公约建立后启动的所有 Apache 项目都有一个格式为 org.apache.* 的 groupId.一些在公约成立之前启动的项目更改了它们的 groupId,而另一些则没有.

The commons-[library_name] naming convention is the older, legacy convention. The org.apache.commons-style names follow the current operating convention of basing groupIds on domain names. All Apache projects started after the convention was established have a groupId of the form org.apache.*. Some projects that were started before the convention was established changed their groupIds while others did not.

在 Maven 历史早期的某个时候,显然需要在 Maven Central 中的所有项目中强制实施通用唯一的 groupId,以避免名称冲突.确保这一点的一种简单方法是建立一个约定,项目作者只能使用他们控制的域名中的 groupId.因此,来自 Apache 组织的 org.apache.* 形式的 groupIds.

Sometime early in the history of Maven, there was an obvious need to enforce universally unique groupIds across all projects in Maven Central to avoid name collisions. An easy way to ensure that was to establish a convention where project authors could only use groupIds from a domain name they control. Hence groupIds of the form org.apache.* from the Apache organization.

然而,很多项目已经不遵守约定了,改变groupId也不是那么简单声音.主要原因是,如果旧的和新的 groupId 都是特定项目的依赖项,那么这两个工件都将被包含在内,然后您会遇到不同的工件提供完全相同的类的情况,这是类加载的噩梦.

However, many projects already did not adhere to the convention, and changing the groupId is not as trivial as it sounds. The main reason why is that if both the old and the new groupIds are dependencies of a particular project, both artifacts will be included, and then you have a case where you have different artifacts providing the exact same classes, which is a classloading nightmare.

一些项目通过同时更改包名称和 groupId 来切换到新约定,例如 Commons Lang 做了.然而,更改包名通常被认为是非常具有破坏性的,因此 Commons Lang 仅在不兼容的 API 更改时才这样做.其他项目,如 Commons IO,有一些讨论反复讨论,但最终没有做出改变,因为旧式名称并没有真正伤害任何人无论如何.

Some projects switched over to the new convention by also changing the package name along with the groupId, like Commons Lang did. However, changing the package name is generally considered pretty disruptive, so Commons Lang did it only along with incompatible API changes. Other projects, like Commons IO, had some discussions and back-and-forth about it, but ultimately never got around to making the switch, because the old-style name is not really hurting anybody anyway.

这就是为什么今天大多数 Apache 项目都采用 org.apache.* 形式,但仍有一些不是.

So that's why today most Apache projects are of the form org.apache.*, but there are still a few that are not.

这篇关于为什么 Apache Commons 库的 groupId 不一致,具体取决于项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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