Wednesday, September 30, 2009

Building a Site and using Properties

When building a site in Maven you are likely to want to use custom properties, such as the version #, artifact/group ids and so forth. This isn't as easy as it should be. First you'll need to attach an extra '.vm' to the end of any apt, fml file that you want to be filtered. Without this the ${property} references in these files will not be replaced with values.

A word on the properties you'll use in these site template files. They may not have '.'s in them. That's right you can't have a property such as 'pom.version' in your templates. So instead you'll need to add properties that do not use this character.


<properties>
<currentVersion>${pom.version}</currentVersion>
<properties>


Then in your apt file you can now put in ${currentVersion} and it will resolve to the pom's version element value in the generated html file.

Sunday, June 21, 2009

Authenticating When Using the SCM Plugin

If you are using the SCM plugin with Mercurial then you will likely need to pass the username and password to it. This can be done with the following arguments to the mvn command:

"-Dusername=<username> -Dpassword=<password>"

You also can create a server element in your 'settings.xml' file (in ~/.m2) which has an id that matches the host part of the SCM url, then set the username/password in the respective elements. This'll keep you from having to put in the values on the command line again and again.

<server>
<id>www.blueleftistconstructor.com</id>
<username>rob</username>
<password>pass</password>
</server>

When using the release plugin I've always had to use this technique to 'push' the changeset from my local mercurial repo to the remote one.

Note that one unfortunate side effect here is that the HG Maven plugin WILL OUTPUT YOUR CREDENTIALS IN CLEAR TEXT!!!

This doesn't bother me all that much since I run a pretty tight ship, but if this violates your comfort level you may be out of luck as far as the release plugin goes.