sdkman gradle 3.4 无法确定 java 版本

sdkman gradle 3.4 cannot determine java version

在使用 gradle 5.6.1 的终端中工作时,许多事情都按预期工作。例如。更改为较旧的 java 版本 (1)。如果我更改为 gradle 3.4 gradle 不再找到 jdk (1).

如何让 gradle 3.4 再次在我的系统上运行。

我想建立一个我曾经用 gradle 3.4 做过的项目。但是,我没有 gradle 包装器,并且由于 gradle 5.6.1.

的更改,构建似乎已损坏

(1)

user@system:~$ sdk u gradle 3.4                                                                      

Using gradle version 3.4 in this shell.                                                                           
user@system:~$ gradle -v                                                                             

FAILURE: Build failed with an exception.                                                                          

* What went wrong:                                                                                                
Could not determine java version from '11.0.5'.                                                                   

* Try:                                                                                                            
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
user@system:~$ sdk u java 9.0.4

Stop! java 9.0.4 is not available. Possible causes:
 * 9.0.4 is an invalid version
 * java binaries are incompatible with Linux64
 * java has not been released yet
user@system:~$ sdk u java 9.0.4-open

Using java version 9.0.4-open in this shell.
user@system:~$ gradle

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine java version from '9.0.4'.

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

(2)

user@system:~$ gradle -v                                                                                         
                                                                                                                      ------------------------------------------------------------                                                      
Gradle 5.6.1                                                                                                      
------------------------------------------------------------                                                      

Build time:   2019-08-28 02:49:34 UTC                                                                             
Revision:     b6bd8e7934ca41d9e52610058aa7cb834df81fc4                                                            

Kotlin:       1.3.41
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.14 compiled on March 12 2019                                            
JVM:          11.0.5 (Debian 11.0.5+10-post-Debian-1deb10u1)                                                     
OS:           Linux 4.19.0-6-amd64 amd64

user@system:~$ sdk u java 9.0.4-open

Using java version 9.0.4-open in this shell.
user@system:~$ gradle -v
------------------------------------------------------------                                                     
Gradle 5.6.1
------------------------------------------------------------                                                     

Build time:   2019-08-28 02:49:34 UTC
Revision:     b6bd8e7934ca41d9e52610058aa7cb834df81fc4

Kotlin:       1.3.41
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.14 compiled on March 12 2019
JVM:          9.0.4 (Oracle Corporation 9.0.4+11)
OS:           Linux 4.19.0-6-amd64 amd64

Gradle 仅从 Gradle version 4.7, also see https://github.com/gradle/gradle/issues/4591. Java 9 is supported as of Gradle 4.1 开始支持 Java 11(和 10)。因此,您最好的选择是尝试 Gradle 4.7 是否适合您,或者让您的构建与当前的 Gradle 版本兼容。

不同版本的Gradle在不同版本的Java上支持运行。据我所知,您需要 Gradle 4.2.1 才能完全支持 Java 9. 您确定这是您在旧项目中使用的组合吗?如果是这样,您可能想尝试 Java 9 的初始版本(没有任何点版本)。如果它只是在版本解析中失败,它可能会有所帮助。但我很确定这种组合还有其他问题。

无论如何,您需要从 3.4 升级 Gradle 或从 9.0.4 降级 Java。