André Martins
05/22/2026, 10:43 AMJavaToolchainResolver is a Gradle BuildService and I'm wondering if it is possible to inject additional dependencies via constructor and @Inject .
I'm registering the dependencies via settings.gradle.sharedServices however it seems that the resolver class cannot determine those dependencies due to Unable to determine constructor argument #1: missing parameter of type MyService
In my plugin::apply I'm doing the following
val serviceRegistry = (target as SettingsInternal).services
val toolchainResolverRegistry = serviceRegistry.get(JavaToolchainResolverRegistry::class.java)
toolchainResolverRegistry.register(MyResolver::class.java)
target.gradle.sharedServices.registerIfAbsent("myService", MyService::class.java)André Martins
05/22/2026, 10:43 AMabstract class MyResolver
@Inject
constructor(
val myService: MyService,
) : JavaToolchainResolverAndré Martins
05/22/2026, 10:44 AMAndré Martins
05/22/2026, 11:17 AMAndré Martins
05/22/2026, 11:17 AMAndré Martins
05/22/2026, 11:20 AMJavaToolchainResolverAndré Martins
05/22/2026, 1:37 PMVampire
05/26/2026, 12:46 PMI'm wondering if it is possible to inject additional dependencies via constructor andAfair you cannot inject custom build services automatically anywhere except for tasks with a.@Inject
@ServiceReference annotated property,
but you have to provide the constructor argument manually when doing the creation / registration call.
But as the JavaToolchainResolverRegistry#register call does not allow to give constructor arguments or set parameters, I guess you might not be able to inject any dependency. Also JavaToolchainResolver explicitly implements BuildService<None> so has hard-coded that you cannot have parameters.
But that's mainly wild guessing, as I did not play with own toolchain resolvers yet.
Maybe you can have a setter and get the resolver service to then set the needed dependency before the resolver is used or something like that. 🤷♂️
What you should of course not do is using SettingsInternal, but instead inject an JavaToolchainResolverRegistry instance into your settings plugin like shown in the docs.