title: Gradle : How to use task's output file data in another task?
body: <p><strong>Problematic</strong></p>
  
  <p>I want to update html files before packagind in war to set an HASH variable corresponding to a JS bundle compilation.</p>
  
  <p>Here is what I have</p>
  
  <pre><code>&lt;script th:src="@{/static/js/assistance/manifest.js}" charset="UTF-8"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>Here is what I want at the end of the process</p>
  
  <pre><code>&lt;script th:src="@{/static/js/assistance/manifest.hereIsTheHash.js}" charset="UTF-8"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>The hash is generated after the JS compilation which is a gradle task (see below) and is stored in a json file created after the compilation.</p>
  
  <p><strong>What I've tried (after a thousand of another try)</strong></p>
  
  <p>In order to update all my HTML files with a reference to my JS with HASH, I've tried this : </p>
  
  <pre><code>war{
  
      dependsOn 'createStatsJson'
  
      filesMatching('WEB-INF/views/**.html'){
          filter {  String line -&gt;
                  line = line.replaceAll('assistance.js', ext.assistanceJs)
                  line = line.replaceAll('manifest.js', ext.manifestJs)
                  line = line.replaceAll('vendor.js', ext.vendorJs)
          }
      }
  }
  </code></pre>
  
  <p>If I replace <em>ext.assistanceJs, ext.manifestJs or ext.vendorJs</em> by a string, it works perfectly.</p>
  
  <p>These variables are defined in another task which read a json file :</p>
  
  <pre><code>task createStatsJson(dependsOn: 'buildAssistanceJS') {
          def jsonFile = file('build/webpack/assistance/stats.json')
          def parsedJson = new groovy.json.JsonSlurper().parseText(jsonFile.text)
          ext.assistanceJs = parsedJson.assetsByChunkName.assistance[0]
          ext.manifestJs   = parsedJson.assetsByChunkName.manifest
          ext.vendorJs     = parsedJson.assetsByChunkName.vendor
  }
  </code></pre>
  
  <p>This json file is created by another task :</p>
  
  <pre><code>task buildAssistanceJS(dependsOn: 'gulp_less', type: NpmTask) {
      args = ['--prefix', 'src/main/javascript/assistance', 'run', 'build']
  }
  </code></pre>
  
  <p><strong>Problem</strong></p>
  
  <p>Unfortunately, it don't works as gradle tels me that the json file does not exists. I supposed it's an build lifecycle related problem but I don't know how to achive this.</p>
  
  <p>Any help is greatly appreciated.</p>