使用maven-resources-plugin过滤时如何阻止反斜杠被转义?

时间:2022-06-01 18:35:34

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

我想使用Maven Resources Plugin在XML资源文件中设置XML模式位置:

<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. 这是指定XSD文件的有效格式吗?
  3. Is there a way to tell Maven to use a single backslash instead of double backslashes?
  4. 有没有办法告诉Maven使用单个反斜杠而不是双反斜杠?

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.

环境变量myxsdpath是C:\ mypath \ myschema.xsd。 maven-resources-plugin没有任何特殊配置,除了指定打开过滤时要包含的文件。

1 个解决方案

#1


9  

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

此行为由版本2.4中引入的maven-resources-plugin的escapeWindowsPaths属性控制。它默认为true意味着默认情况下,所有反斜杠都将被转义,将单个\转换为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>

#1


9  

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

此行为由版本2.4中引入的maven-resources-plugin的escapeWindowsPaths属性控制。它默认为true意味着默认情况下,所有反斜杠都将被转义,将单个\转换为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>