Hosting Maven Sites & Repos at Google Code

by Dana H. P'Simer

Sat, Aug 14, 2010


When hosting an Open Source software project you want to keep things simple and cheap. I was struggling to figure out where I was going to put my SNAPSHOTs and site for a simple BOM striping plugin I had written and was hosting at Google Code. I came across this article but it assumes you are going to use Subversion. I prefer Mercurial so I came up with a similar method.

What I came up with was this: Since Google uses http/https to access the Hg repository, I decided a similar arrangement would work. However with Hg you don't push revisions directly to the remote repo. First they have to go into the local clone then they get pushed. For Hg based projects Google Code provisions two source repositories: one for the wiki and one for the code. So I decided to use the wiki source repo to hold the maven repo and site.

To see the entire project source code and layout go to The Google Code Site for the Strip BOM Maven Plugin. The following are a set of steps that should help you use the same strategy in your project:

  1. In order to know where the local wiki repo directory is, I needed a property to hold that value and then we would set it in the settings.xml, however I am a fan of not having any external dependencies that could cause the build to fail. So I added this to my POM to set a default:
  <properties>
    <strip-bom.deploy.directory>${basedir}/target/deploy</strip-bom.deploy.directory>
    ...
  </properties>
  1. Next I added the following to my POM to define the distributionManagement settings

  <distributionManagement>
    <repository>
      <id>strip-bom-deploy</id>
      <name>Repo</name>
      <uniqueVersion>true</uniqueVersion>
      <url>file:${strip-bom.deploy.directory}/repo</url>
    </repository>
    <site>
      <id>strip-bom-site</id>
      <name>Site</name>
      <url>file:${strip-bom.deploy.directory}/site</url>
    </site>
    <downloadUrl>http://code.google.com/p/strip-bom-maven-plugin/downloads</downloadUrl>
  </distributionManagement>
The <repository> tag defines where the repo will be stored. The <site> defines where the site will be deployed. These will be in my Hg controlled local repo.

  1. Next, I added this to my settings.xml:
  <profiles>
    <profile>
      <activation><activeByDefault>true</activeByDefault></activation>
      <properties>
        <strip-bom.deploy.directory>${user.home}/dev/dhptech/strip-bom-maven-plugin-wiki</strip-bom.deploy.directory>
      </properties>
      <id>default</id>
    </profile>
  </profiles>

Now, when I do a snapshot build, I can execute mvn deploy site-deploy, commit and push the wiki repo, and the snapshot and site are deployed at the same time.