Open vlsi opened 1 year ago
The workaround is to map testEntity
provider.
In other words, this somehow works:
abstract class Entity: Named
val entities = objects.domainObjectContainer(Entity::class)
val testEntity: Provider<Entity> by entities.registering
abstract class TestService: BuildService<TestService.Params> {
interface Params: BuildServiceParameters {
val entity: Property<Entity>
}
}
val testService = gradle.sharedServices.registerIfAbsent("testService", TestService::class) {
parameters {
entity.set(testEntity.map { it }) // map { it } fixes NPE
}
}
println("testService: ${testService.get()}")
Thank you for providing a valid reproducer.
The issue is in the backlog of the relevant team and prioritized by them.
Expected Behavior
Shared build service parameters should support managed domain objects.
Current Behavior
I suspect the root cause is that
org.gradle.api.internal.provider.ManagedFactories
usestype.isAssignableFrom(PUBLIC_TYPE)
, however, most likely the proper call isPUBLIC_TYPE.isAssignableFrom(type)
.https://github.com/gradle/gradle/blob/4e3064ffb94a820888447cee2d4f533c8fc8349f/subprojects/model-core/src/main/java/org/gradle/api/internal/provider/ManagedFactories.java#L40
Context
I have trouble with moving Sigstore signing to a shared service.
Steps to Reproduce
See
Your Environment
Gradle 7.6