2

我无法在 Catalina 10.15.2 中运行命令:

bash-3.2$ $GRAALVM_HOME/Home/bin/gu install native-image 

它返回我这条消息:

cannot be opened because the developer cannot be verified.

我试过跑步

sudo xattr -r -d com.apple.quarantine $GRAALVM_HOME

在哪里

bash-3.2$ echo $GRAALVM_HOME
/Library/Java/JavaVirtualMachines/graalvm-ce-java8-19.3.0/Contents

没有运气。我无法运行该命令,因此无法成功运行该命令

mvn install -Pnative.

[粘贴箱][1]

我已经读过这个 [thread][2],对我没有用。

请帮忙

更新

好的,我已经应用了这个建议,现在我可以创建 native-image,但是当我尝试运行 mvn install -Pnative 时出现一个错误:

~/g/q/quarkus-echo> echo $GRAALVM_HOME 
/Library/Java/JavaVirtualMachines/graalvm-ce-java8-19.3.0
aironman@MacBook-Pro-de-Alonso ~/g/q/quarkus-echo> cd $GRAALVM_HOME 
aironman@MacBook-Pro-de-Alonso /L/J/J/graalvm-ce-java8-19.3.0> sudo xattr -r -d com.apple.quarantine $GRAALVM_HOME
Password:
bash-3.2$ /Library/Java/JavaVirtualMachines/graalvm-ce-java8-19.3.0/Contents/Home/bin/gu install native-image
Downloading: Component catalog from www.graalvm.org
Processing Component: Native Image
Downloading: Component native-image: Native Image  from github.com
Installing new component: Native Image (org.graalvm.native-image, version 19.3.0)

bash-3.2$ pwd
/Users/aironman/gitProjects/quarkus-test/quarkus-echo
bash-3.2$ mvn install -Pnative
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------< ujr.combat.quarkus:quarkus-echo >-------------------
[INFO] Building quarkus-echo 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ quarkus-echo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ quarkus-echo ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ quarkus-echo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/aironman/gitProjects/quarkus-test/quarkus-echo/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ quarkus-echo ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ quarkus-echo ---
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running ujr.combat.quarkus.EchoResourceTest
2020-01-13 17:13:45,816 INFO  [io.quarkus] (main) Quarkus 1.1.1.Final started in 0.324s. Listening on: http://0.0.0.0:8081
2020-01-13 17:13:45,829 INFO  [io.quarkus] (main) Profile test activated. 
2020-01-13 17:13:45,829 INFO  [io.quarkus] (main) Installed features: [cdi, resteasy, resteasy-jsonb]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.998 s - in ujr.combat.quarkus.EchoResourceTest
2020-01-13 17:13:46,604 INFO  [io.quarkus] (main) Quarkus stopped in 0.028s
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ quarkus-echo ---
[INFO] 
[INFO] --- quarkus-maven-plugin:1.1.1.Final:build (default) @ quarkus-echo ---
[INFO] [org.jboss.threads] JBoss Threads version 3.0.0.Final
[INFO] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Building native image source jar: /Users/aironman/gitProjects/quarkus-test/quarkus-echo/target/quarkus-echo-1.0-SNAPSHOT-native-image-source-jar/quarkus-echo-1.0-SNAPSHOT-runner.jar
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Building native image from /Users/aironman/gitProjects/quarkus-test/quarkus-echo/target/quarkus-echo-1.0-SNAPSHOT-native-image-source-jar/quarkus-echo-1.0-SNAPSHOT-runner.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  6.070 s
[INFO] Finished at: 2020-01-13T17:13:48+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.1.1.Final:build (default) on project quarkus-echo: Failed to build a runnable JAR: Failed to augment application classes: Build failure: Build failed due to errors
[ERROR]     [error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: java.lang.RuntimeException: Cannot find the `native-image` in the GRAALVM_HOME, JAVA_HOME and System PATH. Install it using `gu install native-image`
[ERROR]     at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.getNativeImageExecutable(NativeImageBuildStep.java:376)
[ERROR]     at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:134)
[ERROR]     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR]     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]     at java.base/java.lang.reflect.Method.invoke(Method.java:567)
[ERROR]     at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:915)
[ERROR]     at io.quarkus.builder.BuildContext.run(BuildContext.java:415)
[ERROR]     at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
[ERROR]     at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
[ERROR]     at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
[ERROR]     at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426)
[ERROR]     at java.base/java.lang.Thread.run(Thread.java:830)
[ERROR]     at org.jboss.threads.JBossThread.run(JBossThread.java:479)
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
bash-3.2$ echo $GRAALVM_HOME
/Library/Java/JavaVirtualMachines/graalvm-ce-java8-19.3.0
bash-3.2$ 

更新 2

根据 Viktor 的建议,我更改了 GRAALVM_HOME:

export GRAALVM_HOME=/Library/Java/JavaVirtualMachines/graalvm-ce-java8-19.3.0/Contents/Home



    bash-3.2$ export GRAALVM_HOME=/Library/Java/JavaVirtualMachines/graalvm-ce-java8-19.3.0/Contents/Home
bash-3.2$ /Library/Java/JavaVirtualMachines/graalvm-ce-java8-19.3.0/Contents/Home/bin/gu install native-image
Downloading: Component catalog from www.graalvm.org
Processing Component: Native Image
Component Native Image (org.graalvm.native-image) is already installed.
bash-3.2$ pwd
/Users/aironman/gitProjects/quarkus-test/quarkus-echo
bash-3.2$ mvn install -Pnative
...
project quarkus-echo: Failed to build a runnable JAR: Failed to augment application classes: Build failure: Build failed due to errors
[ERROR]     [error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: java.lang.IllegalStateException: Unsupported version of GraalVM detected: GraalVM Version 19.3.0 CE. Please use GraalVM 19.2.1.
[ERROR]     at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.checkGraalVMVersion(NativeImageBuildStep.java:340)
[ERROR]     at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:155)
[ERROR]     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR]     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]     at java.base/java.lang.reflect.Method.invoke(Method.java:567)
[ERROR]     at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:915)
[ERROR]     at io.quarkus.builder.BuildContext.run(BuildContext.java:415)
[ERROR]     at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
[ERROR]     at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
[ERROR]     at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
[ERROR]     at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426)
[ERROR]     at java.base/java.lang.Thread.run(Thread.java:830)
[ERROR]     at org.jboss.threads.JBossThread.run(JBossThread.java:479)
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

看来我必须降级到 GRAALVM 19.2.1 ...

谢谢你们的帮助。我将看到如何使用 brew 降级到所需的版本...

4

3 回答 3

8

您需要在 topdir 上运行隔离区删除:

sudo xattr -r -d com.apple.quarantine /Library/Java/JavaVirtualMachines/graalvm-ce-java8-19.3.0

于 2020-01-13T14:44:06.470 回答
1

这对我有用 10 分钟前OSX 0.14.6 Mojave 有同样的问题

安装 GRAALVM

brew install --cask  graalvm/tap/graalvm-ce-java11
# check your version and fix the last part of path
sudo xattr -r -d com.apple.quarantine /Library/Java/JavaVirtualMachines/graalvm-ce-java11-20.3.0
# install native image
/Library/Java/JavaVirtualMachines/graalvm-ce-java11-20.3.0/Contents/Home/bin/gu install native-image

导出 GRAALVM_HOME ~/.bash_profile

# don't forget to fix version of GraalVM, yours can be newer
export GRAALVM_HOME=/Library/Java/JavaVirtualMachines/graalvm-ce-java11-20.3.0/Contents/Home

使用 GRAALVM 构建

./gradlew build -Dquarkus.package.type=native
于 2021-01-21T23:45:54.400 回答
1

为 OSX BigSur 工作!

按以下顺序执行以下命令

brew install --cask graalvm/tap/graalvm-ce-lts-java11

sudo xattr -r -d com.apple.quarantine /Library/Java/JavaVirtualMachines/graalvm-ce-lts-java11/Contents/Home

/Library/Java/JavaVirtualMachines/graalvm-ce-lts-java11/Contents/Home/bin/gu install native-image

在 ~/.zshrc 中添加以下内容

export GRAALVM_HOME=/Library/Java/JavaVirtualMachines/graalvm-ce-lts-java11/Contents/Home

export PATH=$PATH:$GRAALVM_HOME

source ~/.zshrc

使用 mvn 或 gradle 构建

mvn package -Dquarkus.package.type=native

或者

./gradlew build -Dquarkus.package.type=native

于 2021-10-03T07:51:06.843 回答