Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace backslashes to slashes for ${basedir} property in maven profile profile

I have a pom.xml with defined property module.basedir that is intended to contain transformed basedir property. It is defined as follows:

<properties>
    <module.basedir>${basedir}</module.basedir>
</properties>

And I have following code that is executed using mgroovy plugin:

<source>
    println project.properties['module.basedir']
    project.properties['module.basedir']=project.properties['module.basedir'].replace('\\','/');
    println project.properties['module.basedir']
</source>

Later I use this property in other plugins. This works fine until I move plugin definitions into maven profile. And when maven profile is activated mgroovy plugin works fine, but when I access property in the next plugin I get unmodified value.

This is how I access this property:

${module.basedir}

It looks like that when profile is executed it creates own copies of properties defined in project and they are used when referenced from plugins.

Any suggestions?

like image 294
Igor Nikolaev Avatar asked Dec 04 '10 10:12

Igor Nikolaev


1 Answers

I faced with the same problem using gmaven-plugin on windows to create EJB module description. I'm not a savvy in Groovy, but this approach works for me:

def basedir = project.properties['module.basedir'].replace('\\','/')
def md = (basedir + "/target/module.xml" as File)
like image 68
ZeAL0T Avatar answered Sep 21 '22 11:09

ZeAL0T