Must delete .gradle directory if broken build didn't produce the output file

Mostly the inputs.files and outputs.files is working but for a native build I contributed a task that wasn’t running correctly due to a bug in my build. The bug meant the output file wasn’t created (the actual output was going to the wrong path). So as I understand it gradle marked the output as expected to be missing (as I’ve read in other posts).

Once I corrected this gradle still wouldn’t re-run the task unless I removed the outputs.files and inputs.files. I couldn’t see any solution until I realised that the hashes were probably cached in the .gradle directory. I deleted it and it was working fine, it was up to date when I expected and deleting the output caused a rebuild.

I am using 2.11 and the tasks were defined as:

tasks { allTasks ->
    $("components.main").binaries { binaries ->
      binaries.values().each { binary ->
        if (binary.toolChain.name == 'pnacl' && binary.buildType != buildTypes.debug) {
          def finalizeTask = binary.tasks.taskName("pnaclFinalize")
          def pexeFile = binary.tasks.link.outputFile.getAbsolutePath() + ".pexe"
          allTasks.create(finalizeTask) {
            dependsOn binary.tasks.link
            FileCollection myInputs = files(binary.tasks.link.outputFile)
            inputs.files myInputs
            FileCollection myOutputs = files(file(pexeFile))
            outputs.files myOutputs
            println binary.tasks.link.outputFile
            println file(pexeFile)
            doFirst {
              def finalizeProcess = [toolChains.pnacl.ext.finalizeCommand, "-o", pexeFile, binary.tasks.link.outputFile.getAbsolutePath()].execute()
              finalizeProcess.waitFor()
            }
          }
          def zipTask = binary.tasks.taskName("zip")
          println pexeFile
          allTasks.create(zipTask, Zip) {
            dependsOn finalizeTask
            FileCollection zipFiles = files('csdk.nmf', binary.tasks.link.outputFile, pexeFile)
            destinationDir project.buildDir
            baseName binary.component.baseName
            inputs.files zipFiles
            from zipFiles
            outputs.files archiveName
          }
          binary.tasks.build.dependsOn zipTask
        }
      }
    }

The failing task was the pnaclFinalize one and the other was doing up to date checks correctly the whole time.