blob: 8abaec5ffc7087183773ef8978b0224d3c7a8580 [file] [log] [blame]
import java.security.MessageDigest
class GenSHA256 extends SourceTask {
def outputDir
@OutputDirectory
File getOutputDir() { project.file(outputDir) }
@TaskAction
void writeSHA256s() {
source.each { file ->
MessageDigest digest = MessageDigest.getInstance("SHA-256")
digest.update(file.bytes)
def checksum = new BigInteger(1, digest.digest()).toString(16).padLeft(32, "0")
new File(outputDir, file.name + ".sha256").text = checksum
}
}
}
project.ext.GenSHA256 = GenSHA256.class