1

I wanted to compile groovy along with java sources so I added groovy-eclipse-compiler to pom.xml but I got an error:

Groovy-Eclipse: source level should be in '1.1'...'1.8','9'...'15' (or '5.0'..'15.0'): 17

pom.xml as follows:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.app</groupId>
    <artifactId>mb2g-alt-jvm</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>17</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy</artifactId>
            <classifier>indy</classifier>
            <version>3.0.10</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version><!-- 3.6.2 is the minimum -->
                <configuration>
                    <compilerId>groovy-eclipse-compiler</compilerId>
                    <compilerArguments>
                        <indy/><!-- optional; supported by batch 2.4.12-04+ -->
                        <configScript>config.groovy</configScript><!-- optional; supported by batch 2.4.13-02+ -->
                    </compilerArguments>
                    <failOnWarning>true</failOnWarning><!-- optional; supported by batch 2.5.8-02+ -->
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.codehaus.groovy</groupId>
                        <artifactId>groovy-eclipse-compiler</artifactId>
                        <version>3.7.1</version>
                    </dependency>
                    <dependency>
                        <groupId>org.codehaus.groovy</groupId>
                        <artifactId>groovy-eclipse-batch</artifactId>
                        <version>3.0.10-02</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

    <pluginRepositories>
        <pluginRepository>
            <id>groovy-plugins-release</id>
            <url>https://groovy.jfrog.io/artifactory/plugins-release</url>
        </pluginRepository>
    </pluginRepositories>

</project>

Intellij Java Compiler Version: Java 17

Module Language Level: Java 17

Error Screenshot : enter image description here

How can I solve it? Thank you.

Veysel Öz
  • 95
  • 11

2 Answers2

3

Groovy 3 does not suitably support Java 16+ and so groovy-eclipse-batch is currently capped at Java 15. You can set release (aka java.version in you pom) to 15 as indicated in the error message.

Or you can split Java and Groovy compilation in maven so you can set separate release targets.

emilles
  • 1,104
  • 7
  • 14
  • am stuck with the same issue. Is there any other upgrade to this plugin that takes care of Java-17 also ? – Arun Mar 20 '23 at 12:15
  • @Arun Not sure what you're stuck on. You can use groovy-eclipse-batch 3.0.17-02 to run your compiler process with Java 17 and to target Java 17 as well. You can also use Groovy 4 versions of all these dependencies to work with up to Java 20. – emilles Mar 28 '23 at 23:57
  • @emiles org.eclipse.aether.transfer.ArtifactNotFoundException: org.codehaus.groovy:groovy-eclipse-batch:jar:3.0.17-02 was not found in https://repo.maven.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not – RoutesMaps.com Apr 06 '23 at 12:30
  • @emilles - The version is not available in public maven repository. I then downloaded from the JFrog repo where it is available and then uploaded in to my own repository. – Arun Apr 06 '23 at 12:42
0

You can use last Groovy version for last java version. Look instructions for Maven here: Groovy Eclipse Maven plugin

RoutesMaps.com
  • 1,628
  • 1
  • 14
  • 19