Skip to content

Build a CompilerManager through ServiceLoader - #524

Closed
slachiewicz wants to merge 1 commit into
masterfrom
agent/compiler-service-loader
Closed

slachiewicz wants to merge 1 commit into
masterfrom
agent/compiler-service-loader

Conversation

@slachiewicz

Copy link
Copy Markdown
Member

DefaultCompilerManager.fromServiceLoader(ClassLoader) builds a compiler manager from META-INF/services instead of a Sisu container, so a plugin written to the Maven 4 API, which cannot inject Sisu components from its own jars, can create one and bind it with a @Provides method. The Sisu wiring is unchanged.

Compilers are keyed by their @Named value, as Sisu does. @Singleton compilers (javac, eclipse) are shared; aspectj, csharp and javac-errorprone get a new instance per getCompiler call, as with Sisu. A provider that cannot be loaded is skipped with a warning. Two small changes make the compilers load without a container: JavacCompiler creates its JavaxToolsCompiler when nothing injects one, and AbstractCompiler creates its deprecated Plexus logger wrapper on first use, because the Plexus logging API is only provided by Maven at run time.

The new plexus-compiler-service-loader-test module checks that each compiler module's services file lists the same classes as its generated Sisu index.

Same approach as apache/maven-scm#1418; context in apache/maven#13302.

Verified: mvn verify → full reactor green, 12 ITs; 5 new tests.

Each compiler is listed both in the Sisu index and in META-INF/services; ServiceLoaderCompilersTest fails when the two lists differ. AbstractCompiler creates its Plexus logger wrapper lazily so compilers load without the Plexus logging API; do not move it back into the constructor.
@slachiewicz

Copy link
Copy Markdown
Member Author

Not needed: Maven 4 API mojos will inject Sisu components from their plugin realm through javax.inject (apache/maven#13326), so the Maven 4 port injects this manager as on Maven 3. Tracked in apache/maven#13309.

@slachiewicz slachiewicz closed this Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request wontfix This will not be worked on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant