我正在尝试编写测试并使用groovy特性特性。
这是我的gmaven插件配置
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.5</version>
<configuration>
<debug>false</debug>
<verbose>true</verbose>
<stacktrace>true</stacktrace>
<providerSelection>2.0</providerSelection>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>generateStubs</goal>
<goal>testCompile</goal>
<goal>generateTestStubs</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
</plugin>我的特点是:
trait UserTrait {
String generateCrossId(){
System.currentTimeMillis().toString()
}
String generateOuterKey(){
(System.currentTimeMillis() / new Random().nextInt(1000)) as String
}
}这是我的考试课:
class UserToCrossIdConnectionTest extends IntegrationBaseTest implements UserTrait{}我试图用maven编译这个东西,我得到了:
INFO] --- maven-compiler-plugin:3.0:testCompile (default-testCompile) @ project ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 21 source files to /project/target/test-classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /project/target/generated-sources/groovy-stubs/test/ru/mycode/UserControllerTest.java:[12,33] interface expected here
[ERROR] /project/target/generated-sources/groovy-stubs/test/ru/mycode/UserToCrossIdConnectionTest.java:[12,33] interface expected here
[INFO] 2 errors 我查过课程了。特点变成:
@groovy.transform.Trait() public class UserTrait
extends java.lang.Object implements
groovy.lang.GroovyObject {}以及实现特性的类:
public class UserToCrossIdConnectionTest
extends IntegrationBaseTest implements
ru.mycode.UserTrait {这是公平的,我不能执行课程。我怎么才能修好它?
发布于 2015-02-24 13:58:15
GMaven无法编译更新版本的Groovy。我建议迁移到GMavenPlus (我刚刚根据您的示例成功地测试了它)。
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<goals>
<goal>addSources</goal>
<goal>addTestSources</goal>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>testGenerateStubs</goal>
<goal>testCompile</goal>
<goal>removeStubs</goal>
<goal>removeTestStubs</goal>
</goals>
</execution>
</executions>
</plugin>因为我是GMavenPlus的作者(我还维护了一段时间的GMaven ),老实说,还有Groovy-用于Maven的Eclipse编译器插件。我试着帮助人们理解他们的选择,这里。
https://stackoverflow.com/questions/28003992
复制相似问题