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

时间:2016-01-04 16:28:16

标签: java xml maven xsd maven-resources-plugin

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

func share(sender: UIBarButtonItem) {
    let masterpiece = canvas.snapshotViewAfterScreenUpdates(true)
    let image = snapshot(masterpiece)

    UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil)
}

func snapshot(masterpiece: UIView) -> UIImage{
    UIGraphicsBeginImageContextWithOptions(masterpiece.bounds.size, false, UIScreen.mainScreen().scale)
    masterpiece.drawViewHierarchyInRect(masterpiece.bounds, afterScreenUpdates: true)
    let image = UIGraphicsGetImageFromCurrentImageContext()
    UIGraphicsEndImageContext()
    return image

}

除了一件事情之外 - 取代路径有双反斜杠而不是一个黑色斜杠,例如:

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

所以有两个问题:

  1. 这是指定XSD文件的有效格式吗?
  2. 有没有办法告诉Maven使用单个反斜杠而不是双反斜杠?
  3. 环境变量<root xsi:noNamespaceSchemaLocation="C:\\mypath\\myschema.xsd" ...> myxsdpathC:\mypath\myschema.xsd除了指定打开过滤时要包含的文件外,没有任何特殊配置。

1 个答案:

答案 0 :(得分:9)

此行为由版本2.4中引入的escapeWindowsPathsmaven-resources-plugin属性控制。它默认为true,这意味着默认情况下,所有反斜杠都将被转义,将单\转换为双\\

  

是否在Windows风格的路径中转义反斜杠和冒号。

禁用此功能的示例配置:

<plugin>
  <artifactId>maven-resources-plugin</artifactId>
  <version>2.7</version>
  <configuration>
    <escapeWindowsPaths>false</escapeWindowsPaths>
  </configuration>
</plugin>