Maven 错误构建 Quarkus 本机图像 (java.nio.file.AccessDeniedException: /./target)

Maven error building Quarkus native image (java.nio.file.AccessDeniedException: /./target)

我正在尝试使用 Github 自托管运行器为我的 quarkus 应用程序构建本机映像。

这对我来说在 Github 托管运行器上非常有用,但我想在自托管运行器上这样做,这样我们就不会浪费我们的 github 行动分钟预算。

当我更新我的工作流程以使用自托管运行器时,我开始遇到这个奇怪的异常。

runners@ip-10-0-2-105:/opt/actions-runner/_work/prime-platform/prime-platform$ mvn clean package -DskipTests -Pnative
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< com.pubfactory.prime:prime-platform >-----------------
[INFO] Building Prime Platform dev-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ prime-platform ---
[INFO] Deleting /opt/actions-runner/_work/prime-platform/prime-platform/target
[INFO]
[INFO] --- git-commit-id-maven-plugin:5.0.0:revision (get-the-git-infos) @ prime-platform ---
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ prime-platform ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 2 resources
[INFO]
[INFO] --- quarkus-maven-plugin:2.7.5.Final:generate-code (default) @ prime-platform ---
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ prime-platform ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 46 source files to /opt/actions-runner/_work/prime-platform/prime-platform/target/classes
[INFO]
[INFO] --- quarkus-maven-plugin:2.7.5.Final:generate-code-tests (default) @ prime-platform ---
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ prime-platform ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ prime-platform ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 21 source files to /opt/actions-runner/_work/prime-platform/prime-platform/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) @ prime-platform ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ prime-platform ---
[INFO] Building jar: /opt/actions-runner/_work/prime-platform/prime-platform/target/prime-platform-dev-SNAPSHOT-69f1447.jar
[INFO]
[INFO] --- quarkus-maven-plugin:2.7.5.Final:build (default) @ prime-platform ---
[INFO] [org.hibernate.Version] HHH000412: Hibernate ORM core version 5.6.5.Final
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  18.472 s
[INFO] Finished at: 2022-03-24T20:21:26Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:2.7.5.Final:build (default) on project prime-platform: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[ERROR]         [error]: Build step io.quarkus.smallrye.openapi.deployment.SmallRyeOpenApiProcessor#build threw an exception: java.lang.IllegalStateException: java.nio.file.AccessDeniedException: /./target
[ERROR]         at io.quarkus.deployment.ExtensionLoader.execute(ExtensionLoader.java:891)
[ERROR]         at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
[ERROR]         at org.jboss.threads.ContextHandler.runWith(ContextHandler.java:18)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
[ERROR]         at java.base/java.lang.Thread.run(Thread.java:829)
[ERROR]         at org.jboss.threads.JBossThread.run(JBossThread.java:501)
[ERROR] Caused by: java.nio.file.AccessDeniedException: /./target
[ERROR]         at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:90)
[ERROR]         at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
[ERROR]         at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
[ERROR]         at java.base/sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:389)
[ERROR]         at java.base/java.nio.file.Files.createDirectory(Files.java:690)
[ERROR]         at java.base/java.nio.file.Files.createAndCheckIsDirectory(Files.java:797)
[ERROR]         at java.base/java.nio.file.Files.createDirectories(Files.java:783)
[ERROR]         at io.quarkus.smallrye.openapi.deployment.SmallRyeOpenApiProcessor.storeGeneratedSchema(SmallRyeOpenApiProcessor.java:694)
[ERROR]         at io.quarkus.smallrye.openapi.deployment.SmallRyeOpenApiProcessor.storeDocument(SmallRyeOpenApiProcessor.java:945)
[ERROR]         at io.quarkus.smallrye.openapi.deployment.SmallRyeOpenApiProcessor.build(SmallRyeOpenApiProcessor.java:653)
[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:566)
[ERROR]         at io.quarkus.deployment.ExtensionLoader.execute(ExtensionLoader.java:882)
[ERROR]         ... 6 more
[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
runners@ip-10-0-2-105:/opt/actions-runner/_work/prime-platform/prime-platform$

我正在使用 GraalVM 22.0.0.2、Java 11.0.14、Maven 3.8.4 和 Quarkus 2.7.5

我尝试回滚到 Quarkus 2.7.4,这个问题消失了

看来这只是 Quarkus 2.7 中的错误。5.Final。 修复是降级到 2.7.4 并打开 https://github.com/quarkusio/quarkus/issues/24547