Setting properties in maven using gmaven plugin

200 Views Asked by At

I am using gmaven-plugin to convert the maven user.name property to lower case. The plugin configuration looks like this

<plugin>
    <groupId>org.codehaus.groovy.maven</groupId>
    <artifactId>gmaven-plugin</artifactId>
    <version>1.0</version>
    <executions>
        <execution>
            <phase>validate</phase>
            <goals>
                <goal>execute</goal>
            </goals>
            <configuration>
                <source>
                    import org.apache.commons.lang.StringUtils

                    project.properties["user.id"] =
                    StringUtils.lowerCase(project.properties["user.name"])
                </source>
            </configuration>
        </execution>
    </executions>
</plugin>

I also have maven resource resource plugin to copy some resources in a filtered mode. The entry in the manifest.yml is :

- name: ${user.id}-app

And the maven resource plugin configuration is below

<plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <executions>
        <execution>
            <id>copy-context</id>
            <phase>package</phase>
            <goals>
                <goal>copy-resources</goal>
            </goals>
            <configuration>
                <outputDirectory>${project.basedir}/target</outputDirectory>
                <resources>
                    <resource>
                        <directory>src/main/resources</directory>
                        <filtering>true</filtering>
                        <include>manifest.yml</include>
                    </resource>
                </resources>
            </configuration>
        </execution>
    </executions>
</plugin>

My problem is that the ${user.id} is not replaced in the manifest.yml file. Any idea what I am doing wrong ?

The same property is also used in other plugins like maven-antrun-plugin and build-helper-maven-plugin etc. Everything gets replaced fine there. And things also work fine if I directly use ${user.name} in the manifest.yml or any other user defined property in the POM file. But I am looking for lower case. ${user.name} returns upper case.

Any other approache to achieve the same is also welcome.

0

There are 0 best solutions below