Ernest Duodu Ernest is a Java developer. Outside programming, he also enjoys a wide variety of hobbies which includes sky-diving, photography, exercising and listening to music.

How to host a Maven artifact on GitHub

2 min read

Recently at IDR Solutions, I have been working on converting our existing Ant NetBeans plugin to Maven. In order to do so I had to find a way to host the dependencies we ship with the plugin on a Remote or Central Repository.

What is Ant and Maven

Both, Ant and Maven are java build tools. Ant is an imperative build System (instruct Ant what to do i.e explicitly script all targets that makes up the build ) where as Maven is declarative(what we would like the end result of the build to i.e jar or war and it does just that, you do not have to explicitly specify the execution units. )

Why we converted from Ant to Maven

In our previous Ant plugin,the developer had to manually search, download and install the jars each time we update, wheres as in Maven you just have to specify the location of the jar in an xml file (Project Object Model or POM ) and the jars will be automatically downloaded and added as a dependency to the project.

In this article, I will show you step by step how to create a GitHub account and host your Maven artifact on it.


  1. You need to have git installed. You can get git from here
  2. You need to have maven installed. You can get maven from here
  3. You need to have your jar or war file to be hosted ready
  1. Create a new GitHub Repository and select Initialize with ReadMe. I will call mine maven-test-repo.Create a GitHub account if you don’t have already one. Click here to create one.
  2. Clone the GitHub Repository you just created to your desktop (or any preferred location). To do this open command line/Terminal and type in git and enter. If you see something like my screenshot, you are good to go else you need to check your git installation.
    Once installed, open command/Terminal and type in git clone {your-github-maven repository}. In my case this will be
    git clone

    If you set the path to your desktop on command line/ Terminal, you should now see a folder with the name of your repository name and in that folder you should see a holder called .git(on windows) if you’re on mac, depending on your visibility setting, you might not see it but on both OS you should see a file.

  3. We need to place the jar we want to host on GitHub remote repository into our local GitHub repository. We will use maven to perform this task. On command/Terminal, navigate to the local GitHub repository you cloned earlier on. Type in mvn and hit enter. If you do not see something like my screenshot below, you need check your maven installation.
    Now edit this code accordingly and paste onto your terminal and hit enter
    mvn install:install-file -DgroupId=[group-id] -DartifactId=[artifact-id] -Dversion=[version] -Dpackaging=[packaging-format]-Dfile=[path-to-file] -DlocalRepositoryPath=[path-to-the-cloned-repository]

    Im mycase this will be

    mvn install:install-file -DgroupId=org.jpedal -DartifactId=OpenVierwerFX -Dversion=1.0 -Dpackaging=jar -Dfile=C:\Users\Ernest\Desktop\maven-test-jar-older\MavenTestJar.jar -DlocalRepositoryPath=C:\Users\Ernest\Desktop\maven-test-repo

    You should see this on you command Line/Terminal. Also if you check in you local GitHub repository you should see some generated files in there.

  4. Now we are in the position to push to our GitHub remote repository. Commit and Push the changes of the local repository to the remote repository.
    git add "name of generated folder" (in my case git add org) then enter
    git commit -m "Sensible commit message"
    git push -u origin master

    Enter you login credentials and hit enter. Now go to GitHub and Voila!! you have successfully uploaded your first Maven artifact on GitHub.

    Hopefully you have found this quick guide useful. In my next article i will show you how you use the jar you have uploaded as a dependency is a new Maven project

Are you a Java Developer working with PDF files?

Find out why you should be using JPedal
Ernest Duodu Ernest is a Java developer. Outside programming, he also enjoys a wide variety of hobbies which includes sky-diving, photography, exercising and listening to music.

3 Replies to “How to host a Maven artifact on GitHub”

    1. If you want to build/get the jar file then you can use maven package once you have downloaded the source code and it will create the jar file in your project’s target directory.

      Hope this helps.

Comments are closed.