Coach Thrasher

Sunday Jun 08, 2008

Parameterized user.home for Maven on Windows XP

I found a handy way to reference the Java system property ${user.home} within a Maven build that supports Windows' ridiculous path name to home/profile directories:

c:\Documents and Settings\jason.

The problem is, when using Maven, this parameterized property doesn't get passed through as one property value, but as three, because somewhere in the build Maven chokes on the spaces or back-slashes and interprets it as either three arguments:

"c:\Documents", "and", "Settings\jason"

or treats the windows back-slash as an escape character and removes them so my parameterized user.home becomes:

"c:Documents and Settingsjason"

Why would this matter? Well, if you want to share build configurations with other developers, and can't check some of your files into a source control management system (because, for example, they contain private keys or certificates that don't belong in SCM), then you need a common, parameterized place to reference them that will work for every developer without much trouble. In my case, it's integration with Amazon's web-services that necessitates managing public/private PEM and P12 files.

For Amazon, I want to reference the AWS pem and p12 files like this from either the Maven pom.xml, or the settings.xml file:
${user.home}/aws/cert-BLAH.pem
${user.home}/aws/pk-BLAH.pem
${user.home}/aws/awskeystore-BLAH.p12

However, on Windows XP, unless I set the user.home on the build path every time, the back-slash escaping or space issues cause the files to not be found.

To fix it, add this profile to the $M2_HOME/conf/settings.xml file:

<profile>
<id>laptop-xp</id>
<properties>
<user.home>C:/Documents and Settings/${user.name}</user.home>
</properties>
</profile>

Then add an appropriate entry to the activeProfiles:

<activeProfile>laptop-xp</activeProfile>

Now every user will be able to use the user.home property to reference their home path correctly on the Windows box.

Comments:

Post a Comment:
Comments are closed for this entry.

Calendar

Feeds

Search

Links

Navigation

Referrers