I have the following task configuration where I’m ...
# community-support
c
I have the following task configuration where I’m setting a configurable file tree (“inputFiles”) from to be the outputDirectory of another task, I had guessed that setting this would create a dependency between the two tasks but it doesn’t. Do I have to set built by in this case?
Copy code
project.tasks.register<PrepareTestSuite>(
    TASK_NAME_PREPARE_SUITE,
).apply {
    configure {
        description = TASK_DESCRIPTION_PREPARE_SUITE
        group = GROUP

        inputFiles.apply {
            from(syncRepositoryTask.flatMap { it.outputDirectory })
            include("**/*.wast")
            exclude("**/proposals/**")
            exclude(extension.excludes.get())
        }

        wast2Json.set(resolveWast2JsonTask.flatMap { it.outputFile })
        outputDirectory.set(extension.testSuiteGenDirectory)
    }
}
v
Why do you do apply and configure instead of right away
tasks.register(...) { task configuration here }
But anyway, the answer to your question maybe is the
flatMap
. It loses task dependency and replace by the inner provider. So it depends on how the
outputDirectory
is defined. If it is an
@OutputDirectory
it should have the task dependency itself and it should probably work. But hard to say without a complete MCVE.
c
The answer is I don’t know what I’m doing 🤣 The apply and configure block was just because I was assigning the result of the register task into a variable and configure returns Unit so I couldn’t do that. I’m guessing that these should always be separate?
v
What should be separate?
Just directly give the configure closure to the register call as second argument as I showed
c
Ah I see
Output directory is a :
Copy code
@get:OutputDirectory
abstract val outputDirectory: DirectoryProperty
This is why I thought it would work, but settings builtby fixes it for now
v
It probably should, yes