Hosting Maven Sites & Repos at Google Code

by Dana H. P'Simer

Sat, Aug 14, 2010


  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.