Steve Chambers Steve Chambers - 3 months ago 26
Java Question

How to stop backslashes being escaped when filtering with maven-resources-plugin?

I'd like to use the Maven Resources Plugin to set the XML schema location within an XML resource file:

<root xsi:noNamespaceSchemaLocation="${env.myxsdpath}" ...>

This works except for one thing - the substituted path has double backslashes instead of a single blackslash, e.g:

<root xsi:noNamespaceSchemaLocation="C:\\mypath\\myschema.xsd" ...>

So two questions:

  1. Is this a valid format for specifying the XSD file?

  2. Is there a way to tell Maven to use a single backslash instead of double backslashes?

The environment variable
. The
doesn't have any special configuration other than specifying the files that are to be included with filtering turned on.


This behaviour is controlled by the escapeWindowsPaths attribute of the maven-resources-plugin, introduced in version 2.4. It defaults to true meaning that, by default, all back-slashes will be escaped, turning single \ into double \\.

Whether to escape backslashes and colons in windows-style paths.

Sample configuration to disable this: