Kelvin Chung
03/28/2024, 8:45 PMabstract class MyValueSource : ValueSource<String, MyValueSource.Parameters> {
interface Parameters : ValueSourceParameters {
abstract val client: Property<MyClient>
// other stuff
}
}
Just to clarify, then, that it's generally better to have a client constructed internally rather than have it passed in...?Vampire
03/29/2024, 11:08 AMAdam
03/29/2024, 11:19 AMVampire
03/29/2024, 12:12 PMKelvin Chung
03/29/2024, 4:15 PMabstract class MyValueSource : ValueSource<String, MyValueSource.Parameters> {
@ServiceReference
abstract val myService: Property<MyService>
private val client = myService.map { ... }
}
so that you have serializable parameters, but 1) does that even work under the hood, and 2) is it possible to do the same without @ServiceReference if it did?Vampire
03/29/2024, 6:18 PMabstract class MyService : BuildService<BuildServiceParameters.None> {
val client = "client"
}
gradle.sharedServices.registerIfAbsent("myService", MyService::class.java)
abstract class MyValueSource : ValueSource<String, ValueSourceParameters.None> {
@get:ServiceReference
abstract val myService: Property<MyService>
private val client = myService.map { it.client }
override fun obtain() = client.get()
}
println(providers.of(MyValueSource::class){}.get())
=>
Could not create an instance of type Build_gradle$MyValueSource.
> No service of type ObjectFactory available in DefaultServiceRegistry.Vampire
03/29/2024, 6:26 PM