This is how I do it:
<plugin> <groupId>org.codehaus.gmavenplus</groupId> <artifactId>gmavenplus-plugin</artifactId> <dependencies> <dependency> <groupId>org.apache.groovy</groupId> <artifactId>groovy</artifactId> <version>4.0.22</version> </dependency> </dependencies> <configuration> <targetBytecode>11</targetBytecode> </configuration> <executions> <execution> <goals> <goal>addSources</goal> <goal>addTestSources</goal> <goal>compile</goal> <goal>compileTests</goal> </goals> </execution> </executions> </plugin> I’m using byte-code 11 since that is the latest backwards compatible. Tommy Svensson to...@natusoft.se Från: Jochen Theodorou <blackd...@gmx.org> Svara: users@groovy.apache.org <users@groovy.apache.org> Datum: 15 december 2024 at 19:11:05 Till: users@groovy.apache.org <users@groovy.apache.org> Ämne: Re: Groovy Compiler On 13.12.24 01:14, James Poli via users wrote: > Our company has upgraded to Groovy 4 and JDK 21. However, one platform > we support, MVS, only supports a JDK 8 runtime. > > When running a class compiled with Groovy 4, an exception results: > > ... java.lang.UnsupportedClassVersionError: JVMCFRE199E bad major > version 61.0 of class=..., the maximum supported major version is 52.0; > offset=6 > > Can we cross-compile or force Groovy to generate bytecodes that support > JDK 8? > > I appreciate any help you can provide. The problem is not only the bytecode version the compiler produces. It is also the class library in use and the Groovy runtime using that. You would need a bytecode level back porting tool like retro lambda... Or you go and change AsmClassGenerator und its supporting classes to produce JDK8 compatible code from the beginning... plus several places you would have to replace because Java8+ Sourcecode in Java is used. bye Jochen