Gradle + Groovy + Spock + Windows == argh!


(Steven Dick) #1

I have a large Java-and-Groovy-based Gradle build that uses Spock for some of our tests. All was well until I added another project to the build, which then caused an unexpected build failure.

This failure is the dreaded command line length issue on Windows when forking groovyc. After a big of googling I found the workaround to set ‘fork=false’ for the Groovy compilation tasks. However this now causes Spock to fail, complaining that the Spock test classes haven’t had the AST transformations applied.

I’ve seen another comment from Peter Niederwieser that Groovy compiler plug-ins don’t work when running in-process.

Another workaround I’ve tried is to use a pathing JAR for the Groovy compilation and set ‘fork=true’ again. I just can’t get the pathing JAR to work - none of the dependencies are found. I found Peter’s answer on Stack Overflow, which I used as the basis for my workaround. I made all the paths on ‘Class-Path’ relative from the location of the pathing JAR, used / as the path separator and escaped any spaces in the paths (since it is an URL) with %20. No luck - none of the dependencies are found and there’s little evidence to go on as to what is wrong with this approach.

I’m now stuck between a rock and a hard place. I don’t currently know of any further workarounds I can try, which would leave me with the option of removing our use of Spock.


(Rolf Suurd) #2

The guys at groovy have been making issues for this: http://jira.codehaus.org/browse/GROOVY-5024

Related discussion: http://groovy.329449.n5.nabble.com/groovyc-ant-task-failure-with-a-long-classpath-td4751999.html

As a workaround, I have set GRADLE_USER_HOME to d:/tmp just to shorten to total classpath (from c:/users/[name]/.gradle/caches)

Another, not so cool, option could be to use gradle 1.0-milestone-3. This release doesn’t use the new cache mechanism, which adds lengthy SHA hashes to all cached jars, which should reduce the classpath length as well.


(Steven Dick) #3

I think all the workarounds are really messy and brittle, so decided to try the suggested patch on the Groovy issue. It’s looking good so far. Hoping this change makes it into an official Groovy 1.8.6 release soon.