我有工作maven 2设置,它编译用groovy编写的jUnit测试。 java和groovy测试都位于/ src / test / java
查看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>
当我升级到插件版本1.5和groovy 2.1.0时,* / .groovy文件被忽略。有没有人遇到过这个问题?
答案 0 :(得分:4)
我找到了这个页面https://confluence.atlassian.com/display/CLOVER/Compiling+Groovy+with+GMaven+plugin
请注意,您必须将Groovy类和测试分别放在src/main/groovy
和src/test/groovy
下。
基于该页面的以下配置似乎有效:
<!-- 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>
当然还有依赖
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>${groovy.version}</version>
</dependency>
在属性中
<properties>
<gmaven.version>1.5</gmaven.version>
<groovy.version>2.1.8</groovy.version>
</properties>
答案 1 :(得分:1)
好的,这个配置适用于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>
答案 2 :(得分:1)
我遇到同样的问题,但降级到gmaven 1.4解决了问题(使用groovy-all 2.3.2)
答案 3 :(得分:0)
首先,每个GMaven提供程序都针对特定版本的Groovy进行编译,因此如果Groovy破坏点发布,可能会出现问题。其次,不再维护GMaven(这就是为什么你没有看到任何新的Groovy版本的提供商)。我建议切换到GMavenPlus或Groovy-Eclipse compiler plugin for Maven。