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.