Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Cannot create custom Guice bindings with a maven extention #41

Closed
HomeOfTheWizard opened this issue Jun 29, 2023 · 2 comments
Closed

Cannot create custom Guice bindings with a maven extention #41

HomeOfTheWizard opened this issue Jun 29, 2023 · 2 comments

Comments

@HomeOfTheWizard
Copy link
Contributor

Hi,
I tried to use a custom Guice module to bind an specific instance of class in an extension, following this tutorial.
https://github.com/eclipse/sisu.plexus/wiki/Plexus-to-JSR330#custom-bindings

But couldnt make it work.
https://github.com/HomeOfTheWizard/demo-maven-extension.

When I lookup in the container, I see the module is picked up, but cannot find the component that I bind with the module.
Here is what I do

session.getContainer().lookup(AbstractModule.class,"myModule"); //gets MyModule.class
session.getContainer().hasComponent("myComponent"); // return false.

I saw that the session.getContainer() is deprecated.
Maybe there is a better API to search in the sisu container ?
Can you please help me 🙏

@dsyer
Copy link

dsyer commented Jul 6, 2023

I think it might work, actually. You can see that someone thought about it here: https://maven.apache.org/ref/3.9.0/maven-core/core-extensions.html (look for commented out com.google.inject packages). I updated my sample https://github.com/scratches/plugin-demo to use this approach.

@HomeOfTheWizard
Copy link
Contributor Author

Ok I see now. it was my META-INF/maven/extension.xml file that wasnt exported correctly. indeed it works !

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

No branches or pull requests

2 participants