From 684bde3f64a44fdfae484b6b1dc6c184daf7af28 Mon Sep 17 00:00:00 2001 From: John Engelman Date: Fri, 24 Feb 2023 18:27:38 -0600 Subject: [PATCH] bug: fix bad merge --- .../shadow/util/repo/AbstractModule.groovy | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/util/repo/AbstractModule.groovy b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/util/repo/AbstractModule.groovy index b12a79a46..ff62a315c 100644 --- a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/util/repo/AbstractModule.groovy +++ b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/util/repo/AbstractModule.groovy @@ -65,7 +65,8 @@ abstract class AbstractModule { private TestFile hashFile(TestFile file, String algorithm, int len) { def hashFile = getHashFile(file, algorithm) - hashFile.text = getHash(file, algorithm) + def hash = getHash(file, algorithm) + hashFile.text = String.format("%0${len}x", hash) return hashFile } @@ -73,18 +74,7 @@ abstract class AbstractModule { file.parentFile.file("${file.name}.${algorithm}") } - protected String getHash(TestFile file, String algorithm) { - file.newInputStream().withCloseable { - switch (algorithm) { - case 'sha1': - DigestUtils.sha1Hex(it) - break - case 'md5' : - DigestUtils.md5Hex(it) - break - default: - throw new IOException("Unsupported algorithm " + algorithm) - } - } + protected BigInteger getHash(TestFile file, String algorithm) { + HashUtil.createHash(file, algorithm.toUpperCase()).asBigInteger() } -} +} \ No newline at end of file