The proper way to share information

Hello :slightly_smiling:

I’m quite new to Gradle and I’m not sure I completely understand what’s the proper way to share information between tasks. Please consider the following example:
I have a task that extract value from a file. This value is being used couple of time across the build process. I’m not completely sure what is the right way to expose it and making sure the file is only access one time. Here is an example:

task extract(type:Exec) {
    commandLine 'cmd', '/c', 'echo HI'
    standardOutput = new ByteArrayOutputStream()

    ext.value= {
        return standardOutput.toString()

This doesn’t feel right, because it means every-time I want to use this information, I need to dependOn it:

task test(dependsOn: extract) << {
    println extract.schemeName()

I think a better way would be perhaps to save this information in an ext block, but I’m not sure if this will prevent multiple accessing to the file, and if I can even use this code (as it require the task type to work).