Windows 上用于 JavaFX 的 Gluon 客户端 maven 插件无法编译?

Gluon client maven plugin for JavaFX on Windows fails to compile?

我一直在 Windows 机器上为我的一个项目试验 Gluon 的客户端 maven 插件。我决定尝试他们的 "hello world" 示例之一,here. 我遵循了有关如何配置机器的所有步骤。

但是,我遇到了一些错误。由于某种原因,编译总是失败并给我一个错误 "Cannot run program "cl""。有人知道如何解决这个问题吗?

我是 运行 client:build 命令中的一个 "x64 Native Tools Command Prompt for VS 2019" window。

日志如下:

java.io.IOException: Cannot run program "cl" (in directory "C:\Users\Evan\Documents\client-samples\Maven\HelloFXML\target\client\x86_64-windows\gvm\hellofxml"): CreateProcess error=2, The system cannot find the file specified
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
[INFO] ------------------------------------------------------------------------
        at com.gluonhq.substrate.util.ProcessRunner.setupProcess(ProcessRunner.java:336)
[INFO] BUILD FAILURE
        at com.gluonhq.substrate.util.ProcessRunner.runProcess(ProcessRunner.java:194)
[INFO] ------------------------------------------------------------------------
        at com.gluonhq.substrate.target.AbstractTargetConfiguration.compileAdditionalSources(AbstractTargetConfiguration.java:330)
[INFO] Total time:  2.860 s
        at com.gluonhq.substrate.target.AbstractTargetConfiguration.compile(AbstractTargetConfiguration.java:130)
[INFO] Finished at: 2020-06-02T17:37:39-04:00
        at com.gluonhq.substrate.SubstrateDispatcher.nativeCompile(SubstrateDispatcher.java:414)
[INFO] ------------------------------------------------------------------------
        at com.gluonhq.NativeCompileMojo.execute(NativeCompileMojo.java:54)
[ERROR] Failed to execute goal com.gluonhq:client-maven-plugin:0.1.26:compile (default-cli) on project hellofxml: Error: Cannot run program "cl" (in directory "C:\Users\Evan\Documents\client-samples\Maven\HelloFXML\target\client\x86_64-windows\gvm\hellofxml"): CreateProcess error=2, The system cannot find the file specified -> [Help 1]
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
[ERROR]
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
[ERROR]
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
[ERROR] For more information about the errors and possible solutions, please read the following articles:
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:567)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
        at java.base/java.lang.ProcessImpl.create(Native Method)
        at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:420)
        at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:151)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
        ... 29 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.141 s
[INFO] Finished at: 2020-06-02T17:37:39-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.gluonhq:client-maven-plugin:0.1.26:build (default-cli) on project hellofxml: Error, client:build failed -> [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

当我将 C:\Program Files (x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC.25.28610\bin\HostX64\x64 添加到我的系统路径时,插件在日志中给出以下错误。 (我在管理员模式下运行这个命令)

[Tue Jun 02 18:28:07 EDT 2020][INFO] ==================== COMPILE TASK ====================
[Tue Jun 02 18:28:08 EDT 2020][FINE] PB Command for check version: D:\graalvm-ce-java11-20.2.0-dev\bin\java -version
[Tue Jun 02 18:28:08 EDT 2020][FINE] Start process check version...
[Tue Jun 02 18:28:09 EDT 2020][FINE] [SUB] openjdk version "11.0.7" 2020-04-14
[Tue Jun 02 18:28:09 EDT 2020][FINE] [SUB] OpenJDK Runtime Environment GraalVM CE 20.2.0-dev (build 11.0.7+10-jvmci-20.1-b02)
[Tue Jun 02 18:28:09 EDT 2020][FINE] [SUB] OpenJDK 64-Bit Server VM GraalVM CE 20.2.0-dev (build 11.0.7+10-jvmci-20.1-b02, mixed mode, sharing)
[Tue Jun 02 18:28:09 EDT 2020][FINE] Result for check version: 0
[Tue Jun 02 18:28:09 EDT 2020][INFO] We will now compile your code for x86_64-microsoft-windows. This may take some time.
[Tue Jun 02 18:28:09 EDT 2020][FINE] Extracting native libs to: C:\Users\Evan\Documents\client-samples\Maven\HelloFXML\target\client\x86_64-windows\gvm\lib
[Tue Jun 02 18:28:09 EDT 2020][FINE] Looking for resource: /native/windows/launcher.c
[Tue Jun 02 18:28:09 EDT 2020][FINE] PB Command for compile-additional-sources: cl -c -DSUBSTRATE /MD /D_UNICODE /DUNICODE /DWIN32 /D_WINDOWS -IC:\Users\Evan\Documents\client-samples\Maven\HelloFXML\target\client\x86_64-windows\gvm\hellofxml launcher.c
[Tue Jun 02 18:28:09 EDT 2020][FINE] Start process compile-additional-sources...
[Tue Jun 02 18:28:09 EDT 2020][FINE] [SUB] Microsoft (R) C/C++ Optimizing Compiler Version 19.25.28610.4 for x64
[Tue Jun 02 18:28:09 EDT 2020][FINE] [SUB] Copyright (C) Microsoft Corporation.  All rights reserved.
[Tue Jun 02 18:28:09 EDT 2020][FINE] [SUB] 
[Tue Jun 02 18:28:09 EDT 2020][FINE] [SUB] launcher.c
[Tue Jun 02 18:28:09 EDT 2020][FINE] [SUB] launcher.c(28): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory
[Tue Jun 02 18:28:09 EDT 2020][FINE] Result for compile-additional-sources: 2
[Tue Jun 02 18:28:09 EDT 2020][SEVERE] Process compile-additional-sources failed with result: 2
Check the log files under C:\Users\Evan\Documents\client-samples\Maven\HelloFXML\target\client\x86_64-windows\gvm\log
And please check https://docs.gluonhq.com/client/ for more information.
[Tue Jun 02 18:28:09 EDT 2020][INFO] Logging process [compile-additional-sources] to file: C:\Users\Evan\Documents\client-samples\Maven\HelloFXML\target\client\log\process-compile-additional-sources-1591136889122.log
[Tue Jun 02 18:28:09 EDT 2020][SEVERE] Compiling failed.
Check the log files under C:\Users\Evan\Documents\client-samples\Maven\HelloFXML\target\client\x86_64-windows\gvm\log
And please check https://docs.gluonhq.com/client/ for more information.

These are the VS 2019 components I have installed.

我遇到了同样的两个问题:

  1. 无法进行 cl 操作
  2. stdio.h 或找不到类似文件

第一个问题的解决方案(作者已经做了):

确保系统路径包含 Visual Studio 条目。类似于“C:\Program Files (x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC.25.28610\bin\HostX64\x64”

Visual Studio 似乎在安装时有时会错过路径变量上的条目。我把它安装到不同的目录。这可能会导致问题。

第二个问题的解决方案:

documentation 指出,如果 运行 在 Windows 上,您必须 运行 本机工具命令提示符中的所有 maven 或 gradle 命令。我在阅读文档时错过了那部分几次。

If you are running on Windows, you need to run all the Client goals from an x64 terminal.

之后我可以使用 client:compile 和 client:link 目标。