I have a open source maven project hosted on GitHub. Let's say the url is https://github.com/foo/bar.

Now I want to upload it to the Sonatype OSS Maven Repository. I checked that they have a strict rule on the groupId (https://docs.sonatype.org/display/Repository/Choosing+your+Coordinates).

groupId will identify your project uniquely across all projects, so we need to enforce a naming schema. It has to follow the package name rules, what means that has to be at least as a domain name you control, and you can create as many subgroups as you want. eg. org.apache.maven, org.apache.commons A good way to determine the granularity of the groupId is to use the project structure. That is, if the current project is a multiple module project, it should append a new identifier to the parent's groupId. eg. org.apache.maven, org.apache.maven.plugins, org.apache.maven.reporting

The question is that for projects hosted on GitHub, what is the proper groudId?

As user generated website has domain foo.github.io, I have at least the following two options:

  • com.github.foo
  • io.github.foo
有帮助吗?

解决方案

It is a popular choice to use a groupId with the hosting site in the name. Search on http://search.maven.org for

  • net.sf
  • sourceforge
  • googlecode
  • github

While it is better to use a domain that you really own, using the hosting site in the groupId is a sensible fall-back. You should try to make sure that you choose a name that is not associated with the hosting company itself (e.g. com.google) but with the hosting site (e.g. com.googlecode), so that it is clear you are a project on the site and not a project of the underlying company.

其他提示

I think you should use your own domain in the groupId, not github.* - that implies that the project is owned by Github.

While many groupIds of Maven projects are derived from the web domain, they are derived from the domain of the people who started the project - github is just a convenient service to give other people access to your project.

So you should select an ID which is specific for you just like all the other projects there.

Another options is foo.bar as groupId, but groupId with github is also good.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top