Spent some time during configuration Java projects to be tested via Groovy (just adding Groovy nature to Eclipse projects). Sure everything should be done in Maven and Eclipse must get Groovy nature via plugins.
My problem like in the most cases was reading fast (throw 3 lines) documentation, where each line is very important. After installing Groovy for eclipse and groovy m2e configuration for Eclipse eclipse started to work well and sync faceds from pom.xml plugin.
2. Tell to maven-compiler-plugin about Groovy:
3. Show to Eclipse: where are my Groovy sources:
My problem like in the most cases was reading fast (throw 3 lines) documentation, where each line is very important. After installing Groovy for eclipse and groovy m2e configuration for Eclipse eclipse started to work well and sync faceds from pom.xml plugin.
That is almost all
1. Add explicit dependency to maven to load Groovy version which you need
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.codehaus.groovy</groupId> | |
<artifactId>groovy-all</artifactId> | |
<version>${groovy.version}</version> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<build> | |
<plugins> | |
... | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<version>2.3.2</version> | |
<configuration> | |
<compilerId>groovy-eclipse-compiler</compilerId> | |
</configuration> | |
<dependencies> | |
<dependency> | |
<groupId>org.codehaus.groovy</groupId> | |
<artifactId>groovy-eclipse-compiler</artifactId> | |
<version>2.6.0-01</version> | |
</dependency> | |
</dependencies> | |
</plugin> | |
... | |
</plugins> | |
</build> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.codehaus.mojo</groupId> | |
<artifactId>build-helper-maven-plugin</artifactId> | |
<executions> | |
<execution> | |
<id>add-source</id> | |
<phase>generate-sources</phase> | |
<goals> | |
<goal>add-source</goal> | |
</goals> | |
<configuration> | |
<sources> | |
<source>src/main/groovy</source> | |
</sources> | |
</configuration> | |
</execution> | |
<execution> | |
<id>add-test-source</id> | |
<phase>generate-test-sources</phase> | |
<goals> | |
<goal>add-test-source</goal> | |
</goals> | |
<configuration> | |
<sources> | |
<source>src/test/groovy</source> | |
</sources> | |
</configuration> | |
</execution> | |
</executions> | |
</plugin> | |
</plugins> | |
</build> |
No comments:
Post a Comment