DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Coding
  3. Java
  4. Want to Host on Maven Central?

Want to Host on Maven Central?

Kapil Viren Ahuja user avatar by
Kapil Viren Ahuja
·
Sep. 17, 11 · Interview
Like (0)
Save
Tweet
Share
4.64K Views

Join the DZone community and get the full member experience.

Join For Free

Recently, when I decided to make my projects available to the Java Community under Open Source license, I did a lit of things like Hosting my code on Google Code, using Maven to build and test the code and also making sure that I have a project site up and running. However, even after all of this, there was one thing that was missing which was the most essential – “Hosting the project files on a repository so that users who may find these utilities useful may use it”.

I started to research on what was possible and after little research I found out that sonatype would allow me to deploy my code to Maven Central Repository. However, after 3 days of trial and error, I have finally been able to release a version of my code to the Central Repo. I am writing this post so that if you ever want to do this, you will not have to go through the same pain as I did.

Pre-requisites

  • A domain name which will be your groupId – I used kapilvirenahuja.com which is used as “com.kapilvirenahuja”
  • A PGP key – this is a requirement for you to sign your artifacts and upload it to Central. You can refer to the document here for help on how PGP keys can be generated.
  • Have the username and password of your SVN handy, you will need it while performing builds and releases

 

Hosting

The easiest way to upload another project is to use the Sonatype OSS Repository, which is an approved repository provided by Sonatype for any OSS Project that want to get their artifacts into Central Repository.

The service is proposed in two variants:

  • Maven repository hosting service: You can deploy snapshots, stage releases, and promote your releases so they will be published to Central Repository
  • Manual upload of artifacts: The process is mostly automated with turnaround time averaging 1 business day.

Follow the steps in the guide which is self-explanatory. After sign-up, when you are creating the issue for a new project, you will need the domain address. If you do not have a domain registered, you will not be able to proceed.

After your account is created, you will receive email notifications that you are good to go. Follow the steps in the link and update your POM as per Step 6. When you are ready, follow instructions in Step#7 and you should be able to deploy the code to Snapshot directory. If you get 401 error or “Authorization failed”, check for following:

  • The groupId in the POM.XML is the same that you registered for
  • The Settings.xml has the Nexus username and password. You can run the maven command in -X (debug) mode and see logs to validate the location of the settings.xml file

Release to Central

Once you have the artifacts on Snapshots repository you are past a major step in the process, but the next one is even bigger. The step 7.a.3 seems simple but is not that simple especially if you have only used mvn:compile in most cases. Ensure that you follow standard directory layout anything else and the process will fail at the last step.

Step 1

The First step is to Clean up Release using Maven plugin

mvn release:clean 

You will notice that it will be done quickly (apart from the time it takes for maven to download dependencies and plugins).

Step 2

Run the following command. You will have to pass the username and password through mvn. The command should be

mvn release:prepare -Dusername=username -Dpassword=password

It will do the following:

  • Ask for the version number for the current release
  • Ask for the version of the tag that will be created, should be same as the release number provided above
  • Ask for the next version of the release – you can choose to provide a major or minor release.

Please be careful when selecting the version numbers, because this process will update the POM files and also the subversion repository by adding new tag and also updating the POM file in the current working location.

Step 3

mvn release:perform -Dusername=username -Dpassword=password

This is a non-intrusive method and will simply upload everything to the repository. If you miss the username and password, the build will fail without any descriptive errors and you will keep wondering what went wrong.

From http://scratchpad101.com/2011/09/08/project-files-maven-central/

Apache Maven Host (Unix)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Tracking Software Architecture Decisions
  • Introduction to Spring Cloud Kubernetes
  • The Power of Docker Images: A Comprehensive Guide to Building From Scratch
  • Implementing PEG in Java

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: