Groovy Maven Plugins

1.1k views Asked by At

I am trying to run Spock tests and perhaps some Groovy scripts, currently for a Groovy app, but in future for Java projects as well.

I am really confused about which plugins should be used and how to best configure them, aka least amount of code.

I found numerous articles showing Maven XML settings for gmaven-plugin, gmaven-runtime and groovy-eclipse plugin, which seems like it works under IDEA as well. I have been using Eclipse for a while and now am trying out IDEA Community Edition. One of the confusions stems from the fact that I was able to add following dependency to my POM, in addition to having Gmaven in section.

<dependency>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.5</version>
</dependency>

I understand that the question is a bit vague... but so is documentation on the matter :)

1

There are 1 answers

6
MariuszS On BEST ANSWER

For fully Maven-Groovy projects read this post Building your Groovy 2.0 projects with Maven


I have sample project with Maven, Java and Spock tests. There is one requirement here. Spock tests needs to have names like FooTest.groovy.

My configuration looks like this

<plugin>
    <groupId>org.codehaus.gmaven</groupId>
    <artifactId>gmaven-plugin</artifactId>
    <version>1.5</version>
    <configuration>
        <providerSelection>2.0</providerSelection>
        <source/>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>testCompile</goal>
            </goals>
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>org.codehaus.gmaven.runtime</groupId>
            <artifactId>gmaven-runtime-2.0</artifactId>
            <version>1.5</version>
            <exclusions>
                <exclusion>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-all</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>2.2.1</version>
        </dependency>
    </dependencies>
</plugin>

Fully working project is here: https://github.com/mariuszs/java-spock-test-sample