DEV Community


Hosting a maven repository on Github: site-maven-plugin

iamthecarisma profile image Adewale Azeez ใƒป3 min read

This article provides a step by step guide on publishing a maven project from GitHub using site-maven-plugin.


  • Project repository on Github
  • Java and Maven
  • Familiarity with Maven configuration

Create a repository for your maven project on Github if you don't have one already and push your maven project. This method will use the site-maven-plugin to push the artifacts to Github.

This approach does not cause conflict with gh-pages and other branch as the artifacts is pushed to the mvn-repo branch of your repository, every time the mvn deploy command is executed the new build artifact will be published.

First, the maven artifact has to be deployed to a temporary location in the build/target directory. Add the following repository to the project pom.xml:

        <name>Temporary Staging Repository</name>

Add the maven-deploy-plugin configuration to your pom.xml:


After adding the above repository and plugin to your pom.xml execute mvn deploy, the maven repository will be deployed to the directory target/mvn-repo/. The next step is to deploy to github mvn-repo branch.

Configure github authentication information in ~/.m2/settings.xml to enable site-maven-plugin push to github. if the file settings.xml does not exist it should be created.

There are several ways to authenticate github, add one of the following configuration to your ~/.m2/settings.xml.

using your github username and password:




Then add the following to your pom.xml:


The last step is to configure site-maven-plugin to push your local staging repo target/mvn-repo/ to your remote mvn-repo branch.

        <message>Maven artifacts for ${project.version}</message> <!-- git commit message -->
        <noJekyll>true</noJekyll>  <!-- disable webpage processing -->
        <outputDirectory>${}/mvn-repo</outputDirectory> <!-- matches distribution management repository url above -->
        <branch>refs/heads/mvn-repo</branch> <!-- remote branch name -->
        <repositoryName>YOUR-REPOSITORY-NAME</repositoryName> <!-- github repo name -->
        <repositoryOwner>THE-REPOSITORY-OWNER</repositoryOwner> <!-- organization or user name  -->
    <executions> <!-- run site-maven-plugin's 'site' target as part of the build's normal 'deploy' phase -->

repositoryOwner value is is the parent name of the repo, if the repo is owned by a github organization the value will be the organization name and if the repo is owned by a user the value will be the username e.g. for the repo keyvaluedb/key-value-db-java, repositoryName value will be key-value-db-java and repositoryOwner value will be keyvaluedb.

Execute mvn deploy to upload your artifact to github. The mvn-repo branch will be created if it does not exist.

Visit in your browser, select the mvn-repo branch, and verify that all your binaries are uploaded.

Alt Text

Hooray. Your maven project is now available to be used in other projects.

Every time you run mvn clean deploy command on your project, the latest artifacts will be uploaded to github.

Other maven project using your project can be configured to pull your artifact from github. Add the following snippet to the pom.xml files that depend on your project.


After adding the properties to the pom.xml the project will automatically download your maven repository jars from github.

Discussion (1)

Editor guide
tjmpholo profile image

Thank you very much @Adewale this solution worked for me with a simple maven side project, but it is failing for a multi module project with multiple pom.xml files that are nested within sub-projects of the main project. The project executes the "mvn deploy" command properly but it does not create any packages on github.