Tuesday, February 23, 2010

Google Code as Maven Repository

In this post I will explain how to set up a Google code project as a maven repository.

I like Maven. The fact that I can checkout some code and let Maven figure out all the dependencies is wonderful. I know that there are developers out there who will criticize Maven. But in my opinion, a lot of the critique is not really justified.

I also like Google code project hosting. It is very easy to start a project on Google code and have a mature environment for software development.

When I was looking around for a way to publicize my own artefacts I came across the idea of using project hosting on Google code as a maven repository. Because It took me a while to get everything up and running, I will outline the steps I had to take.

As a precondition, I assume a you have a Google code project where you can submit to and a working maven project.

  1. Add the Java.net maven repository.

    We will be using a plugin which is found on the java.net maven repository.
        Java.net Repository for Maven

  2. Add the wagon-svn plugin

    We are going to use the wagon-svn plugin which will do all the heavy lifting for us. Make sure to use the latest version.

  3. Come up with a naming scheme.

    We are going to create repositories in the svn tree. I propose the following convention. Create a maven directory at the top of the svn tree. This directory will contain a repo directory and a snapshot-repo.

    This can be configured in the following way.
          Maven Repository for minimal-examples
          Maven Repository for minimal-examples (snapshot)

Now we are all set to start deploying! By running the command maven deploy, the svn-wagon plugin will deploy the artifacts to the repository. The first time you will have to accept the certificate that the Google code project return.
Furthermore, you will have to authenticate yourself with your username and password which are known to the Google code project. You can take up this information in your ~/.m2/settings.xml, so you do not have to enter this information all the time.


This wraps up the set up for using a Google code project as a Maven repository.


  1. This comment has been removed by a blog administrator.

  2. Thank you for this post. I found it vary helpful in setting up our in house svn as a maven repository. Some of the xml tags in your sample code need to be camel-cased to make maven happy. "groupid" should be "groupId", "artifactid" shuold be "artifactId", "distributionmanagement" should be "distributionManagement", "snapshotrepository" should be "snapshotRepository" and "uniqueversion" shuold be "uniqueVersion".

  3. Great post Daan, really appreciate it.

    Hakan ERDOGAN

  4. Can you give an example of how someone would download your artifact? What would they need to specify as the repository?