helidon-io / helidon

Java libraries for writing microservices
https://helidon.io
Apache License 2.0
3.52k stars 564 forks source link

4.x: Helidon Inject - only API dependency to compile #7957

Open tomas-langer opened 1 year ago

tomas-langer commented 1 year ago

The current implementation requires runtime to be present at compilation time (through dependencies of the generated code).

This should be changed, so only API is required.

Planned changes against the inject-update branch in Helidon repository:

tomas-langer commented 1 year ago

An attempt will be done to have this backward compatible (by keeping the bind methods available and deprecated).

The new approach is being designed as follows:

  1. ServiceDescriptor will be code generated - this type will depend only on API, and will use class model to be generated
  2. The runtime will pick up the generated service descriptors using a module (similar to what is done right now) by binding the descriptors to the binder
  3. Then an appropriate service provider will be discovered (through service loader, using an ID that is code generated together with the service descriptor (default is a default method on the interface)
  4. These implementation take care of all the lifecycle tasks (activation, deactivation etc.)

Most of the code is either re-used or copied from existing implementation, with focus on:

tomas-langer commented 12 months ago

Some conceptual changes are required to align with Helidon style and coding guidelines. The PR will contain appropriate readme, high level info:

trentjeff commented 11 months ago

You need to add a dependencies-test making use of the enforcer plugin to ensure that there is no inject runtime in the cp. This is to avoid regressions in this area.