title: How to read output from a task?
body: <p>I created a task to compute a version name from the latest git tag. I am basically writing a computed tag into a file in the build directory. However, when I try to read this text from file gives me below error:</p>
  <blockquote>
  <p>/path/to/project/build/intermediates/versioning/versionName.txt (No such file or directory)</p>
  </blockquote>
  <p>VersionNameTask.kt</p>
  <pre><code>abstract class VersionNameTask : DefaultTask() {
  
        @get:OutputFile
        abstract val outputFile: RegularFileProperty
  
        @TaskAction
        fun action() {
          outputFile.get().asFile.writeText(project.computeGitTag)
        }
      }
  </code></pre>
  <p>This is how I try to read the content of the generated file.</p>
  <pre><code>private fun BaseAppModuleExtension.configureVersioning(project: Project) {
    onVariantProperties.withBuildType(&quot;release&quot;) {
      val versionNameTask = project.tasks.register&lt;VersionNameTask&gt;(
        &quot;computeVersionNameFor${name.capitalize(Locale.US)}&quot;
      ) {
        group = &quot;versioning&quot;
        outputFile.set(project.layout.buildDirectory.file(&quot;intermediates/versioning/versionName.txt&quot;))
      }
      val mappedVersionNameTask = versionNameTask.map { it.outputFile.get().asFile.readText() }
  
      outputs.forEach { variantOutput -&gt;
        variantOutput.versionName.set(mappedVersionNameTask)
      }
    }
  }
  </code></pre>
  <p>Can you please tell me what I am doing wrong? I assume I am reading the file content before the task generates it but why is this happening? I am using <code>map</code> transformation and shouldn't it wait for the file to be created first? I couldn't find anything useful. Thanks!</p>