Search code examples
javamavengroovy

Running groovy-maven-plugin within POM packaged project


I want to run groovy scripts as part of parent POM which has POM packaging. I set maven-groovy-plugin configured as follows:


<groupId>org.sct</groupId>
<artifactId>app-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>app</name>
<modules>
    <module>module1</module>
    <module>module2</module>
    <module>module3</module>
</modules>
...
<plugin>
    <groupId>org.codehaus.gmaven</groupId>
    <artifactId>groovy-maven-plugin</artifactId>
    <version>2.1.1</version>
    <executions>
        <execution>
            <phase>install</phase>
            <goals>
                <goal>execute</goal>
             </goals>
        </execution>
    </executions>
    <configuration>
        <source>${project.basedir}/src/test/groovy/check-xsl-id.groovy</source>
    </configuration>
</plugin>
...

However the script is not executed during the build. If I run the goal individually mvn groovy:execute it works fine.

How can I bind plugin execution to a POM packaging phase?


Solution

  • Using <plugin> instead of <pluginManagement> for plugin configuration works perfectly well.