I've spent some time to migrate my project written in Groovy to Java 10. Now it's possible to compile and run it. But still it doesn't use any benefits of Java 9 modularity.
Googling about Groovy and Java 9 modules gives almost nothing.
So is it possible to migrate Groovy project to use JDK 10 with Project Jigsaw modules?
Well, after a few days of experiments I come up with the answer - yes, it is possible to use Groovy with Project Jigsaw modules.
But it needs some additional effort.
Let's say we have following file structure:
module-info.java
Application.groovy
First of all we need to compile module-info.java file with javac instead of compiling all files using groovyc because groovy treats module file as closure.
Let's do it:
--module-path will include our groovy.all.jar as automatic module with name derived from JAR-file name.
Next we need to compile Application.groovy
It goes smoothly.
After compilation we have module-info.class (aka module descriptor) and Application.class.
Now let's try to run our compiled module.
And this is what we get
And what does it mean? I don't know. After a lot of googling I found something similar.
So we need to manually remove from JAR these files:
Finally our Java module is able to start
All manipulations were done using Oracle JDK 10 and Groovy 2.4.15.