I figured it out. It seems that Gradle completely ignores the sourceCompatibility & targetCompatibility properties as it relates to compiling Scala code.
I was able to get Kafka's Scala code to compile to Java 8 bytecode by adding the following to the build.gradle: ------------------------ tasks.withType(ScalaCompile) { scalaCompileOptions.useAnt = false scalaCompileOptions.additionalParameters = [ "-Ybackend:GenBCode", "-Ydelambdafy:method", "-target:jvm-1.8" ] sourceCompatibility = 1.8 targetCompatibility = 1.8 ------------------------ According to https://github.com/scala/make-release-notes/blob/2.11.x/experimental-backend.md : "-target:jvm-1.8 instructs the Scala compiler to generate classfiles of version 52 (the default is jvm-1.6, generating classfiles of version 50). This option is one of the requirements to enable emitting lambdas in Java 8 style." So unless you specify the above settings, it will by default compile all Scala code to Java 6 compatible bytecode. -Kyle On Sun, Apr 17, 2016 at 4:41 PM, Kyle B <kbi...@gmail.com> wrote: > Hello, > > I'm trying to build Kafka 0.9.0.1 using JDK8, so that it generates JDK8 > compatible class files. However, no matter what I try, it seems the class > files generated are for JDK6. I've tried setting sourceCompatibility > and targetCompatibility to 1.8 to no avail. > > ------------------------ > $ pwd > kafka-0.9.0.1-src > $ javac -version > javac 1.8.0_77 > $ diff build.gradle > 90c90,91 > < sourceCompatibility = 1.7 > --- > > sourceCompatibility = "1.8" > > targetCompatibility = "1.8" > 184a186,187 > > sourceCompatibility = "1.8" > > targetCompatibility = "1.8" > 254a258,259 > > sourceCompatibility = "1.8" > > targetCompatibility = "1.8" > $ ./gradlew -PscalaVersion=2.11.7 clean releaseTarGz -x signArchives > ... > $ file ./core/build/classes/main/kafka/common/TopicAndPartition.class > ./core/build/classes/main/kafka/common/TopicAndPartition.class: compiled > Java class data, version 50.0 (Java 1.6) > ------------------------ > > Is compiling Kafka to JDK8 compatible class files supported? Has anyone > done this successfully, and can tell me what I'm doing wrong? > > Thanks much, > > -Kyle >