为什么 Apache Commons 库的 groupId 不一致,具体取决于项目?

Why do Apache Commons libraries have inconsistent groupIds, depending on the project?

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

它们有什么区别?

commons-[library_name] 命名约定是较旧的遗留约定。 org.apache.commons 风格的名称遵循基于域名的 current operating convention groupIds。所有在约定成立后启动的 Apache 项目都有一个 org.apache.* 形式的 groupId。一些在公约成立之前启动的项目改变了他们的groupId,而另一些则没有。

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

但是,很多项目已经不遵守约定了,changing the groupId is not as trivial as it sounds。主要原因是如果旧的和新的 groupIds 都是特定项目的依赖项,那么两个工件都将被包含,然后你会遇到不同的工件提供完全相同的 类 的情况类加载噩梦。

一些项目通过更改包名称和 groupId 来切换到新约定,例如 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,但最终没有时间进行切换,因为旧式名称是无论如何都没有真正伤害任何人。

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