[英]Escape property in pom.xml
我想在pom.xml中转义一个属性。 不是在资源中,我知道可以使用过滤器。 例如,我尝试使用launch4j插件,如下所示:
<plugin>
<groupId>org.bluestemsoftware.open.maven.plugin</groupId>
<artifactId>launch4j-plugin</artifactId>
<executions>
<execution>
<id>l4j-cli</id>
<phase>install</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<headerType>console</headerType>
<outfile>../out.exe</outfile>
<dontWrapJar>true</dontWrapJar>
<jar>./../out.jar</jar>
<icon>../icon.ico</icon>
<chdir>.</chdir>
<customProcName>true</customProcName>
<downloadUrl>http://www.oracle.com/technetwork/java/javase/downloads/index.html</downloadUrl>
<classPath>
<mainClass>com.stack.Main</mainClass>
<addDependencies>true</addDependencies>
<jarLocation>./lib</jarLocation>
</classPath>
<jre>
<opts>
<opt>-DconfigBasePath=${ALLUSERSPROFILE}/dir</opt>
</opts>
</jre>
</configuration>
</execution>
</executions>
</plugin>
并且$ {ALLUSERSPROFILE}不能由maven解释,而是由launch4j生成的程序。 我尝试:
\${ALLUSERSPROFILE}
\\${ALLUSERSPROFILE}
$${ALLUSERSPROFILE}
和
<properties>
<dollar>$</dollar>
</properties>
${dollar}{ALLUSERSPROFILE}
但没什么用。
$$
使用${surefire.forkNumber}
为我工作。
当我想通过使用pom属性值'$ {user.home}'解析密钥'$ {log4j.dir}'来过滤我的log4j.properties文件时,我添加了相同的问题。
$$ {key} hack和$ {dollar} {key} hack都没有为我工作。 我终于设法使用HEXA表示法为pom属性中的$ char。
<project>
<properties>
<log4j.dir>\u0024{user.home}</log4j.dir>
</properties>
<!--...-->
</project>
对于pom.xml
真正转义,你运气不好。
上面的一些答案引用了Surefire插件,它使用自己的语法进行转义。 那不是一回事。
Maven的资源过滤使用自己的机制转义。 那不是一回事。
如果你只需要打印一些东西,你可以使用零宽度空间unicode字符 ,如下所示:
$​{somePomProperty}
这将呈现为:
$ + zero-width-space + { + somePomProperty + }
并且至少看起来是正确的。
以下从上面的线程稍加修改为我工作:
<properties>
<dollar>$</dollar>
<dollar.bloop>${dollar}{bloop}</dollar.bloop>
</properties>
$$
。 我真的希望编辑没有红色的曲线。 \$
的反斜线进行通过,并且在任何时候用$代替。 YMMV我想。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.