Q:

Gradle : How to use task's output file data in another task?

Problematic
I want to update html files before packagind in war to set an HASH variable corresponding to a JS bundle compilation.
Here is what I have
<script th:src="@{/static/js/assistance/manifest.js}" charset="UTF-8"></script>

Here is what I want at the end of the process
<script th:src="@{/static/js/assistance/manifest.hereIsTheHash.js}" charset="UTF-8"></script>

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.
What I've tried (after a thousand of another try)
In order to update all my HTML files with a reference to my JS with HASH, I've tried this : 
war{

    dependsOn 'createStatsJson'

    filesMatching('WEB-INF/views/**.html'){
        filter {  String line ->
                line = line.replaceAll('assistance.js', ext.assistanceJs)
                line = line.replaceAll('manifest.js', ext.manifestJs)
                line = line.replaceAll('vendor.js', ext.vendorJs)
        }
    }
}

If I replace ext.assistanceJs, ext.manifestJs or ext.vendorJs by a string, it works perfectly.
These variables are defined in another task which read a json file :
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
}

This json file is created by another task :
task buildAssistanceJS(dependsOn: 'gulp_less', type: NpmTask) {
    args = ['--prefix', 'src/main/javascript/assistance', 'run', 'build']
}

Problem
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.
Any help is greatly appreciated.

A:

Finally found a working solution. Hope it will help.
task buildAssistanceJS(dependsOn: 'gulp_less', type: NpmTask) {
    args = ['--prefix', 'src/main/javascript/assistance', 'run', 'build']
}

def assistanceJs = ""
def manifestJs = ""
def vendorJs = ""

task createStatsJson(dependsOn: 'buildAssistanceJS') {
    doLast {
        def jsonFile = file('build/webpack/assistance/stats.json')
        def parsedJson = new groovy.json.JsonSlurper().parseText(jsonFile.text)
        assistanceJs = parsedJson.assetsByChunkName.assistance[0]
        manifestJs   = parsedJson.assetsByChunkName.manifest
        vendorJs     = parsedJson.assetsByChunkName.vendor
    }
}

war {

    dependsOn 'createStatsJson'

    filesMatching('WEB-INF/views/**.html'){ fichier ->
        fichier.filter {  String line ->
            line = line.replaceAll('assistance.js', assistanceJs)
            line = line.replaceAll('manifest.js', manifestJs)
            line = line.replaceAll('vendor.js', vendorJs)
      }
    }
}

