gradle 指的是 java 6,尽管我的 java 家的目标是 java 8

gradle refers java 6 even though my java home is aim to java 8

我运行./gradlew clean build

我收到这个错误:

warning: [options] bootstrap class path not set in conjunction with -source 1.6

/Users/eladb/WorkspaceQa/java/UsersServer/src/test/java/linqmap/users/jms/UsersServerAccessPropUserNameTest.java:163: error: diamond operator is not supported in -source 1.6

        Map<String, String> properties = new HashMap<>();

                                                     ^

  (use -source 7 or higher to enable diamond operator)

1 error

1 warning

:compileTestJava FAILED



FAILURE: Build failed with an exception.



* What went wrong:

Execution failed for task ':compileTestJava'.

> Compilation failed; see the compiler error output for details.



BUILD FAILED

尽管我看到我的 java 家是 java 8.

我还需要在哪里配置 java 8 ?

➜ myServer  echo $JAVA_HOME      

/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home

我的gradle.build:

apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'jacoco'

sourceCompatibility = 1.8
version = '1.0'

repositories {
    mavenCentral()
    jcenter()
}

dependencies {
//
//    configurations.all*.exclude(group: 'com.sun.jersey', module: 'jersey-bundle')
//    configurations.all*.exclude(group: 'com.fasterxml.jackson.core', module:'jackson-databind')


    compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'

    compile 'com.google.inject:guice:4.0-beta5'
    compile 'com.sun.jersey:jersey-core:1.18.3'
    compile 'com.sun.jersey:jersey-client:1.18.3'

您似乎已经明确设置了源兼容性。

尝试添加:

sourceCompatibility = 1.8