4

We are using a small segment of Groovy code within our POM file to replace the backslash delimiters in the main base directory with forward slash delimiters. For more information on this, see this post: How to convert file separator in maven

However, the problem we have is that the suggested groovy from that link works fine on one developers machine, but not on another.

What works for the first developer is this: (The code mentioned in the linked post)

pom.properties['main.basedir']=project.basedir.absolutePath.replace('\\','/');

What works for the other developer is the following:

pom.properties['main.basedir']=project.basedir.absolutePath.replace('\','/');

(Note the single backslash)

The errors that the second developer sees when using the double backslash are:

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:15.096s
[INFO] Finished at: Tue Sep 03 16:54:18 BST 2013
[INFO] Final Memory: 36M/298M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.gmaven:gmaven-plugin:1.5:execute (setproperty) on project bonus-wallet-amq-tests: startup failed, script1378223658221.groovy: 1: expecting ''', found '<EOF>' @ line 1, column 79.
[ERROR] 1 error

We can't work out why the second developer only needs the single backslash. Both developers are using Eclipse Juno, Java 1.6 Update 45 and the version of groovy must be the same as it is defined as a dependency in the POM file. (Version 1.6.9)

The only thing we found was the versions of maven being different. Developer 1 has version 3.0.3 and developer 2 has version 3.0.5. However we have been unable to find any documentation that may relate to this.

Any help would be most beneficial.

4

1 回答 1

4

You should change your code as follows:

pom.properties['main.basedir']= project.basedir.absolutePath.replace(File.separator,'/');

Instead of manually decode your file separator.

于 2013-09-03T17:38:45.790 回答