Java – how to convert file delimiters in maven
•
Java
I have an attribute defined as follows:
<properties>
<main.basedir>${project.parent.basedir}</main.basedir>
</properties>
Since I use windows as the operating system, it contains backslashes I want to add this path to the GlassFish domain as a JVM option (using the GlassFish Maven plug-in) The problem is that asadmin can use only slashes as separators, and all backslashes disappear How do I use slashes to define attributes with exactly the same content?
Solution
I don't think there is a non - procedural way to do this So I suggest a groovy front line and maven gmaven plugin (gmaven is usually the easiest way to embed programming code into 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>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
