在多模块项目中构建 Gluon 应用程序

Building Gluon Apps in Multi-Module Project

TL;DR:如何构建属于更大的多模块项目的 Gluon 应用程序?

我有一个多模块 Mave 项目(也就是说,我的顶级 POM 有“<packaging>pom</packaging>”)。该项目包含一堆库和相关的子项目,其中一个是 Gluon 应用程序,我的实际用户将安装该应用程序。 (项目的其余部分是客户端应用程序连接到的所有云托管管道。)

当我尝试构建 Gluon 应用程序时,根据 Gluon documentation,我收到以下错误:

mvn gluonfx:build
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] app                                                            [pom]
[INFO] app-common                                                     [jar]
[INFO] app-server                                                     [jar]
[INFO] app-client                                                     [jar]
[INFO] app-test                                                       [jar]
[INFO] app-utilities                                                  [jar]
[INFO] app-integration-lambda                                         [jar]
[INFO] app-integration-jakarta                                        [war]
[INFO] app-gluon                                                      [jar]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for app 0.9:
[INFO]
[INFO] app ............................................ SKIPPED
[INFO] app-common ..................................... SKIPPED
[INFO] app-server ..................................... SKIPPED
[INFO] app-client ..................................... SKIPPED
[INFO] app-test ....................................... SKIPPED
[INFO] app-utilities .................................. SKIPPED
[INFO] app-integration-lambda ......................... SKIPPED
[INFO] app-integration-jakarta ........................ SKIPPED
[INFO] app-gluon ...................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.298 s
[INFO] Finished at: 2022-02-22T21:03:18+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'gluonfx' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\Administrator\.m2\repository), central (https://repo.maven.apache.org/maven2)] -> [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/NoPluginFoundForPrefixException

如果我 运行 Maven 让它只构建 Gluon 应用程序,就像这样:

mvn gluonfx:build --projects "app-gluon" --also-make

我得到了基本相同的错误。如果我先 cd 到 app-gluon,我会得到一个不同的错误(而且我没想到它会起作用):

cd app-gluon
mvn gluonfx:build
[INFO] Scanning for projects...
[INFO] 
[INFO] --------------------< com.whatever:app-gluon >--------------------
[INFO] Building app-gluon 0.9
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for com.whatever:app-common:jar:0.9 is missing, no dependency information available
[WARNING] The POM for com.whatever:app-client:jar:0.9 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.380 s
[INFO] Finished at: 2022-02-22T21:09:12+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project app-gluon: Could not resolve dependencies for project com.whatever:app-gluon:jar:0.9: The following artifacts could not be 
resolved: com.whatever:app-common:jar:0.9, com.whatever:app-client:jar:0.9: com.whatever:app-common:jar:0.9 was not found in https://nexus.gluonhq.com/nexus/
content/repositories/releases during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of Gluon has elapsed or updates are forced -> [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/DependencyResolutionException

所以我的问题是:如何构建属于更大的多模块项目的 Gluon 应用程序?

如果您有一个多模块项目,并且您的应用程序模块依赖于其他模块,您需要将这些模块发布到存储库,以便应用程序模块找到它们,就像任何其他第三方依赖项一样。

通常,对于本地开发,您可以简单地使用根文件夹中的 mvn install 在本地部署您的项目。当然,为了分发,您应该考虑将它们发布到可访问的存储库。

确保所有模块都已部署到 ~/.m2 存储库。

然后你可以运行从根:

mvn gluonfx:build -f app-gluon

或在app-gluon文件夹中输入:

cd app-gluon
mvn gluonfx:build

请记住,每次您对其他模块进行任何更改时,都需要在构建本机映像之前再次发布它们。

此外,由于您可以在 JVM 上 运行 您的应用程序,因此在构建本机映像之前(这需要几分钟),您可以简单地 运行 和测试:

mvn gluonfx:run

如果一切正常,请构建本机映像。