在撰写本文时,正确的答案过去是,现在仍然是公认的答案。我无意窃取这种声誉,但我也不想再次编辑它,因为它有点过时了(例如链接到Codehaus),所以我基本上必须重写它,以便更新它。
这是一个基于Maven POM的
- 爪哇 8
- Maven Compiler 3.7.0
- 时髦 2.4.7
- Groovy Eclipse Compiler 2.9.3-01
- 时髦日食批次 2.4.15-01
- 龙目岛 1.16.20
它还包含Maven Central上找不到的最新Groovy Eclipse版本的插件存储库配置。
顺便说一句,我正在使用此设置进行Spock + Geb测试。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.scrum-master.testing</groupId>
<artifactId>my-artifact</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<version.groovy-eclipse-compiler>2.9.3-01</version.groovy-eclipse-compiler>
<version.groovy-eclipse-batch>2.4.15-01</version.groovy-eclipse-batch>
<version.lombok>1.16.20</version.lombok>
</properties>
<pluginRepositories>
<!-- Needed for latest Groovy Eclipse version -->
<pluginRepository>
<id>bintray</id>
<name>Groovy Bintray</name>
<url>https://dl.bintray.com/groovy/maven</url>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<!-- IMPORTANT -->
<useIncrementalCompilation>false</useIncrementalCompilation>
<encoding>${project.build.sourceEncoding}</encoding>
<!-- Use Groovy Eclipse Compiler -->
<compilerId>groovy-eclipse-compiler</compilerId>
<!--
Lombok agent needed for successful Maven compilation, see
https://github.com/groovy/groovy-eclipse/wiki/Groovy-Eclipse-Maven-plugin#project-lombok
-->
<compilerArguments>
<javaAgentClass>lombok.launch.Agent</javaAgentClass>
</compilerArguments>
<!-- Without this Lombok compilation fails -->
<fork>true</fork>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>${version.groovy-eclipse-compiler}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>${version.groovy-eclipse-batch}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${version.lombok}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>${version.groovy-eclipse-compiler}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.7</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${version.lombok}</version>
</dependency>
</dependencies>
</project>
在Groovy-Eclipse wiki的龙目岛部分阅读更多关于这个主题的信息。