Gradle包装器报告X86-64体系结构,而不是Mac M1上的ARM-V8体系结构
您好,从Mac M1工作时,Gradle包装器任务报告与Gradle相比不正确:
这是./ Gradlew Clean Clean
的结果:
operating system 'Mac OS X'
architecture 'x86-64'
osx
x86_64
x86_64
这是Gradle Clean Clean
的结果:
operating system 'Mac OS X'
architecture 'arm-v8'
osx
aarch_64
aarch64
有人对此有解释吗?
其他信息:gradle -version
的输出
------------------------------------------------------------
Gradle 7.4.2
------------------------------------------------------------
Build time: 2022-03-31 15:25:29 UTC
Revision: 540473b8118064efcc264694cbcaa4b677f61041
Kotlin: 1.5.31
Groovy: 3.0.9
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 18.0.1 (Homebrew 18.0.1+0)
OS: Mac OS X 12.2.1 aarch64
是我的构建内容。显示架构的Gradle:
println org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.currentOperatingSystem;
println org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.currentArchitecture;
println osdetector.os
println osdetector.arch
println System.getProperty("os.arch")
我使用gradle包装器
从我的Mac M1生成了Gradle包装器。
Hello when working from a Mac m1, Gradle wrapper task reports incorrect architecture compared to gradle :
Here is the result of ./gradlew clean
:
operating system 'Mac OS X'
architecture 'x86-64'
osx
x86_64
x86_64
Here is the result of gradle clean
:
operating system 'Mac OS X'
architecture 'arm-v8'
osx
aarch_64
aarch64
Does someone have an explanation for that.
Additional information : output of gradle --version
------------------------------------------------------------
Gradle 7.4.2
------------------------------------------------------------
Build time: 2022-03-31 15:25:29 UTC
Revision: 540473b8118064efcc264694cbcaa4b677f61041
Kotlin: 1.5.31
Groovy: 3.0.9
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 18.0.1 (Homebrew 18.0.1+0)
OS: Mac OS X 12.2.1 aarch64
here is the content of my build.gradle to display architecture :
println org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.currentOperatingSystem;
println org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.currentArchitecture;
println osdetector.os
println osdetector.arch
println System.getProperty("os.arch")
I generated the Gradle wrapper from my Mac m1 using gradle wrapper
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
多亏了 @jesper的评论,这里是解决该问题的解决方案。
tl; dr
列出了系统上的JVM,并验证您在租赁一(ARM64)JVM时是否拥有JVM。
设置java_home环境变量JVM :
在我的情况下发生了什么:
这是由系统上安装的多个JVM引起的。有些JVM用于ARM64并本地运行,另一些则用于X86_64,并在A “翻译器”(Rosetta)。
没有遵循OpenJDK的“警告”:
因此,安装的Gradle安装了Hommbrew已安装了JVM。但是gradlew脚本正在使用默认系统JVM(Oracle X86_64 JVM)。
Thanks to @Jesper's comment here is a solution to that issue.
TL;DR
List the JVMs on your system and verify that you have at lease one (arm64) JVM.
Setup your JAVA_HOME environment variable to an arm64 JVM :
What happened in my case :
This is caused by multiple JVMs installed on the system. Some JVMs are compiled for arm64 and run natively, and some other are compiled for x86_64 and run in a "translator" (rosetta).
Did not follow the "Caveat" of openJDK :
So the homebrew installed gradle was using the homebrew installed JVM. But gradlew scripts were using the default system JVM (the Oracle x86_64 JVM).