Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

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

What is the difference between them?

like image 506
Kao Avatar asked Aug 24 '15 13:08

Kao


1 Answers

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.

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.

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.

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.

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

like image 71
heenenee Avatar answered Oct 21 '22 11:10

heenenee