www-repository mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: Sharing common groupId
Date Thu, 17 Nov 2016 23:17:52 GMT
On 17 November 2016 at 22:38, Lukasz Lenart <lukaszlenart@apache.org> wrote:
> 2016-11-16 13:00 GMT+01:00 sebb <sebbaz@gmail.com>:
>> On 16 November 2016 at 10:10, Lukasz Lenart <lukaszlenart@apache.org> wrote:
>>> Hi,
>>>
>>> I would like to know if there is any problem if multiple different
>>> projects shares the same groupId? I meant, we would like to allow
>>> third parties to use common groupId as mentioned in the post below
>>>
>>> http://markmail.org/message/yruabvlfpfdfw6w5
>>>
>>> Can this be a problem during publishing artifacts?
>>
>> Yes. It can cause severe problems.
>>
>> Maven uses the (groupId,artifactId) pair to determine which jars can
>> appear on the same classpath.
>>
>> Unless all the projects sharing the groupId ensure that they use
>> distinct artifact Ids this can result in jar hell.
>>
>> The simplest way to ensure distinct (groupId,artifactId) pairs is to
>> ensure each independent project uses different groupIds.
>> They can then maintain their own unique list of artifactIds.
>
> So this should work, it's just a manner of controlling who can use the
> shared groupId and artifactId. We (Struts PMC) can accept if a given
> external project can use the groupId or not and this will give us a
> way to control if (groupId,artifactId) is distinct. Does it make
> sense?

This will need careful policing to avoid problems.
You have to be sure that the 3rd party will continue to abide by the rules.

And how do you decide which projects can use the gId and which cannot?
What if a project seems amenable at first, but then get taken over?

It's a lot simpler to let each external project have its own groupId.

The shared groupId sort of works for Maven plugins, because they use a
convention for the artifactId.
AIUI all official Maven plugins are named
maven-xxx-plugin
whereas 3rd party plugins have the form
xxx-maven-plugin

If two 3rd party plugins accidentally use the same name, then in
theory it's not a Maven problem.
However since they own the groupId, they may well get blamed.

==

Note that you need to be very careful about Java package names as well.
These need to be unique for each distinct (gid,aid) pair.

This is because Java only allows one instance of each class on the classpath.
If there are different copies of the class in different jars, which
one is used is generally indeterminate.

For this reason, Java package names by convention include the project
owners URL in reverse.
This name is under the control of the project.

Maven does not know about package names; it uses the (gid,aid) pair to
determine which jars can coexist.
So Maven coords must have a 1-1 relationship with Java package names
Change one, and you must change the other or risk runtime failures
that are really difficult to debug.

Also if the same Java package is in two different (gid,aid) pairs,
problems can result if both Maven jars are used.

>
> Regards
> --
> Ɓukasz
> + 48 606 323 122 http://www.lenart.org.pl/

Mime
View raw message