Gradle 1.10 and Java8 / JDK8: invalid source release: 1.8

I have troubles building a Java 8 project on the command line with Gradle 1.10 - it works with Gradle 1.7

I can build the project in Netbeans, which also uses Gradle 1.10. Netbeans supports Java 8 better than Eclipse.

Why do I see the invalid source release: 1.8 error on the command line? And not in Netbeans.

Is an example source repository available?

I have added the build.gradle file below.

Edit: messing around with formatting.

~/bin/gradle-1.10/bin/gradle build --version

Gradle 1.10

Build time:

2013-12-17 09:28:15 UTC

Build number: none






Apache Ant™ version 1.9.2 compiled on July 8 2013




1.7.0_25 (Oracle Corporation 23.7-b01)


Linux 3.12.6-031206-generic amd64

------------- Build failure

~/bin/gradle-1.10/bin/gradle build

:salescloud-mobile:compileJava FAILED

FAILURE: Build failed with an exception.

  • What went wrong:

Execution failed for task ‘:salescloud-mobile:compileJava’.

invalid source release: 1.8

  • Try:

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


-------------- build.gradle

apply plugin: ‘application’

apply plugin: ‘java’

apply plugin: ‘maven’

apply plugin: ‘eclipse’

apply plugin: ‘idea’

apply plugin: ‘war’

mainClassName = ‘bla.bla.Start’

group = ‘bla.bla’

version = ‘1.0’

description = “”“salescloud-mobile”""

sourceCompatibility = 1.8

targetCompatibility = 1.8

repositories {


maven { url “” }

maven { url “” }



dependencies {

testCompile “junit:junit:4.11”

testCompile “org.hamcrest:hamcrest-all:1.1”

testCompile “org.mockito:mockito-core:1.9.0”

providedCompile “org.projectlombok:lombok:1.12.2”

providedCompile “org.eclipse.jetty:jetty-server:9.0.4.v20130625”

providedCompile “org.eclipse.jetty:jetty-webapp:9.0.4.v20130625”

providedCompile “org.eclipse.jetty:jetty-util:9.0.4.v20130625”


configurations {

all*.exclude group: ‘javassist’, module: ‘javassist’

all*.exclude group: ‘org.glassfish.web’, module: ‘javax.el’

all {

// SNAPSHOTs should not be checked every time

resolutionStrategy.cacheChangingModulesFor 0, ‘seconds’



war {

from(‘src/main/java’) {

include ‘**’

exclude ‘**/*.java’




You are trying to build Java 8 code with JDK 7. The easiest way to build with JDK 8 is to run Gradle with JDK 8.

Doh, my mistake - I feel embarrassed now. I was blind for that info when running --version. For some reason my Gradle 1.7 was resolving the default JAVA_HOME differently than Gradle 1.10.

Gradle 1.10 was behaving correctly, I had set the java on PATH to JDK8, but forgot to change JAVA_HOME.

Thank you.

but gradle 1.10 doesn’t work well with java8, right?

Write a comment…