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

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.



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 emilles