问题描述
我有一个像这样定义的属性:
< properties>
< main.basedir> $ {project.parent.basedir}< /main.basedir>
< / properties>
由于我使用Windows作为操作系统,它包含反斜杠。我想将此路径添加到glassfish域作为JVM选项(使用glassfish maven插件)。问题是,asadmin只能使用斜线作为分隔符,并且所有反斜杠都会消失。我怎么能定义一个与斜线完全相同的属性?
我不认为有一个非程序性的方法来做到这一点。所以我建议您使用进行一次简单的练习(GMaven通常是最简单的将程序代码嵌入到pom中): < plugin>
< groupId> org.codehaus.gmaven< / groupId>
< artifactId> gmaven-plugin< / artifactId>
<执行次数>
<执行>
< id> setproperty< / id>
<阶段>验证< /阶段>
<目标>
< goal>执行< / goal>
< /目标>
<配置>
< source>
pom.properties ['main.basedir'] = project.parent.basedir.absolutePath.replace('\\','/');
< / source>
< / configuration>
< /执行>
< /执行次数>
< / plugin>
I have a property defined like this:
<properties>
<main.basedir>${project.parent.basedir}</main.basedir>
</properties>
Since I use Windows as OS, it contains backslashes. I want to add this path to a glassfish domain as JVM option (using glassfish maven plugin). The problem is, that asadmin can consume only slash as separator, and all my backslashes keep on disappearing. How can I define a property with exactly the same content with slashes?
I don't think there is a non-programmatical way to do that. So I suggest a groovy one-liner with the Maven GMaven plugin (GMaven is usually the simplest way to embed programmatic code into a pom):
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<executions>
<execution>
<id>setproperty</id>
<phase>validate</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
pom.properties['main.basedir']=project.parent.basedir.absolutePath.replace('\\','/');
</source>
</configuration>
</execution>
</executions>
</plugin>
这篇关于如何转换maven中的文件分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!