Hi, is there a simple way to make some configurati...
# community-support
t
Hi, is there a simple way to make some configuration-time information from a custom settings plugin available to all (sub) projects in a build?
v
shared build service I'd say, as most times when it is about sharing things in a build cross-project
You use
gradle.sharedServices.registerIfAbsent(...)
in the settings plugin and then in the project builds you can get the service and query the values you set or wired from the settings plugin.
I for example use that with a boolean property in the service as a marker that the settings plugin is applied. Then in the project plugin I get the service and if it is not set to
true
I can complain that the settings plugin should also be applied.
t
Ok, will try that, thanks!
👌 1
Hrm... so where do I put the types so that they're accessible then?
Because I have to access things via
Copy code
gradle.sharedServices.registrations.getByName("my.name", MyType::class.java)
v
Not sure what you mean. The types that are accessible in the settings plugin are also accessible in the project build code. The settings script class loader is in the ancestors of the build script class loaders.
t
Yeah, stupid me, the class was
internal
, as I copied it from the sample
Thanks again!
👌 1
I guess this now my new favourite thing to distribute settings, awesome!
👌 1