How to create simple maven repository on GitHub

10 Mar

Most of the people who are developing simple important projects in java have the following problem.
The problem is how to expose their java libraries as maven artifact.

This is a simple and easy solution for the above matter.

You can easily create the Git repository on GitHub and do the following steps.

First of all tell maven to deploy artifacts to a temporary staging location inside your target directory. Add this to your project pom.xml

        <name>Temporary Staging Repository</name>


Run mvn clean deploy. You’ll see maven artifact is deployed your maven repository located in target/mvn-repo.

Secondly we have to upload the created artifact to github. In order to do that add your authentication information to ~/.m2/settings.xml so then the github site-maven-plugin can push to github


Please make sure this file has proper security because some one can take your credentials.Then the next step is give the server details to your project by referring the server id created above.

Go to your project pom file and place the following property

    <!-- github server corresponds to entry in ~/.m2/settings.xml -->

The last step is going to upload your locally created artifacts in to the github. In my point of view you better create new branch on your project as mvn-repo and place the following configuration on your project.

              <!-- git commit message -->
              <message>Maven artifacts for ${project.version}</message>
              <!-- disable webpage processing -->
              <!-- matches distribution management repository url above -->
              <!-- remote branch name -->
              <!-- If you remove this then the old artifact will be removed and new 
               one will replace. But with the merge tag you can just release by changing 
                                                the version -->
                <!-- github repo name -->
                <!-- github username -->

Run mvn clean deploy again. You should see maven-deploy-plugin create the files to your local staging repository in the target directory, then site-maven-plugin committing those files and pushing them to the server. Now the artifact is available to public use.

When you need to use your uploaded artifact you have to do the following step. You need to add your repository as follows


Now you can refer your maven artifacts easily. I hope now you can expose your simple artifacts as you wish.


Posted by on March 10, 2014 in java


Tags: ,

2 responses to “How to create simple maven repository on GitHub

  1. Sergey Karpushin

    May 30, 2015 at 12:10 am

    Thank you! I would add small instruction to this guide though:

    For new github users make sure you filled your real name in github profile, otherwise you’ll hit meaningless error while running ,maven build (described here:

  2. ruedisteinmann

    February 8, 2017 at 7:07 pm

    I created a public maven repository without the fuss of Maven Central. Check it out: All Feedback is welcome. Enjoy!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: