我正在尝试使用 openjdk 14 运行 gradle 6.3 构建,目标是 java 14。我收到以下错误。我知道这与编译文件的版本有关,但我的理解是 gradle 6.3 支持 java 14。
$ ./gradlew build
> Task :shadowJar FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':shadowJar'.
> Unsupported class file major version 58
$ ./gradlew -v
------------------------------------------------------------
Gradle 6.3
------------------------------------------------------------
Build time: 2020-03-24 19:52:07 UTC
Revision: bacd40b727b0130eeac8855ae3f9fd9a0b207c60
Kotlin: 1.3.70
Groovy: 2.5.10
Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM: 14 (Oracle Corporation 14+36-1461)
OS: Windows 10 10.0 amd64
$ java --version
openjdk 14 2020-03-17
OpenJDK Runtime Environment (build 14+36-1461)
OpenJDK 64-Bit Server VM (build 14+36-1461, mixed mode, sharing)
plugins {
id "net.ltgt.apt-eclipse" version "0.21"
id "com.github.johnrengelman.shadow" version "5.0.0"
id "application"
}
version "0.1"
group "com.xyz"
sourceCompatibility = 14
targetCompatibility = 14
repositories {
mavenCentral()
maven { url "https://jcenter.bintray.com" }
}
configurations {
// for dependencies that are needed for development only
developmentOnly
}
dependencies {
annotationProcessor platform("io.micronaut:micronaut-bom:$micronautVersion")
compileOnly group: 'org.projectlombok', name: 'lombok', version: '1.18.12'
annotationProcessor group: 'org.projectlombok', name: 'lombok', version: '1.18.12'
annotationProcessor "io.micronaut:micronaut-inject-java"
annotationProcessor "io.micronaut:micronaut-validation"
annotationProcessor("io.micronaut.data:micronaut-data-processor:1.0.2")
annotationProcessor("io.micronaut.configuration:micronaut-openapi:1.4.3")
implementation platform("io.micronaut:micronaut-bom:$micronautVersion")
implementation "io.micronaut:micronaut-inject"
implementation "io.micronaut:micronaut-validation"
implementation "io.micronaut:micronaut-runtime"
implementation "javax.annotation:javax.annotation-api"
implementation "io.micronaut:micronaut-http-server-netty"
implementation "io.micronaut:micronaut-http-client"
implementation("io.micronaut.data:micronaut-data-hibernate-jpa:1.0.2")
implementation "org.springframework.security:spring-security-crypto:$springSecurityCryptoVersion"
implementation("io.swagger.core.v3:swagger-annotations")
runtimeOnly "ch.qos.logback:logback-classic:1.2.3"
compile group: 'commons-logging', name: 'commons-logging', version: '1.2'
// compile group: 'io.micronaut.configuration', name: 'micronaut-hibernate-jpa', version: '1.3.0.RC1'
compile "io.micronaut.configuration:micronaut-jdbc-hikari"
compile group: 'org.postgresql', name: 'postgresql', version: '42.2.6'
// compile 'io.micronaut.configuration:micronaut-security-oauth2:1.2.0'
// annotationProcessor "io.micronaut:micronaut-security"
compile "io.micronaut:micronaut-security-jwt"
compile 'io.micronaut.configuration:micronaut-flyway'
testAnnotationProcessor platform("io.micronaut:micronaut-bom:$micronautVersion")
testAnnotationProcessor "io.micronaut:micronaut-inject-java"
testImplementation "org.junit.jupiter:junit-jupiter-api"
testImplementation "io.micronaut.test:micronaut-test-junit5"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine"
testCompile group: 'org.mockito', name: 'mockito-core', version: '3.0.0'
testCompile group: 'org.mockito', name: 'mockito-junit-jupiter', version: '3.0.0'
}
test.classpath += configurations.developmentOnly
mainClassName = "com.vdt.salv.Application"
// use JUnit 5 platform
test {
useJUnitPlatform()
}
tasks.withType(JavaCompile){
options.encoding = "UTF-8"
options.compilerArgs.add('-parameters')
}
shadowJar {
mergeServiceFiles()
}
run.classpath += configurations.developmentOnly
run.jvmArgs('-noverify', '-XX:TieredStopAtLevel=1', '-Dcom.sun.management.jmxremote')
task stage(dependsOn: ['build', 'clean'])
build.mustRunAfter clean
tasks.withType(JavaCompile) {
options.fork = true
options.forkOptions.jvmArgs << '-Dmicronaut.openapi.views.spec=rapidoc.enabled=true,swagger-ui.enabled=true,swagger-ui.theme=flattop'
}
micronautVersion=1.3.4
org.gradle.caching=true
springSecurityCryptoVersion=5.3.1.RELEASE
java.runtime.version=14