-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add module-info to micronaut-inject and micronaut-core #6395
Comments
@msgilligan so this would be a good area to contribute to the framework since nobody on the Micronaut team that I am aware of has a good understanding of what it takes to make Micronaut modular nor add tests for modularity Maybe you and @aalmiray could advise |
Happy to support here, too. |
I would welcome any advice from @aalmiray, @gunnarmorling, @HanSolo, @siordache, or @sormuras -- all of these guys all know much more about modules than I do. I've had good luck running Micronaut in a modular JavaFX environment after reprocessing with the @siordache 's Badass JLink Plugin, but the applications have been fairly simple and I have not been able to implement much automated testing yet. (A real benefit for me has been the ability to create reactive services -- in my case using RxJava 3 -- that are portable between a modular JavaFX application and a non-modular Micronaut server) My proposal would be to do the following:
This is based on the following assumptions: A. The risk from adding B. The presence of C. The Micronaut team is comfortable communicating that the modular support is "incubating" (or whatever terminology is most appropriate) How does this approach sound to everyone? |
Update: It looks like the |
Another option is the badass-jar-plugin, which is a lightweight plugin dedicated to this task. It allows both options (adding the module-info.class file directly to the JAR or creating a Multi-Release JAR). |
Thanks, @siordache! Yes, it looks like the badass-jar-plugin is simpler and a better fit for our relatively minimal requirements. |
I'll wait for more feedback, but I'm leaning towards creating a draft pull request for adding a @graemerocher do you know of any tools in the Micronaut ecosystem that might choke on a |
Do not put |
Is there a specific reason? @sormuras (in a separate conversation) recommended option 1 (root of jar.) I'm happy to do it either way and the |
If you put it at the root then it becomes a class visible to everyone, just like any other class is. If you put it at |
All JUnit's modules have their Taking
This reads just simpler:
|
Note that in terms of
Update: I just discovered that
|
On Friday I looked at @siordache 's So it looks like the 2.0.0 version of |
Update: I've been testing I would like to try using it to make a PR. I understand that Micronaut 4 will use/require JDK 11, which will eventually make use of the plugin unnecessary. This is great news! Not sure if I should wait for a 4.x branch or try to start with the plugin... |
4.x is now being worked on. Is this on the radar for the new version or is the idea dropped? |
idea hasn't been dropped certainly can be added now in 4.x but would like to see community contribution because none of the team use the module system |
Thanks for the answer,
Edit:
|
Opened draft PR: #9002 |
I now experimented a bit with modularizing micronaut runtime components and discovered a few topics that are problematic for the adoption of JPMS. While I could still implement it, it would cause changes and I would need to make a decision, which I don't feel entitled to. These are the most problematic points that I would like to be decided by the micronaut team, or at least somebody who is working on micronaut for longer.
I hope these issues are not a "won't happen" for JPMS support. Sorry for creating such a "mega thread" but I tried to communicate everything I found (still quite new to OSS) and not make it more work for you than it would be to do it yourself, thank you. TL;DR it is problematic - there are design issues that need decisions from the core team. |
Thanks, updated my question. |
|
|
Also to expand on the |
Maybe I am misunderstanding, but the
And since So while
compileOnly project(':core-processor') For example the class Maybe there is a misunderstanding how JPMS deals with runtime/compile time dependencies:
|
as expressed by |
Ok for everyone tracking the issue: And the micronaut team seems to not want this kind of breaking changes so as far as I see it there won't be modular support for micronaut For more detailed reasoning read the last message in my PR linked to this issue. Maybe I overlooked something and my reasoning is wrong. #9002 (comment) |
Thanks for the info.
You must mean PR #7608 |
Doing a change like this without knowledge about internal structure and functionality is hard to do without "standard maintainer" knowledge. Still I spent a week of free time inspecting and experimenting with the structure to understand it, and tried different approaches to make Jpms work in my PR. The only reason why I couldn't add a "serious contribution" is that internal breaking change that is a no go for you/the project. |
agreed, that it takes knowledge of the framework. We also have to balance out whether a change will be worth it, and frankly breaking our existing substantial user base 99% of which do not use the module system to support a tiny fraction of users who are interested in the module system is not worth it. If there is a way to implement this change and not break the entire framework and someone is willing to invest the time to do it I am happy to jump on a call and pair program with that person if necessary. |
I very much agree that a user facing breaking change (ABI/API change) would be unacceptable - as far as I understand the breaking change that my PR introduces is not userfacing but only internal to downstream processors such as
Correct me if this assessment is wrong - in case it is true I would argue that the amount of affected users is minimal compared to the improvement that the Jpms provides. Do you have any Intel about how many users (that are not under the micronaut organization) have created custom micronaut processors and would be affected? For the "not BOM"/plugin users the download metrics on maven central could somewhat give insight. |
The change alters the package This impacts many modules beyond OpenAPI. Any module that plugins into the compiler would be broken (Micronaut Data, JAX-RS, Security, OpenAPI, Micrometer, Validation etc.). And then we would have to find a solution for the loading of We are about to release Micronaut 4, the next time this could be will be possible to re-evaluate would be in Micronaut 5 |
indeed, thats what I meant with "such as OpenAPI". (mostly) every
Probably due to a lack of knowledge - but i do not see where adding JPMS support breaks incremental compilation - i would/did not touch the
I was afraid this would happen - but I understand. Let's talk about this again once Micronaut 5 is in the talks. |
+1 to JPMS as it is now unfortunately required for use with GraalVM's guest runtimes |
Tip: you could take a look at Inverno |
Thanks @palexdev, but we are deeply committed to Micronaut, so we would be more likely to apply patching or wait for v5 than use a new framework. I don't think I can add anything to this already extensive discussion, but I have learned of several newer escape hatches for JPMS, so maybe I can come up with an experiment, and if so, I'll report back. |
We have decided not to target this issue for Micronaut Framework 5. |
Wait, but, @sdelamo; is there still an open question with that? If not, can there be? I missed any opportunity for feedback and JPMS is a key priority for us. I can explain why and what impact we would see that having. Maybe such things have already been considered but it is worth covering before Micronaut 5 work begins in earnest. FWIW, I'm nearly done with some investigation about options to make JPMS support work with Micronaut at v4 as well. I think those could help inform the discussion if it could be extended just a tiny bit. |
@sgammon definitely would be interested to understand your findings |
@sgammon if there are simple changes we can make to make module support easier (such as removing split packages) we are willing to implement those changes in 5.0. However we decided not to spend significant time fully supporting modules. |
@yawkat I made a PR a year ago approximately that implemented JPMS and did smoke testing with my personal projects. As far as i can tell there is only 1 split package problem that blocks JPMS adoption. In my PR there should be a lenghty explaination. So unless in between my PR and now a split package was added micronaut is only 1 (semi internal!) package rename away from being easily portable to JPMS. My PR is massively outdated (i assume) but it could still be used as a template |
we are happy to consider this split for Micronaut 5 or 6 or whatever makes it possible as long as a reasonable breaking change for the community. Perhaps the build tools could be updated somehow to merge the incrementally built be index in |
To clarify because it seems to be unclear what changes would be required. The problemThe only issue is one package
Why/How does it happenFrom the framework author's pov this is a non issue because they consider Which leads to errors such as SolutionsA year ago, i suggested 2 relatively easy fixes to resolve this issue Rename
|
solution 2 seems completely viable. The |
btw with #10842 the service loading issue discussed earlier is resolved |
Looking at the gradle file of Also, i just tested with the newest version and using module-info.java work! This is not an in-depth test but it seems that you have "accidentally" fixed JPMS integration 😄 when restructuring. While you do not have "native" modules (you do not have module-info.java files) micronaut is now usable with JPMS (idk as of which version) My post above was based on the information i acquired in ~v3.9.0 to v4.0.0. It seems that adding module-info files to micronaut modules (to make sure jpackage & jlink work) should be rather trivial! and could be largely based off of my very, very old PR To all who still experience the problem: Make sure that you do NOT have |
@nbrugger-tgm Can you contribute an example project that is using JPMS? |
Sure I will do it on Monday |
Here is an example project: https://github.com/nbrugger-tgm/micronaut-reproductions/tree/main/jpms-example |
Feature description
It has been possible to use Micronaut dependency injection as a Java Module System-compatible standalone dependency injection framework by processing the jars with tools like Badass Jlink Plugin since the 1.x series. As Micronaut and its dependencies have evolved, it is now possible for (at least)
micronaut-inject
andmicronaut-core
to be "fully modularized" by addingmodule-info.java
files to their jars.This can be done while retaining Java 8 compatibility via two different mechanisms:
module-info.class
file directly to an otherwise JDK8-compatible jarmodule-info.class
from JDK8The current dependency tree looks like:
Analyzing each 3rd-party dependency:
slf4j-api
: Is an automatic module that can be updated by applications to 2.0.0-alpha5 or later to get fully-modular:javax.annotation-api
- is an optional dependency that can be arequires static
jakarta.inject-api
- has been updated to fully-modular 2.0.1 via 2860a46jakarta.annotation-api
- fully-modularsnakeyaml
- is an optional dependency that can be arequires static
So it looks like
micronaut-inject
andmicronaut-core
are ready to go fully modular.It would be great to see these two jars released with
module-info
support in Milestone 3.2.0I'm not 100% sure my analysis is correct, but I'd like to at least start a discussion here.
The text was updated successfully, but these errors were encountered: