Failure when specifying java compiler for groovycompile in Gradle 1.6

I need to specify the Java compiler used when compiling Groovy code. The Java version used to execute the build scripts may not be the version I want for compiling the sources.

For java code, I can setExecutable on the CompileOptions. And it works fine.

But for groovycompile, I get the below error, if I try to setExecutable on the java compileoptions.

Fortunately, I can set useAnt=true on groovycompile’s options to make it work. But useAnt is deprecated… :frowning:

Platform: Windows7, using Java6 for running Gradle.

Starting Gradle compiler daemon with fork options DaemonForkOptions{minHeapSize=null, maxHeapSize=null, jvmArgs=[], classpath=[C:\udvikler\ws\e43-dev\jb.jbit.im.tools.system.java\build\gen-lib\groovy-all-1.7.10-jb2.jar, C:\udvikler\tools\gradle\1.6-jb-1\lib\ant-1.8.4.jar, C:\udvikler\tools\gradle\1.6-jb-1\lib\ant-launcher-1.8.4.jar]}. Starting process ‘Gradle Worker 1’. Working directory: C:\udvikler\ws\e43-dev\jb.jbit.im.tools.system.java Command: C:\udvikler\tools\oracle-jdk\1.7.0_21\bin\java.exe -Dfile.encoding=windows-1252 -cp C:\udvikler\tools\gradle\1.6-jb-1\lib\gradle-base-services-1.6.jar;C:\udvikler\tools\gradle\1.6-jb-1\lib\gradle-core-1.6.jar;C:\udvikler\tools\gradle\1.6-jb-1\lib\gradle-cli-1.6.jar;C:\udvikler\tools\gradle\1.6-jb-1\lib\gradle-native-1.6.jar;C:\udvikler\tools\gradle\1.6-jb-1\lib\gradle-messaging-1.6.jar;C:\udvikler\tools\gradle\1.6-jb-1\lib\slf4j-api-1.7.2.jar;C:\udvikler\tools\gradle\1.6-jb-1\lib\logback-classic-1.0.9.jar;C:\udvikler\tools\gradle\1.6-jb-1\lib\logback-core-1.0.9.jar;C:\udvikler\tools\gradle\1.6-jb-1\lib\jul-to-slf4j-1.7.2.jar org.gradle.process.internal.launcher.GradleWorkerMain An attempt to initialize for well behaving parent process finished. Successfully started process ‘Gradle Worker 1’ Started Gradle compiler daemon with fork options DaemonForkOptions{minHeapSize=null, maxHeapSize=null, jvmArgs=[], classpath=[C:\udvikler\ws\e43-dev\jb.jbit.im.tools.system.java\build\gen-lib\groovy-all-1.7.10-jb2.jar, C:\udvikler\tools\gradle\1.6-jb-1\lib\ant-1.8.4.jar, C:\udvikler\tools\gradle\1.6-jb-1\lib\ant-launcher-1.8.4.jar]}. Unexpected exception thrown. org.gradle.messaging.remote.internal.MessageIOException: Could not write message [ChannelMessage channel: org.gradle.api.internal.tasks.compile.daemon.CompilerDaemonServerProtocol, payload: [MethodInvocation method: execute()]] to ‘/127.0.0.1:49874’.

at org.gradle.messaging.remote.internal.inet.SocketConnection.dispatch(SocketConnection.java:115)

at org.gradle.messaging.remote.internal.hub.MessageHub$ConnectionDispatch.run(MessageHub.java:279)

at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

at java.lang.Thread.run(Thread.java:722) Caused by: java.io.NotSerializableException: org.gradle.api.internal.tasks.compile.CommandLineJavaCompiler

at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1180)

at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)

at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)

at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)

at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)

at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1362)

at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1170)

at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)

at org.gradle.messaging.remote.internal.Message.send(Message.java:29)

at org.gradle.messaging.serialize.kryo.JavaSerializer$JavaWriter.write(JavaSerializer.java:62)

at org.gradle.messaging.remote.internal.hub.MethodInvocationSerializer$MethodInvocationWriter.writeArguments(MethodInvocationSerializer.java:66)

at org.gradle.messaging.remote.internal.hub.MethodInvocationSerializer$MethodInvocationWriter.write(MethodInvocationSerializer.java:62)

at org.gradle.messaging.remote.internal.hub.MethodInvocationSerializer$MethodInvocationWriter.write(MethodInvocationSerializer.java:47)

at org.gradle.messaging.serialize.kryo.TypeSafeSerializer$2.write(TypeSafeSerializer.java:46)

at org.gradle.messaging.remote.internal.hub.InterHubMessageSerializer$MessageWriter.write(InterHubMessageSerializer.java:103)

at org.gradle.messaging.remote.internal.hub.InterHubMessageSerializer$MessageWriter.write(InterHubMessageSerializer.java:88)

at org.gradle.messaging.remote.internal.inet.SocketConnection.dispatch(SocketConnection.java:112)

… 5 more

Duh!

On second look, setting useAnt=true does avoid the exception, but does not allow setting compiler executable.

So it appears that it is not possible to specify a javac executable for compilation of groovy code with Gradle 1.6 :frowning:

This bug is already fixed in Gradle 1.7-rc-1 (see release notes).

Super! I’ll give it a spin.