Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving a project to Maven Central

Tags:

maven

sonatype

I manage many maven projects. Most of them deploy to our internal maven repository. Now I would like to start releasing one project to Maven Central. Up until now, I have had a parent POM that specified the distributionManagement of our internal repository. It doesn't make sense to deploy this information to Maven Central.

How should I specify the distribution management for my internal projects? Should I have a seperate parent pom group-internal for internal projects?

Sonatype mentions a way to deploy directly to their repositories, but they recommend using their own parent pom (oss-parent). Looking at projects using mvnrepository.org, I couldn't find any projects with oss-parent as the parent. Do most project manually deploy their artifacts to Sonatype? Where and how do they deploy them first?

So many questions! I'm amazed at how complicates this is...

Update: it turns out some of the projects I identified do use oss-parent. It's just hidden as it's the parent of a parent.

like image 946
schmmd Avatar asked Apr 19 '12 23:04

schmmd


People also ask

How do I publish a Java project to Maven Central?

For each Java project you want to publish the JAR files of to the central Maven repository, you need to go through the following set of POM file configuration steps: Configure POM file with project coordinates. Configure POM file with project name. Configure POM file with project description.

How do I migrate from JCenter to Maven Central?

Migrating to mavenCentral To do so, you must simply add mavenCentral() in your build. gradle file. Make sure to put mavenCentral() before JCenter so that the build script takes the up-to-date versions on mavenCentral in priority.

What is Maven central repository?

Introduction to Maven Central Repository. Maven repository is a directory where all the dependencies such as jars, library files, plugins, or other artifacts that will be required by the projects are stored.


2 Answers

Once you are all set up, you can deploy staged releases and SNAPSHOTs directly to Sonatype's OSS repository. Stages releases can then be released through Sonatype's Nexus UI.

To create a repository folder for your application to which you can deploy, you open a ticket with Sonatype on their JIRA along with a reference to the open-source project you will deploy. The process is very smooth and Sonatype will help you if you don't supply all the necessary information.

While on first glace it doesn't look like many projects have oss-parent as a parent, they often do when you navigate up the POM tree. For example, Google Guava has the parent guava-parent, which has the parent oss-parent. Once your project has oss-parent and the repository is configured, you can easily deploy SNAPSHOTs and releases with mvn deploy or mvn release:prepare release:perform.

It seems overwhelming, but it's easily understood if you just plow through the steps for the first time.

like image 104
schmmd Avatar answered Nov 04 '22 09:11

schmmd


The first I recommend to read is the following: https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide The OSS parent makes under special circumstance sense under other not. That depends what kind of project you like to distribute.

UPDATE: That link is dead now. Look here for help deploying to Sonatype.

UPDATE: For Maven Central check this: http://central.sonatype.org/

like image 41
khmarbaise Avatar answered Nov 04 '22 10:11

khmarbaise