Hi everyone, I've been working on Maven issue #13989: Support pure maven-di build extensions.
The implementation now supports project-aware native type and packaging resolution for pure V4 extensions and V4 plugins used as build extensions. It also handles project-specific extension configuration when multiple projects share the same extension artifact. The targeted validation currently passes: - 65 focused unit tests. - Full 88-module integration "verify". - Pure V4 extension integration test. - Plugin-as-extension configuration test, including parallel projects with different configurations. - Legacy extension compatibility test. During a subsequent lifecycle review, I identified one architectural question that I would like to clarify before considering the implementation complete. Currently, native V4 build-extension providers are discovered into both: 1. The shared root Maven injector. 2. Project-owned injectors, where providers receive project-specific configuration. Project-owned injectors are disposed at "SessionEnded". However, registrations in the shared root injector remain, meaning extension classes and their classloaders can remain reachable after the session ends when the Maven container is reused. I see two possible directions: Option A – Container-lifetime registration Keep root-injector registrations and explicitly treat build-extension provider visibility and retention as lasting for the lifetime of the Maven container. This preserves session-level lookup compatibility but retains extension references beyond individual sessions. Option B – Project-scoped registration Keep project-specific build-extension providers exclusively in project-owned injectors, while retaining root registration for core and genuinely container-scoped services. This would give extension providers a more clearly defined project/session lifecycle, but changes the visibility semantics of session-level service lookup. I do not think selective unbinding is safe with the current injector implementation because dependent bindings, singleton instances, and concurrent lookups may retain references to the extension. My question is: Should V4 build-extension providers be available through session-level service lookup, or should their visibility be limited to project-aware lookup APIs? I would appreciate guidance on the intended lifecycle and visibility contract before making further architectural changes. Thanks!
