https://gradle.com/ logo
#community-support
Title
# community-support
z

Zak Taccardi

09/28/2022, 7:27 PM
Is a pattern like this valid?
Copy code
@OutputDirectory val outputDir: Property<Directory> = objects.directoryProperty()

@Internal
val outputFile: Provider<RegularFile>
    get() = outputDir
        .map { it.file("SharedGroovyCode.groovy") }
outputDir
is the main output here, and
outputFile
is just an accessor to more conveniently access a subset of that output downstream.
c

Chris Lee

09/28/2022, 7:28 PM
yes. this is useful to encapsulate logic & hide the Property state (Provider is nicely read-only).
z

Zak Taccardi

09/28/2022, 7:28 PM
thanks! bit weird the naming is
@Internal
if it can expose outputs as inputs to other tasks
v

Vampire

09/28/2022, 9:30 PM
But why
Property<Directory>
and not
DirectoryProperty
?
Especially as you could then do
outputDir.file("Shared...")
z

Zak Taccardi

09/28/2022, 9:35 PM
Good point!