Implicit task dependency on directory

Thank you for your answer, Björn.

I know that using the same output directory is considered a code smell.
In our use case we have a custom task (TransformXml) which is executed multiple times with different parameters. After all of them are executed I want a task to pack them all into 1 zip file. My hope was, that the zip-File task could trigger all of these tasks at once (like mentioned here: Gradle 7.0 seems to take an overzealous approach to inter-task dependencies)

Can you help me with another similar problem:
I have a Task to extract an archive. Now I want another task to work with the extracted files and have an implicit dependency between them. How do I specify the output-input-relation correctly? I tried:

val unzip = task<Copy>("unzip")  {
    from(zipTree(myConfiguration.singleFile).matching {
        include("de/foobar/**")
    }.files)
    into("build/foobar")
}

task<ZipConsumer>("zipConsumer")
{
    inDir.set(unzip.destinationDir)
}

abstract class ZipConsumer: DefaultTask() {
    @get:InputDirectory
    abstract val inDir : DirectoryProperty

    @TaskAction
    fun action() {
        println("ZipConsumer: ${inDir.asFile.get().absolutePath}")
    }
}

But again, the unzip-Task is not executed automatically when I call zipConsumer. I really don’t want to use dependsOn because I can totally understand that this is not the intended way.