-
Notifications
You must be signed in to change notification settings - Fork 25
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 annotation for module-path InjectPlugin
auto-detection
#722
Conversation
@rbygrave yeah I'm good with this. (unless you have a better name for the annotation) |
Why do you want to add this? Why do you think we need this? |
With this, I can create plugin libraries that will be auto-detected by avaje inject without needing a consumer to have a maven/gradle plugin. I've got a couple of internal libraries that this would be convenient to have on. Essentially, it is the natural extension of #716. |
Currently, we need to use the
This PR makes it so that the
As I like to make use of JPMS, this PR is very convenient for me |
Like what? Why are you creating plugins rather than using "normal dependencies"? That is, I'm not really expecting many people to create plugins at all.
People just need to register a service loader right, so they don't need a maven/gradle plugin for that? I don't get it?
I don't see that no, in that I'm really expecting people to use "normal dependencies" and only very few expert users will create plugins. So no I don't see that point. |
A plugin I have is for one of our encryption libraries. It only exposes a single class so a plugin that provides a single instance is a natural choice. I have a similar structure to the jsonb/validator plugins to configure it using the
Yeah but for the people who do, this would be pretty convenient for their consumers. |
Ah wait I think I might see the disconnect. I'm talking about the consumer of custom Suppose I create a plugin @ServiceProvider
public class EncryptPlugin implements InjectPlugin {
@Override
public Class<?>[] provides() {
return new Class<?>[] {Encryptor.class};
}
@Override
public void apply(BeanScopeBuilder builder) {
Encryptor e = ...
builder.beans(e);
}
} When someone pulls in the maven dependency for this library and tries to use it like this: @Singleton
public class WireOther {
Encryptor e;
public WireOther(Encryptor e) {
this.e = e;
}
} Compilation will fail if any of these are true
In these situations the The maven plugin solves this by using the The obvious problem with this approach is that users must not forget to add the maven plugin or else things won't compile. The point of this PR is to make it easier for users to consume custom plugins if they happen to be using JPMS. |
@rbygrave perchance can you deploy an RC when you find the time? |
Hmmm. https://s01.oss.sonatype.org is currently returning status code 503 ... but yeah will do it shortly hopefully. |
@PluginProvides
annotation that the processor can autodetect viagetAllModuleElements
(not sure I like the name though, feel free to change it if you got a better one)resolves #724