In my maven project, I am currently mixing my Java code with some Groovy code. I use Groovy mainly to create beans at this point. Some of my Java code uses Groovy beans directly.
I configured the Maven Compiler plugin as follows: -
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <compilerId>groovy-eclipse-compiler</compilerId> <source>${jdk.version}</source> <target>${jdk.version}</target> </configuration> <dependencies> <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-eclipse-compiler</artifactId> <version>2.8.0-01</version> </dependency> <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-eclipse-batch</artifactId> <version>2.1.5-03</version> </dependency> </dependencies> </plugin>
When I run my test files using mvn test , it works fine.
However, when I run the test files directly from IntelliJ, by right-clicking the test file and running it, I get "can not find character" errors on Groovy beans. When I read the error log, IntelliJ uses the Java compiler to compile my project before running the test ... so the tests fail.
I can't figure out how to instruct IntelliJ to always use the Groovy compiler instead of the Java compiler.
What should I change in the SDK to use the Groovy compiler? I tried to add Groovy related JAR files, but I got other errors.

UPDATE 1: As suggested by @Seagull
I added the Groovy JAR in the Global Libraries section: -

When I executed the test file directly from IntelliJ, I get Groovy warnings and I still get the same error: -

Thanks.
java intellij-idea maven groovy
limc
source share