How specify the required Java version in a Gradle build

后端 未结 4 950
长发绾君心
长发绾君心 2021-01-07 19:06

I would like to set in a Gradle build file the required Java version e.g. 7 or 8 without having to specify the actual path to a local JDK installation.

Is

4条回答
  •  孤独总比滥情好
    2021-01-07 19:34

    In the build.gradle file, add the following two lines:

    sourceCompatibility = '1.8'
    targetCompatibility = '1.8'
    

    The targetCompatibility defines the generated JVM bytecode version (this is the version that users of your application need). The sourceCompatibility defines which source code constructs are allowed (e.g. you need Java 1.8 or higher to use lambda expressions in source code).

    Source

提交回复
热议问题