Your maven repository on GitHub

Developers can upload their library to GitHub, for which it has a special site-maven-plugin plugin . Let's look at an example of its use:

        	<name>Temporary Staging Repository</name>
                	<message>Maven artifacts for ${project.version}</message>

Let's see what is written here.

The creation of a temporary local repository is highlighted in blue. Technically it's just a folder, but we need Maven to treat it as a separate repository.

We highlighted in red the launch of the maven-deploy-plugin plugin , where we indicated that the compiled library should be placed in this temporary repository.

And finally, the site-maven-plugin plugin is highlighted in green , which should take all the files from the repository and commit them to GitHub. Some explanation is needed here. All parameters are divided into two groups: what to fill and where to fill.

What we fill in:
  • outputDirectory - directory where to get files for commit
  • includes - sets the mask of files to commit
Where do we upload:
  • repositoryOwner - the name of the repository owner on GitHub
  • repositoryName - repository name
  • branch - sets the repository branch on GitHub to which to commit
  • message - the message that will be added when committing

You also need to specify the login and password for your repository in Maven setting.xml :


To connect (use) a library from a GitHub repository to another project, you need to specify this repository in your pom.xml :


After that, Maven will understand where to get the library from.

  • [name-project] is the name of the project, in our case SuperLibrary
  • [username] is the login on GitHub, in the example it is codegym-user

Packing the assembly into a Docker image

We live in a new time, when projects as a result of the assembly can be placed in the Maven repository, or maybe in docker storage.

To make Maven and Docker friends, we need the docker-maven-plugin plugin . Nothing complicated:


Highlighted in blue is the point where we added the goal bulid to the package phase of the build. It can be called with the mvn docker:build command .

The dockerDirectory tag specifies the folder where the Dockerfile is located. And the name of the image is set using the imageName tag .

If the project is packaged in a jar file, then the docker file will look something like this:

FROM java:11
ADD /target/demo.jar demo.jar
ENTRYPOINT ["java","-jar","demo.jar"]

If you are packaging a web application, then you may need to add Tomcat:

FROM tomcat8
ADD sample.war ${CATALINA_HOME}/webapps/ROOT.war