Skip to: Site menu | Main content

Groovy 

      Download | Documentation | Developers | Community

An agile dynamic language for the Java Platform

Groovy Maven Plugin Add comment to Wiki View in Wiki Edit Wiki page Printable Version

MOVED

This content has been moved to GMaven. Please update your links, this page will go away in the near future.

Groovy Maven Plugin

Description

Allows Groovy scripts to be used from within the Maven 2 environment and Maven 2 plugins to be implemented in Groovy!

Current release: 1.0-beta-3

What is New

With this release comes a completely rewritten core, which allows the Groovy runtime version to be changed. Also a brand new stub-generator that preserves Javadocs (so the standard maven-javadoc-plugin works with it). And a org.codehaus.mojo:groovy-maven-plugin has been crafted to provided a link to the org.codehaus.mojo.groovy:groovy-maven-plugin, which means that mvn groovy:shell works!

For more details see the changelog.

Please make sure you are using the org.codehaus.mojo.groovy groupId in your projects and that you are looking at the latest site docs for the current documentation.

Execute a Groovy Script

<plugin>
    <groupId> org.codehaus.mojo.groovy</groupId>
    <artifactId>groovy-maven-plugin</artifactId>
    <executions>
        <execution>
            <phase>generate-resources</phase>
            <goals>
                <goal>execute</goal>
            </goals>
            <configuration>
                <source>
                    if (project.packaging != "pom") {
                        log.info("Copying some stuff...")
                        def dir = "${project.basedir}/target/classes/META-INF"

                        ant.mkdir(dir: dir)
                        ant.copy(todir: dir) {
                            fileset(dir: "${project.basedir}") {
                                include(name: "LICENSE.txt")
                                include(name: "NOTICE.txt")
                            }
                        }
                    }
                </source>
            </configuration>
        </execution>
    </executions>
</plugin>

For more details see the executing examples.

Compile Groovy Sources

<plugin>
    <groupId> org.codehaus.mojo.groovy</groupId>
    <artifactId>groovy-maven-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>compile</goal>
            </goals>
        </execution>
    </executions>
</plugin>

And test sources too:

<plugin>
    <groupId>org.codehaus.mojo.groovy</groupId>
    <artifactId>groovy-maven-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>testCompile</goal>
            </goals>
        </execution>
    </executions>
</plugin>

For more details more see the compiling examples.

References