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