views:

52

answers:

1

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?

+3  A: 

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>
seanizer
Thanks a lot. Works.
Gábor Lipták
Oh hell. I dont even know what the hell happened, but I started to receive error for exactly the same stuff you suggested: [INFO] groovy.lang.MissingMethodException: No signature of method: java.io.File.absolutePath() is applicable for argument types: () values: []. Nothing is changed and not working anymore
Gábor Lipták
my mistake. it's either `absolutePath` without parentheses or `getAbsolutePath()`. fixed my code
seanizer
yep. Now it works. Then the only thing I dont know, how it was look like working earlier :D. But anyway, thanks.
Gábor Lipták
Really nice way to hack the POM. +1
Pascal Thivent