Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 myxsdpath is C:\mypath\myschema.xsd. The maven-resources-plugin doesn't have any special configuration other than specifying the files that are to be included with filtering turned on.

like image 582
Steve Chambers Avatar asked Jan 06 '23 21:01

Steve Chambers


1 Answers

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:

<plugin>
  <artifactId>maven-resources-plugin</artifactId>
  <version>2.7</version>
  <configuration>
    <escapeWindowsPaths>false</escapeWindowsPaths>
  </configuration>
</plugin>
like image 66
Tunaki Avatar answered Feb 04 '23 16:02

Tunaki