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.