rvesse / airline

Java annotation-based framework for parsing Git like command line structures with deep extensibility
https://rvesse.github.io/airline/
Apache License 2.0
128 stars 20 forks source link

Replace use of @Inject with Airline specific annotation #81

Closed rvesse closed 9 months ago

rvesse commented 6 years ago

As described in #77 and #80 the use of the @Inject annotation, which is a generic Java annotation, can cause conflicts with DI frameworks like Google Guice. We use this injection as a marker for fields whose types should be scanned for Airline annotations. It may be better to replace use of this annotation with an Airline specific one e.g. @Module to avoid these conflicts.

This would be a breaking change that should go into the 3x branch

@sdorra Does this seem like a good change to make?

rvesse commented 6 years ago

May also want to consider adding a @Metadata annotation for the metadata fields that currently use @Inject

sdorra commented 6 years ago

Yes, i think this would be good change, because the inject annotation could cause problems with some other frameworks too (e.g.: cdi, weld, spring, guice, ...).

This change would break the airline-guice module, but we could use custom injection to support @Metadata.

gsmet commented 2 years ago

@rvesse I agree it would be a good change. In my case, I had to use a trick to mask the @Inject annotations used by Airline to CDI (by having a look at the annotations and types so it's a bit brittle).

rvesse commented 9 months ago

Done in 3.0.0, only @AirlineModule is supported out the box and javax-inject and jakarta-inject dependencies are now optional and the usage of @Inject MUST be explicitly opted into

gsmet commented 9 months ago

That's very cool \o/