What is the purpose of addModules in the configuration #8
Replies: 3 comments
-
It's passed to the jlink command to tell it what to include in the smaller JVM. For example, if you don't care about fxml you can remove it from the list. Probably the biggest one is the JavaFX web component, which is around 30mb IIRC and bundles the entire Chromium engine. https://docs.oracle.com/en/java/javase/17/docs/specs/man/jlink.html jlink does follow the dependency graph, for example look at the module graph for java.desktop at the top of this page. https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/module-summary.html The plugin is just passing the options to the underlying jlink tool. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reply. As far as I understand, we still have to manually let My assumption is, the 3rd party dependencies I use are non-modular which can be detected automatically but java modules are modular and have to be added manually. Correct me if I'm wrong. |
Beta Was this translation helpful? Give feedback.
-
Generally speaking, I would say that you should only add things a modules that really constitute part of your core JDK build. For most people, that's the JDK itself and JavaFX. In this project the JDK modules come from the JDK itself, and JavaFX modules come from the JavaFX download site. I include a bunch of the JavaFX modules to make things a bit easier and to illustrate how it works (although I don't include the JavaFX web module as it's too large for GitHub templates). For the rest of the application, it's JAR files downloaded and managed by Maven, including transitive downloads. In Maven, if a library A declares that it needs B in the pom.xml for A, it will download B, and if B needs C it will download C, etc). Java modules know nothing about Maven dependencies. Maven knows nothing about Java modules. Java modules do have the ability to declare dependencies on each other, but don't have the ability to download new modules. So if a Module A declares a dependency on B, it will only find B if it is already on the module path. You have to manage that all yourself. Does that help? |
Beta Was this translation helpful? Give feedback.
-
Hi!
It is not clear from the documentation why we need
addModules
. Doesn't this plugin already detects what modules are necessary and bundle them into the custom runtime?Beta Was this translation helpful? Give feedback.
All reactions