Maven Native Image Plugin: Support for building java modules for native image, including support for junit
Hello there,
Is your feature request related to a problem? Please describe. I've converted an application of mine into java modules and tried to build it via native maven plugin. The problem: Native maven plugin seams not support to build native image automatically via the module parameters. So i have to add all project modules and maven dependencies manually to the --module-path parameter which isn't very comfortable in large projects. For executing junit tests via native image profile i did not find the correct parameters on my own for getting the tests running with modules in native image.
Describe the solution you'd like I would suggest implement support for automatically detecting that the current project, that is built, is a java module and automatically feed the native-image command with the module parameters, like other maven plugins do. For example running unit tests with surefire automatically runs them in "module mode" without any additional parameters for the plugin, it's enough the have a module-info.java present in the project.
I've already checked the documentation here https://graalvm.github.io/native-build-tools/latest/maven-plugin.html but didn't found any information for building module projects with native maven plugin.
Hopefully it's understandable what my point is, if you need additional information or a sample application i can provide it.
Regards Christoph
We'd like to properly support the module path, but as far as I know, it is poorly supported by Maven and Gradle and causes a lot of problems. Can you build and run your modularized Java application with Maven just fine when not using the native build tools?
We'd like to properly support the module path, but as far as I know, it is poorly supported by Maven and Gradle and causes a lot of problems. Can you build and run your modularized Java application with Maven just fine when not using the native build tools?
Yes, it was also possible to build with native-build-tools, but i needed to feed in all paths to maven dependencies manually, which isn't that simple, when you have different environments like Windows Dev-Machines and Linux-Build-Servers, cause of different paths to the maven repo and path separators etc.
As a final result i wrote my own maven plugin, that obtains all dependencies etc. and feeding native-image with the required parameters to build it on the module path.
As a final result i wrote my own maven plugin, that obtains all dependencies etc. and feeding native-image with the required parameters to build it on the module path.
Please consider upstreaming the work that you have done. And if you have any other suggestions how the NBTs could support the module path, we are all ears.
My 3 cents on this topic:
- allows overriding the generated command line args by being able to replace
-cpwith-pusing a flag (easy way) - allows specifying modulepath as for classpath inside configuration (a bit harder)
- same as above plus removing from classpath any dependency mentioned inside the modulepath (hardest, makes sense?)