Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maven Native Image Plugin: Support for building java modules for native image, including support for junit #334

Open
Rottinator opened this issue Oct 13, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@Rottinator
Copy link

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

@Rottinator Rottinator added the enhancement New feature or request label Oct 13, 2022
@fniephaus
Copy link
Member

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?

@Rottinator
Copy link
Author

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.

@fniephaus
Copy link
Member

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.

@loiclefevre
Copy link

My 3 cents on this topic:

  • allows overriding the generated command line args by being able to replace -cp with -p using 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?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants