Question

I have working maven 2 setup which compiles jUnit tests written in groovy. Both java and groovy tests are located at /src/test/java

See a snapshot of the pom.xml

<plugin>
    <groupId>org.codehaus.gmaven</groupId>
    <artifactId>gmaven-plugin</artifactId>
    <version>1.3</version>
    <executions>
        <execution>
        <id>testCompile</id>
        <goals>
            <goal>testCompile</goal>
        </goals>
        <configuration>
            <sources>
                <fileset>
                    <directory>${pom.basedir}/src/test/java</directory>
                    <includes>
                        <include>**/*.groovy</include>
                    </includes>
                </fileset>
            </sources>
        </configuration>
        </execution>
    </executions>
</plugin>

<dependency>
    <groupId>org.codehaus.groovy</groupId>
    <artifactId>groovy</artifactId>
    <version>1.7.5</version>
    <scope>test</scope>
</dependency>

When I upgrade to plugin version 1.5 and groovy 2.1.0, */.groovy files are ignored. Has anybody met up with this problem?

Was it helpful?

Solution 2

Ok, this configuration works for maven 2.

<plugin>
    <groupId>org.codehaus.gmaven</groupId>
        <artifactId>gmaven-plugin</artifactId>
        <version>1.4</version>
        <configuration>
            <providerSelection>2.0</providerSelection>
            <sourceEncoding>UTF-8</sourceEncoding>
        </configuration>
        <executions>
            <execution>
                <goals>
                    <goal>testCompile</goal>
                </goals>
                <configuration>
                    <sources>
                        <fileset>
                            <directory>${pom.basedir}/src/test/java</directory>
                            <includes>
                                <include>**/*.groovy</include>
                            </includes>
                        </fileset>
                    </sources>
                </configuration>
            </execution>
        </executions>
</plugin>

<dependency>
    <groupId>org.codehaus.groovy</groupId>
    <artifactId>groovy</artifactId>
    <version>2.0.0</version>
    <scope>test</scope>
</dependency>

OTHER TIPS

I found this page https://confluence.atlassian.com/display/CLOVER/Compiling+Groovy+with+GMaven+plugin

Note that you must put your Groovy Classes and Tests under src/main/groovy and src/test/groovy respectively.

Following configuration based on that page seems to work:

        <!-- Groovy and Maven https://confluence.atlassian.com/display/CLOVER/Compiling+Groovy+with+GMaven+plugin -->
        <plugin>
            <groupId>org.codehaus.gmaven</groupId>
            <artifactId>gmaven-plugin</artifactId>
            <version>${gmaven.version}</version>
            <configuration>
                <providerSelection>2.0</providerSelection>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.codehaus.gmaven.runtime</groupId>
                    <artifactId>gmaven-runtime-2.0</artifactId>
                    <version>${gmaven.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-all</artifactId>
                    <version>${groovy.version}</version>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <goals>
                        <goal>generateStubs</goal>
                        <goal>compile</goal>
                        <goal>generateTestStubs</goal>
                        <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

And in dependencies of course

    <dependency>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy-all</artifactId>
        <version>${groovy.version}</version>
    </dependency>

And in properties

<properties>
    <gmaven.version>1.5</gmaven.version>
    <groovy.version>2.1.8</groovy.version>
</properties>

I experience the same problem, but downgrading to gmaven 1.4 solves the problem (using groovy-all 2.3.2)

First, each GMaven provider compiles against a particular version of Groovy, so there can be issues if Groovy breaks something with a point release. Second, GMaven is no longer maintained (that's why you don't see any providers for newer Groovy versions). I recommend switching to GMavenPlus or the Groovy-Eclipse compiler plugin for Maven.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top