How do I tell Gradle to use specific JDK version?

前端 未结 17 2175
时光取名叫无心
时光取名叫无心 2020-11-22 12:12

I can\'t figure out to get this working.

Scenario:

  • I have an application built with gradle
  • The application uses JavaFX

What I w

17条回答
  •  花落未央
    2020-11-22 12:37

    If you are using JDK 9+, you can do this:

    java {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    
    tasks.withType {
        options.compilerArgs.addAll(arrayOf("--release", "8"))
    }
    

    You can also see the following related issues:

    • Gradle: [Java 9] Add convenience method for -release compiler argument
    • Eclipse Plug-ins for Gradle: JDK API compatibility should match the sourceCompatibility option.

提交回复
热议问题