mavengluon

Building Gluon Apps in Multi-Module Project


TL;DR: How does one build a Gluon app that's part of a larger multi-module project?

I have a multi-module Mave project (that is, my top-level POM has "<packaging>pom</packaging>"). The project contains a bunch of libraries and related sub-projects, one of which is a Gluon app that will be what my actual users install. (The rest of the project is all the cloud-hosted plumbing that the client app connects to.)

When I try to build the Gluon app, per the Gluon documentation, I am getting the following error:

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

If I run Maven so that it only builds the Gluon application instead, like this:

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

I get basically the same error. If I cd to app-gluon first, I get a different error (and I didn't expect this to work anyhow):

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

So my question is: how does one build a Gluon app that's part of a larger multi-module project?


Solution

  • If you have a multi module project, and your app module depends on other modules, you need to publish those modules to a repository, so the app module finds them, like any other third party dependency.

    Typically, for local development, you can simply use mvn install from the root folder to deploy your project locally. Of course, for distribution, you should consider publishing them to a reachable repository.

    Make sure all your modules are deployed to your ~/.m2 repository.

    Then you can run from the root:

    mvn gluonfx:build -f app-gluon
    

    or enter in the app-gluon folder:

    cd app-gluon
    mvn gluonfx:build
    

    And remember that every time you make any change to the other modules, you will need to publish them again before building the native image.

    Also, since you can run your app on the JVM, before building the native image (which takes a couple of minutes), you can simply run and test:

    mvn gluonfx:run
    

    and if that works fine, do the native image build.