Play plugin can't handle java 8 source files

Using Java 8 features in a play project causes the following error:

$ gradle runPlayBinary
:createPlayBinaryAssetsJar
:routesCompileRoutesSourcesPlayBinary
:twirlCompileTwirlTemplatesPlayBinary
:scalaCompilePlayBinary FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':scalaCompilePlayBinary'.
> Unknown constant: 18

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

To reproduce, clone the repo at https://github.com/khernyo/gradle-play-java8-bug (I’m not allowed to upload a file here…) and run:

gradle runPlayBinary

Please note that there is no such problem in an ordinary java/scala mixed project, so I’m guessing that an old sbt is used for compiling play projects.

I’m using Gradle version 2.5

Thanks for the reproducible example. I think you’re right and this is related to the version of the sbt libraries that the Zinc compiler pulls in. We’re currently using an older version of Zinc (0.3.0) and upgrading to the latest (0.3.7) seems to fix the issue. We’ll look at getting this rolled into Gradle 2.6.

Not that it’s much of a workaround, but I did notice that the compile succeeds on the second run - this error only seems to bite on a clean build.

I’ve opened GRADLE-3319 to track this.