groovy / GMavenPlus

A rewrite of GMaven, a Maven plugin for Groovy
Other
282 stars 35 forks source link

Groovy 2.4.21 and JDK 11 #260

Closed jcrben closed 1 year ago

jcrben commented 1 year ago

I'm currently using this successfully https://github.com/jenkinsci/JenkinsPipelineUnit 1.14 but I want to upgrade to 1.19. The new version requires JDK 11.

After bumping to 1.19 and bumping the target byte code to 11

<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>

I see this:

[INFO] Using Groovy 2.4.21 to perform generateTestStubs.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.638 s
[INFO] Finished at: 2023-08-14T23:11:49-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.gmavenplus:gmavenplus-plugin:3.0.0:generateTestStubs (groovy) on project cicd-pipeline-shared: Execution groovy of goal org.codehaus.gmavenplus:gmavenplus-plugin:3.0.0:generateTestStubs failed: Target bytecode 11 requires Groovy 2.5.3/3.0.0-alpha-4 or newer. No 2.6 version is supported. -> [Help 1]

Keep in mind that the pom.xml for the JenkinsPipelineUnit contains

</dependency>
      <dependency>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy-all</artifactId>
        <version>2.4.21</version>
        <scope>runtime</scope>
      </dependency>
<dependency>

which is why it's using Groovy 2.4.21

I noticed https://github.com/groovy/GMavenPlus/issues/256 which makes me think maybe 2.4.21 should be supported?

This project is work-related but I can come up with a sanitized version if you don't see anything off the top of your head.

I tried versions 1.13.1 2.1.0 and 3.0.0 of gmavenplus

keeganwitt commented 1 year ago

Here's the code in Groovy: https://github.com/apache/groovy/blob/GROOVY_2_4_X/src/main/org/codehaus/groovy/control/CompilerConfiguration.java

As you can see, there's nothing about Java 11 bytecode in Groovy 2.4. The code in GMavenPlus accurately reflects Groovy's support of bytecode versions.

keeganwitt commented 1 year ago

I think you've misunderstood their note. It says

JenkinsPipelineUnit requires Java 11, since this is also the minimum version required by Jenkins.

I think this means that it requires Java 11 as the runtime (since Jenkins itself needs to run on Java 11). It doesn't require code to be compiled to Java 11 bytecode.

jcrben commented 1 year ago

Thanks, that advice helped. I set up a system using maven-toolchains-plugins to compile with java 8 and run the surefire tests on jdk 11. Thanks 😄