繁体   English   中英

由于 Gradle 版本 I 没有和来源 8,Gradle 构建失败

[英]Gradle Build Failing Due to Gradle Version I Do Not Have and Source 8

我正在尝试构建和运行一个项目,我收到这些错误/警告。 文档说它需要 JVM 10 和 Gradle 6:

D:\GIT\geo\spring-boot>.\gradlew  bootRun

> Task :compileJava FAILED
D:\GIT\geo\spring-boot\src\main\java\module-info.java:1: error: modules are not supported in -source 
8
module Geo {
^
  (use -source 9 or higher to enable modules)
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more 
log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1s
1 actionable task: 1 executed

我看到这条消息: use -source 9 or higher to enable modules但是,它看起来像是在使用 java 10

D:\GIT\geo\spring-boot>java -version
openjdk version "10" 2018-03-20
OpenJDK Runtime Environment 18.3 (build 10+44)
OpenJDK 64-Bit Server VM 18.3 (build 10+44, mixed mode)

我还看到此消息: Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0. 但看起来我正在使用 Gradle 2.2

D:\GIT\geo\spring-boot>.\gradlew -v

------------------------------------------------------------
Gradle 6.2.2
------------------------------------------------------------

Build time:   2020-03-04 08:49:31 UTC
Revision:     7d0bf6dcb46c143bcc3b7a0fa40a8e5ca28e5856

Kotlin:       1.3.61
Groovy:       2.5.8
Ant:          Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM:          10 ("Oracle Corporation" 10+44)
OS:           Windows Server 2016 10.0 amd64

您需要在构建脚本中设置版本

compileJava {
    options.release = 10
}

https://docs.gradle.org/6.8.1/userguide/building_java_projects.html#sec:java_cross_compilation

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM