views:

426

answers:

1

I've got the following line in my pom.xml:

<updateRepositoryURL>file:/${user.home}/.m2/repository/repository.xml</updateRepositoryURL>

and when I am attempting to use it within my program the resultant string is:

file:/c:Documents and Settings<myusername>/.m2/repository/repository.xml

where <myusername> is my user name funnily enough.

however it should be

file:/c:/Documents and Settings/<myusername>/.m2/repository/repository.xml

Does anyone out there have any ideas as to why it is not resolving properly?

Thanks in advance

+2  A: 

This might be a bug in maven. I've bookmarked this workaround some time ago:

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\foobar.

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\foobar"

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

"c:Documents and Settingsfoobar"

[...]

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.

Or, you're just another victim of this bug: http://bugs.sun.com/view_bug.do?bug_id=4787931. It's a very old bug (more than 6 years old) that affects all versions up till Java 1.6.x.

Pascal Thivent
Thanks, That works but going to stil look for another solution at leads request. The link doesnt seem to work giving a 503 error.
schubySteve
+1 for the workaround, the alternative is to put the file somewhere else. You can override the localRepository in the settings to point to c:\.m2\repository or something else short and easy to find
Rich Seller