Java Jar - Publish to Open Source

2019, 28 July

Hello again, this time I am gonna tell you about the time I publish a open source jar to maven central repository.

This post is about publishing jar file which is an artifact that is generated using java programming language.

If you managed to generate a library into jar file, you can publish it to maven central repository. The catch is that you gotta make the library as open source library.

You can follow the guide provided by OSSRH (Open Source Software Repository Hosting).

In summary, the steps are:

  1. Create a jira account for the OSSRH jira via this link.
  2. Create a new jira project via this link. Your new project will look like this. JIRA ticket example
  3. You might need to verify your domain ownership if you use personal domain.

    You can verify the domain by adding the TXT record that reference to the jira ticket.

    After adding the TXT record, you can check if it’s propagated properly like this.

    TXT DNS check

  4. Follow this requirements of the library setup. The requirements require you to publish javadoc and sign your library with developer information and license.

    You can also refer to this example.

  5. Publish your library using OSSRH jira credentials (username and password) to staging.
  6. Login to the OSSRH Nexus using OSSRH jira credentials.
  7. You should be able to see your library under the staging menu.
  8. Promote your staging artifact using the menu in the nexus (can right click also).

    This step will trigger some checks on the library.

    If something fails, try to fix the error or retry.

  9. After you promote your first artifact, you can comment on the jira ticket you created previously to enable the sync to maven central. The sync might takes sometime up to some hours, you can check if your artifact is available via maven search.

    If you got confused along the way, you can also refer to the release guide.

And, that’s all folks.

Hope that this guide can help you contribute to the Open Source Software.