1

I want to upload a fork of a Java library to Maven. According to https://maven.apache.org/guides/mini/guide-central-repository-upload.html I have to pick a new groupId.

Now the groupId doesn't match the Java namespace anymore. Do I need to rename all Java packages as well or can I keep the original namespace?

Example:
Original library:
Maven groupId: org.foo.bar
Java namespace: org.foo.bar

Fork:
Maven GroupId: com.acme.bar
Java namespace: org.foo.bar

0

1 Answer 1

3

The groupId and the package name don't have to match necessarily.

The thing is, that the same package might confuse tools and frameworks.

Let's say both have a class foo.Bar but with a different API.

E.g. having both libraries on the classpath build tools such as Maven won't recognize that it's actual the same dependency in different versions (version resolution). Later at runtime this means that the first version of foo.Bar on the classpath wins. You might be able to use excludes to solve this issue, but this makes the build more complex.

Also module systems such as OSGi and probably Jigsaw (Java SE 9), too, work on the package level. How do you want to version these packages in a way the versioning doesn't conflict with the version of the original package?

So best thing would be to work with the original project together rather than to release a fork.

If this is not possible for some reason, I would only keep the same package names if

  • you're pretty sure that you (or any user of your library) won't end up with both dependencies on the classpath

and

  • you want to merge updates of the original project into your fork (which might be easier with some VCS, if you keep the same package names)

In all other cases I would recommend to change the package names.

3
  • 1
    Well put. If you are in control of both groupIds (meaning that the "real" com.acme doesn't exist or can claim namespace infringement) then from a technical standpoint it doesn't matter, it's rather only confusing to humans. For instance, commons-lang:commons-lang doesn't define any classes under the commons-lang package.
    – Daniel
    Oct 12, 2015 at 15:55
  • 1
    Thank you for the elaborate considerations. The original project has been unmaintained for years and was never uploaded to Maven. There are several forks with minor patches floating around on GitHub. However nobody stepped forward as the new maintainer. So I will instead host the repository on GitHub first. stackoverflow.com/questions/14013644/… Should it gain traction, I will rename the packages properly and upload it to Maven.
    – wfr
    Oct 12, 2015 at 15:59
  • 1
    @wfr Did you try to contact the owner? Maybe he/ she is ready to give the control over the original project to you.
    – Puce
    Oct 12, 2015 at 16:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.