Closed SaptarshiSarkar12 closed 11 months ago
Hi, Thank you for your suggestion, I'm curious about what version of GraalVM you're using.
@oubidar-Abderrahim I am using GraalVM 20.0.2+9.1.
Hi, the version of GraalVM used is up-to-date so it should support building modular applications, could you please check our docs at https://www.graalvm.org/latest/reference-manual/native-image/guides/build-java-modules-into-native-executable/ and see if that helps.
Hi @oubidar-Abderrahim :wave:! Thank you for responding. But, I am using the maven plugin of GraalVM for the build and it cannot recognize the multi-module structure of my project. I prefer using the maven plugin and it is being used in GitHub Actions CI/CD as well. I shall be glad if you can guide me to the right direction.
That shouldn't be an issue, you'll need to add the flags mentioned in our docs as buildArgs
. you can check how on our plugin docs here: https://graalvm.github.io/native-build-tools/latest/maven-plugin.html
@oubidar-Abderrahim Even after using the --module
flag, it still throws error as shown below
[ERROR] Failed to execute goal org.graalvm.buildtools:native-maven-plugin:0.9.27:build (build) on project Drifty: Image classpath is empty. Check if your classpath configuration is correct. -> [Help 1]
How should I solve it?
I have added these (:point_down:) in the <buildArgs>
<buildArg>--module Core</buildArg>
<buildArg>--module CLI</buildArg>
Could you please share a small example of what you're trying to achieve and we can take a look into it
@oubidar-Abderrahim I am planning to create three separate modules (two of which depend on the third) for my application Drifty. The parent pom is of Drifty's with three sub-modules - CLI, GUI and Core. The modules dependency can be visualised like this :point_down:
I wish GraalVM to build the CLI application by building and using the source files of CLI and Core. Do you want to know anything else? I couldn't get what you meant by simple example. I just tried to make you understand what I wished to have.
@oubidar-Abderrahim Is this feature being implemented? Have you understood the whole concept of my project, mentioned in the above comment?
Hi, this feature request doesn't make much sense because Native image does support modular java systems, you can find a simple example here: https://github.com/graalvm/graalvm-demos/tree/master/native-hello-module.
In case there is a bug, please create a bug-issue in our repository following our template, and provide a small reproducer code that we can build and verify the issue with.
Thank you
@oubidar-Abderrahim But, How do I setup GraalVM for a project using more than one java module?
I've been struggling with similar issue and this is my solution:
This is an example Maven configuration to invoke native-image
binary directly via Maven exec:exec
plugin and pass there all necessary JPMS arguments to build application composing of multiple modules: https://github.com/jtulach/NativeImageModularDemo/commit/f61ebfd677ec77e9c19104028bc0690b4cc376a2
@JaroslavTulach Hi Jaroslav :wave:!
Yes, this is the only working solution till now. Thank you for posting this soluton :smile:. It would help many people struggling to get GraalVM work with multi-module project.
Now, it requires you to run mvn install
before building "native-image" :upside_down_face:.
I had already implemented this approach in https://github.com/SaptarshiSarkar12/Drifty/pull/398/commits/d990871536fa0dcb195a73081e5c48d5f17a137f commit in my project - Drifty. Forgot to post my solution back here :smiley:.
Feature request
Is your feature request related to a problem? Please describe.
I am building a modular java project for Drifty. The source code for the project can be found here. I am using the Maven plugin of GraalVM to build native executables of the project. I have made three modules - Core, CLI and GUI for the project. When I try to build using GraalVM's maven plugin, it fails with the following error.
Build Error
```powershell [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Reactor Build Order: [INFO] [INFO] Drifty [pom] [INFO] Core [jar] [INFO] CLI [jar] [INFO] GUI [jar] [INFO] [INFO] -------------------------< com.Drifty:Drifty >-------------------------- [INFO] Building Drifty 2.0.0 [1/4] [INFO] --------------------------------[ pom ]--------------------------------- [INFO] [INFO] --- native-maven-plugin:0.9.27:build (build) @ Drifty --- [WARNING] 'native:build' goal is deprecated. Use 'native:compile-no-fork' instead. [INFO] Found GraalVM installation from GRAALVM_HOME variable. [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary for Drifty 2.0.0: [INFO] [INFO] Drifty ............................................. FAILURE [ 0.063 s] [INFO] Core ............................................... SKIPPED [INFO] CLI ................................................ SKIPPED [INFO] GUI ................................................ SKIPPED [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.534 s [INFO] Finished at: 2023-09-20T12:33:03+05:30 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.graalvm.buildtools:native-maven-plugin:0.9.27:build (build) on project Drifty: Image classpath is empty. Check if your classpath configuration is correct. -> [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/MojoExecutionException ```My Project structure
My CLI Module structure
![image](https://github.com/oracle/graal/assets/105960032/4529b941-2408-46d4-8ac1-3ac22c4eaf17)My GUI Module structure
![image](https://github.com/oracle/graal/assets/105960032/87981f71-d1e9-4908-9409-192a609129e8)My Core Module structure
![image](https://github.com/oracle/graal/assets/105960032/2c5426b6-f557-4c0d-8451-25b374fe5b78)The pom files of my project
The parent pom file
```xmlpom file of Core module
```xmlpom file of CLI module
```xmlpom file of GUI module
```xmlDescribe the solution you'd like.
The main problem occurring now is that GraalVM can not detect if it is a multi-modular java project (at least I cannot find any option to tell GraalVM that it has multiple modules so it needs to handle in that way). So, it would be better if GraalVM could have this feature.
Describe who do you think will benefit the most.
GraalVM users will benefit the most. Since JDK 9, modularity has been introduced and most of the large Java apps are expected to make their project modular for independent code changes, efficiency and better security. So, this feature is going to really help those people like me.
Additional context