1
我正在用Maven程序集插件2.4過濾一些配置文件,並得到了在.bat文件中,當值包含冒號時文字反斜槓不能轉義的問題。Maven程序集插件:當冒號存在時不過濾轉義反斜線
的pom.xml:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<filters>
<filter>src/assembly/filter.properties</filter>
</filters>
<descriptors>
<descriptor>src/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
</plugin>
filter.properties:
#Double (escaped) backslashes
testPath1 = a\\b\\c
testPath2 = c:\\test
#testPath3 contains no colon
testPath3 = c\\test
test.bat的:
REM ${testPath1}
REM ${testPath2}
REM ${testPath3}
test.properties:
path1=${testPath1}
path2=${testPath2}
path3=${testPath3}
assembly.xml:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>distribution</id>
<formats><format>zip</format></formats>
<files>
<file>
<source>${basedir}/src/assembly/testBat.bat</source>
<outputDirectory>/</outputDirectory>
<filtered>true</filtered>
</file>
<file>
<source>${basedir}/src/assembly/testProp.properties</source>
<outputDirectory>/</outputDirectory>
<filtered>true</filtered>
</file>
</files>
</assembly>
並且這產生...
testBat.bat(所有的反斜線了逃脫):
REM a\b\c
REM c:\test\path
REM c\test\path
testProp.properties(在路徑2反斜槓沒有逃脫如預期!!!):
path1=a\b\c
path2=c:\\test\\path
path3=c\test\path
任何人都知道這是某種特殊功能,或其實是一個錯誤? :)