Can Shared Build Services parameters receive tasks outputs as inputs?

Hi! I’d like to know if a Shared Build Service can receive a task’s output as its input, and that’d ensure that said task will always run before the service is created?

Doesn’t seem so.
I tried with this:

interface FooParams : BuildServiceParameters {
    val bar: RegularFileProperty
abstract class Foo : BuildService<FooParams>
abstract class Baz : DefaultTask() {
    abstract val out: RegularFileProperty
    fun doIt() {
val baz by tasks.registering(Baz::class) {
val fooService = gradle.sharedServices.registerIfAbsent("foo", Foo::class) {
    parameters {
        bar.set(baz.flatMap { it.out })
val bam by tasks.registering {
    doLast {

and run task bam.
No tasks other than bam were run and it complained that the file does not exist.
But maybe that would be a candidate for a feature request on GitHub, especially if you can describe a proper use-case.

1 Like

I see, many thanks for checking! - I got some similar results but I was wondering if I was doing something wrong so I wanted to double check here :slight_smile: my use case might not be too common though, basically there is one task, that I believe uses the Worker API to have many instances running in parallel, that I don’t create and don’t have control over, but it has an API that allows me to run my code as part of its execution, so this task is in between Gradle’s APIs and my code, but I need some other tasks to run prior to my code, which is in a Build Service so that it can be reused across all the instances of the task that I don’t control, and so far I haven’t found a way to do so.

I’ll create a ticket anyway to see if that could be useful for other people too.