Maven $ {user.home} could not resolve correctly

I have the following line in my pom.xml:

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

      

and when I try to use it in my program the resulting line is:

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

      

where <myusername>

is my username is pretty funny.

however it should be

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

      

Does anyone have any ideas as to why it doesn't resolve correctly?

Thank you in advance

+2


source to share


2 answers


It might be a bug in maven. I've written about this workaround for a while now :

I found a convenient way to reference a Java System Property ${user.home}

in a Maven assembly that supports Windows Fuzzy Pathname for home / profile directories:

c:\Documents and Settings\foobar.

      

The problem is that when using Maven, this parameterized property does not get passed as one property value, but as three, because somewhere in Maven build chokes on spaces or backslashes and interprets it as either three arguments:

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

      

or treats backslashes as an escape character and removes them so my parameterized user.home becomes:

"c:Documents and Settingsfoobar"

      

[...]

However, on Windows XP, if I didn't set user.home on the build path every time, the backward drop or space bar issues do not result in the files not being found.

To fix this, 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 the appropriate entry to activeProfiles:

<activeProfile>laptop-xp</activeProfile>

      

Now each user will be able to use the user.home

property to link their home path correctly to the Windows Window.



Or are you just another victim of this error: http://bugs.sun.com/view_bug.do?bug_id=4787931 . This is a very old bug (over 6 years old) that affects all versions up to Java 1.6.x.

+6


source


Another workaround could be to fix or create the path with the GMaven Groovy plugin , similar to this groovy code:

System.setProperty(  
  'user.home.fixed',  
  System.getProperty('user.home').replaceAll( '\\\\', '/' )  )

      



It might even be possible to override it user.home

, but I'm not sure if this will work. Therefore, use is everywhere, and should not work if done early. ${user.home.fixed}

${user.home}

0


source







All Articles