Support to @Inject a SoftwareComponentFactory into a BuildService #28956
Labels
a:feature
A new functionality
closed:not-fixed
Indicates the issue was not fixed and is not planned to be
Expected Behavior
It would be nice if a SoftwareComponentFactory could be given to a BuildService via Injection
Current Behavior (optional)
It doesn't seem to be possible to inject a SoftwareComponentFactory directly into a BuildService via the Inject annotation.
Notice that https://docs.gradle.org/current/userguide/dependency_management.html#sec:publishing-custom-components says:
I also made a repro project at https://github.com/mathjeff/gradle-samples-2/tree/main/buildservice-componentfactory where I tried to inject a SoftwareComponentFactory directly into a BuildService like this:
which gives this output:
Context
In AndroidX we're trying to migrate towards compatibility with project isolation which entails more artifacts to publish from some projects and consume from other projects, so we're looking into making some helper methods for making this easier.
The first thing I tried was to directly inject the SoftwareComponentFactory into the BuildService, but that didn't work.
As a workaround it seems to work to inject the SoftwareComponentFactory into a Plugin which can then pass it to the BuildService
Thanks
The text was updated successfully, but these errors were encountered: