From ab7b0484449e0495f07dfb550ba0932374c91b3f Mon Sep 17 00:00:00 2001 From: icasdri Date: Wed, 10 Aug 2016 18:13:44 -0400 Subject: [PATCH] Use gradle's project file discovery via relative path to resolve path to external dependency Math.js in res/raw --- app/build.gradle | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 37d876a..66430a4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -29,9 +29,8 @@ android { } } -String sha256sum(String pathstr) { - java.nio.file.Path path = java.nio.file.Paths.get(pathstr); - byte[] contents = java.nio.file.Files.readAllBytes(path); +String sha256sum(File file) { + byte[] contents = java.nio.file.Files.readAllBytes(file.toPath()); java.security.MessageDigest digest = java.security.MessageDigest.getInstance("SHA-256"); byte[] hash = digest.digest(contents); return String.format("%032X", new BigInteger(1, hash)); @@ -45,9 +44,9 @@ dependencies { compile 'com.android.support:design:23.1.1' ant.get(src: 'http://cdnjs.cloudflare.com/ajax/libs/mathjs/3.2.1/math.min.js', - dest: 'src/main/res/raw/math.js') + dest: file('src/main/res/raw/math.js')) - assert "6CEC5DD5257A68E172E76FC5BB1EE130C420C0DAC929E3D1955ADFC859D0707F".equals( - sha256sum("app/src/main/res/raw/math.js")) + assert '6CEC5DD5257A68E172E76FC5BB1EE130C420C0DAC929E3D1955ADFC859D0707F'.equals( + sha256sum(file('src/main/res/raw/math.js'))) }