Search code examples
mavengroovy

Groovy versions aligned (groovy-eclipse-* and groovy-all)


Part of our project is written in Groovy 2.3 and in Java 8. We would like to upgrade to JDK 17. First we would like to upgrade the Groovy version. So after that upgrade we still have JDK 8. Then we upgrade to JDK 17.

On the internet I see that the Groovy 3.0.8 is suitable for both JDK 8 and JDK17.

The question is: I see that there has been a change in lib locations. How can I use a stable version of Groovy that both supports JDK 8 and 17?

Update: is this the right way to go? See this Baeldung article.

In the build section we used (and ignore the version numbers):

<plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>${maven-compiler-plugin.version}</version>
    <configuration>
        <compilerId>groovy-eclipse-compiler</compilerId>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-eclipse-compiler</artifactId>
            <version>3.7.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-eclipse-batch</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-eclipse-batch</artifactId>
            <version>3.0.8-01</version>
        </dependency>
    </dependencies>
</plugin>

In the dependency section:

<dependency>
    <groupId>org.apache.groovy</groupId>
    <artifactId>groovy-all</artifactId>
    <version>3.0.15</version>
    <type>pom</type>
</dependency>

Normally I don't have any trouble with Maven lib versions, I know many proglangs, but Groovy is fairly new to me.

Can you help with choosing good lib versions? I got lost a bit ;-)


Solution

  • The Baeldung article specifies a coherent set of library versions. The project compiles.

    Be careful about the versions of which the batch and Groovy compiler should be equal.

    <dependency>
        <groupId>org.apache.groovy</groupId>
        <artifactId>groovy-all</artifactId>
        <version>3.0.8</version>
        <type>pom</type>
    </dependency>
    

    In the github linked to the article the extra is introduced before the maven-compiler-plugin. The tag is supposed to be mandatory.

    <build>
        <plugins>       
            <plugin>
                <groupId>org.codehaus.groovy</groupId>
                <artifactId>groovy-eclipse-compiler</artifactId>
                <version>${groovy-eclipse-compiler.version}</version>
                <extensions>true</extensions>
            </plugin>