Upgrade Groovy version to 1.8.9 to fix ConfigSlurper issue with Java 8


(Stefan Marklund) #1

Hello Gradle devs,

In my build I use the Groovy class ConfigSlurper. With Java 8 I run into issues with the ConfigSlurper class. I may have located the issue. The issue have been fixed as of Groovy 1.8.9 and I would suggest that the Groovy version distributed with Gradle is upgraded from its current 1.8.6 version.

Groovy Jiras ============ http://stackoverflow.com/questions/9625077/grails-application-failed-to-run-in-googleappengine-due-to-hashmapentry-classno http://jira.codehaus.org/browse/GROOVY-4950

Gradle Change Needed ==================== File: dependencies.gradle groovy: ‘org.codehaus.groovy:groovy-all:1.8.9@jar’

Tests:
======
cat > kalle.gradle
File file = new File("test.gradle")
def slurper = new ConfigSlurper().parse(file.text)
println "Status: " + slurper.ext.success
  cat > test.gradle
ext {
    success = 'success'
}
Groovy 1.8.6 (Gradle 1.11)
============
s@cft639:~/groovytest$ gradle -b kalle.gradle --no-daemon
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: http://gradle.org/docs/1.11/userguide/gradle_daemon.html.
Parallel execution is an incubating feature.
  FAILURE: Build failed with an exception.
  * Where:
Build file '/home/s/groovytest/kalle.gradle' line: 2
  * What went wrong:
A problem occurred evaluating root project 'groovytest'.
> [Ljava/util/HashMap$Entry;
  * Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  BUILD FAILED
  Total time: 5.529 secs
Groovy 1.8.9: Replaced groovy 1.8.6 with 1.8.9 jar
===================================================
s@cft639:~/groovytest$ gradle -b kalle.gradle --no-daemon
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: http://gradle.org/docs/1.11/userguide/gradle_daemon.html.
Parallel execution is an incubating feature.
Status: success
:help
  Welcome to Gradle 1.11.
  To run a build, run gradle <task> ...
  To see a list of available tasks, run gradle tasks
  To see a list of command-line options, run gradle --help
  BUILD SUCCESSFUL
  Total time: 3.64 secs
Groovy 1.8.9: Updated dependencies.gradle in gradle build and made a new distribution
=======================================================================
s@cft639:~/groovytest$ gradle -b kalle.gradle --no-daemon
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: http://gradle.org/docs/2.0-20140319132910+0000/userguide/gradle_daemon.html.
Parallel execution is an incubating feature.
Status: success
:help
  Welcome to Gradle 2.0-20140319132910+0000.
  To run a build, run gradle <task> ...
  To see a list of available tasks, run gradle tasks
  To see a list of command-line options, run gradle --help
  BUILD SUCCESSFUL
  Total time: 5.263 secs
s@cft639:~/groovytest$ gradle -v
  ------------------------------------------------------------
Gradle 2.0-20140319132910+0000
------------------------------------------------------------
Build time:
 2014-03-19 13:29:10 UTC
Build number: none
Revision:
   f8e103a0d0d2a8a888fb20e18777e96f06a5f86f
  Groovy:
     1.8.9
Ant:
        Apache Ant(TM) version 1.9.3 compiled on December 23 2013
Ivy:
        2.2.0
JVM:
        1.8.0 (Oracle Corporation 25.0-b70)
OS:
         Linux 3.5.0-17-generic amd64

The test script is working ok after updating to groovy-all-1.8.9.jar in the Gradle distribution.

What do you think about upgrading the Groovy version to 1.8.9?

Thank you, Stefan


(Peter Niederwieser) #2

As I’ve said before, we weren’t able to upgrade to Groovy 1.8.7/8/9 due to some regressions in these Groovy versions. Gradle 1.12 will still ship with Groovy 1.8.6, but Gradle 2.0 (which is the next version after 1.12) is set to ship with Groovy 2.x, which will hopefully solve your ‘ConfigSlurper’ problem.


(Kai Tödter) #3

Peter, I have the same issue with ConfigSlurper and Java 8. What would be the preferred way to parse configs using gradle 1.11 and Java 8?


(Peter Niederwieser) #4

I’m not familiar with the ConfigSlurper issue. If it’s a plain properties file, ‘java.util.Properties’ will do. Otherwise, using a Gradle build script instead of the config file might be an option (depending on what your needs are). Note that you don’t necessarily have to run Gradle with Java 8 in order to compile against Java 8, although that’s currently the simplest option.


(Luke Daley) #5

Another option would be to use GSON or Jackson.


(Stefan Marklund) #6

Thank you for the responses. Sorry Peter I never did search for old responses. However, now you are aware of an issue that you were not of before.

The reason I used the ConfigSlurper is that the configuration parameters can both be indexed with dot notation outside a build as well as ‘apply from:’ ed into a Gradle project. It’s straight Groovy syntax. It can come in handy.

The Slurper was fixed in Groovy 2.0.6 and 2.1 also according to the jira so it should be fixed with the Gradle 2.0 release.