Plugin development on M1 Mac...

已计划

I'm trying to build a CLion plugin on a new M1 Mac. When I run using runIde, it always runs the x86 version of CLion, not the aarch64 version. I have updated to the latest org.jetbrains.intellij. I tried using jreRelease, but the system automatically fills in the architecture.

runIde {
jbrVersion.set("jbr_jcef-11_0_11b1504.12.tar.gz")
}

[gradle-intellij-plugin :cse335-intellij-plugin:runIde] Cannot download JetBrains Java Runtime 'jbr_jcef-11_0_11-osx-x64-b1504.12.tar.gz'. Run with --debug option to get more log output.

runIde {
jbrVersion.set("jbr_jcef-11_0_11-osx-aarch64-b1504.12.tar.gz")
}
[gradle-intellij-plugin :cse335-intellij-plugin:runIde] Cannot download JetBrains Java Runtime 'jbr_jcef-11_0_11-osx-aarch64--osx-x64-b1504.12.tar.gz'. Run with --debug option to get more log output.

You can view my code at: https://github.com/charles-owen/cse335-intellij-plugin

0

I don't know whether you have found an answer to this yourself already. But in case you haven't or anyone else stumbles over this, here is what I have found out:

The gradle-intellij-plugin , which you will use if you start from the plugin-template, resolves the architecture via system-property "os.arch" for the to-be-downloaded Jbr artifact from your "Project SDK," which in turn runs the task.

Since most JRE/JDK packages currently available for macOS are x64 and not aarch64, they will run in compatibility mode (Rosetta) on your M1. This is why you will not see any issues until some code uses "os.arch" to figure out the CPU architecture it runs on. This is - oddly enough - also true for runtimes that are supposedly aarch64. If you start your plugin from an IntelliJ Idea that identifies itself as running on

Runtime version: 11.0.12+7-b1504.40 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 12.0.1

the contained JRE returns "x86_64" for system-property "os.arch". 

The quickest solution is to install a macOS aarch64 JDK/JRE package on your M1 and configure it as the "Project SDK." For Java 11, this means to use the JVM from Azul since Adoptium (previously AdoptOpenJDK) does provide MacOS aarch64 builds only since Java 17.

I am not sure, but maybe it would be better for the gradle-intellij-plugin to use a more robust source than the "os.arch" property as a proxy for the actual CPU architecture or allow overwrites via an explicit parameter.

0

请先登录再写评论。