如何使用eclipse编译器插件使gradle支持java10?

uwopmtnx  于 2021-07-06  发布在  Java
关注(0)|答案(0)|浏览(296)

我有以下几点 build.gradle 构建具有java10语法的java项目( var 关键字)使用eclipse编译器插件

group 'com.test.j10'
version '1.0-SNAPSHOT'

apply plugin: 'java'

repositories {
    mavenCentral()
}

dependencies {
    testImplementation group: 'junit', name: 'junit', version: '4.12'
}

tasks.withType(JavaCompile) {
    options.headerOutputDirectory.convention(null)
}

wrapper {
    gradleVersion = '6.7'
}

sourceCompatibility = JavaVersion.VERSION_1_10
targetCompatibility = JavaVersion.VERSION_1_8

buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath "gradle.plugin.de.set.gradle:gradle-eclipse-compiler-plugin:1.4.1"
    }
}

apply plugin: "de.set.ecj"

但我有以下例外

> Task :compileJava FAILED
source level should be comprised in between '1.3' and '1.9' (or '5', '5.0', ..., '9' or '9.0'): 1.10

FAILURE: Build failed with an exception.

* What went wrong:

Execution failed for task ':compileJava'.
> Process 'command '/home/user392919/installs/java/adoptopenjdk/jdk8u272-b10/bin/java'' finished with non-zero exit value 255

但是根据gradle的6.7api,它支持java10。也是我的 ./gradlew -v 显示为gradle版本6.7。所以不知道为什么会失败。
我补充说

tasks.withType(JavaCompile) {
    options.headerOutputDirectory.convention(null)
}

到我的build.gradle来解决这个gradle问题。
我是一个全新的grad尔,所以如果我在这里犯了一些根本的错误,请足够善良的纠正我
谢谢您!

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题