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

jpms / modular dagger #2636

Open
h908714124 opened this issue May 20, 2021 · 4 comments
Open

jpms / modular dagger #2636

h908714124 opened this issue May 20, 2021 · 4 comments

Comments

@h908714124
Copy link

h908714124 commented May 20, 2021

I've noticed jlink doesn't work unless every dependency has a module info.
I've tried and got this far:

Error: automatic module cannot be used with jlink

It seems dagger doesn't even set Automatic-Module-Name in the MANIFEST.
Are there any plans to release a dagger version with module-info.java included?

Because currently it seems like code that uses dagger can't be fully modular, and it looks like that means you won't be able use jlink, to make a custom jdk image of it.
Likewise, any library code that uses the dagger annotations will also become a roadblock to modularization.
This seems pretty bad. I've just finished adding dagger to my pet command line parser.
Will I have to rip it out again? Ugh.
Custom runtime images are going to be very important for command line applications, imho.
Please respond.

@tbroyer
Copy link

tbroyer commented May 20, 2021

Duplicate of #1079

@h908714124
Copy link
Author

h908714124 commented May 20, 2021

@tbroyer sure? The other issue seems to be about adding an "Automatic-Module-Name". But I'm afraid that's not even good enough for jlink. Read the jlink error again: automatic module cannot be used with jlink

@Chang-Eric
Copy link
Member

Thanks for the reminder about #1079. I had started on the work to add the automatic module name but never finished submitting it.

For the bigger question of modularizing Dagger, I don't think it is a high priority for us right now when compared to other work we have planned. I'm going to leave this open since it is something we should do, but I can't say when it will be done or that we are looking at this with any urgency right now. Sorry about that =\

@h908714124
Copy link
Author

h908714124 commented May 26, 2021

Hi, thanks for the update. I figured I can use dagger in jbock and still be fully jlink-compatible. This is possible because jbock is an annotation processor itself, so it is not a runtime dependency for its users. I added a module-info to its runtime jar jbock-annotations, which don't use dagger internally, and that's good enough. So it's not a high priority for me anymore.

However, this happy workaround is apparently not available for anything that isn't an annotation processor itself. Dagger cannot be used in a basic jlink-packaged application, like this one. Is that correct?

Another idea: To modularize dagger, it would be enough to add the module descriptor to its runtime jar com.google.dagger:dagger. But this depends on javax.inject, which might be a problem. I found this thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants