Hosting Maven Sites & Repos at Google Code

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

  &lt;distributionManagement>
    &lt;repository>
      &lt;id>strip-bom-deploy&lt;/id>
      &lt;name>Repo&lt;/name>
      &lt;uniqueVersion>true&lt;/uniqueVersion>
      &lt;url>file:${strip-bom.deploy.directory}/repo&lt;/url>
    &lt;/repository>
    &lt;site>
      &lt;id>strip-bom-site&lt;/id>
      &lt;name>Site&lt;/name>
      &lt;url>file:${strip-bom.deploy.directory}/site&lt;/url>
    &lt;/site>
    &lt;downloadUrl>http://code.google.com/p/strip-bom-maven-plugin/downloads&lt;/downloadUrl>
  &lt;/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:
  &lt;profiles>
    &lt;profile>
      &lt;activation>&lt;activeByDefault>true&lt;/activeByDefault>&lt;/activation>
      &lt;properties>
        &lt;strip-bom.deploy.directory>${user.home}/dev/dhptech/strip-bom-maven-plugin-wiki&lt;/strip-bom.deploy.directory>
      &lt;/properties>
      &lt;id>default&lt;/id>
    &lt;/profile>
  &lt;/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.