summaryrefslogtreecommitdiff
path: root/buildSrc/src/main
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2015-12-22 16:34:33 +0100
committerYves Fischer <yvesf-git@xapek.org>2015-12-22 16:34:33 +0100
commitb2d145df57a10699b722d8fe84a759e43f0375c7 (patch)
tree403f5465b1ba2403a8bbd5101fd8430faf775c12 /buildSrc/src/main
parentc90386a74cf61db6ac95f24743b4fb8d00f881ce (diff)
downloaddebian-packages-b2d145df57a10699b722d8fe84a759e43f0375c7.tar.gz
debian-packages-b2d145df57a10699b722d8fe84a759e43f0375c7.zip
use org.xapek.yvesf : gradle-download-task
Diffstat (limited to 'buildSrc/src/main')
-rw-r--r--buildSrc/src/main/groovy/buildSrc/DownloadTask.groovy61
1 files changed, 0 insertions, 61 deletions
diff --git a/buildSrc/src/main/groovy/buildSrc/DownloadTask.groovy b/buildSrc/src/main/groovy/buildSrc/DownloadTask.groovy
deleted file mode 100644
index 1a49dd5..0000000
--- a/buildSrc/src/main/groovy/buildSrc/DownloadTask.groovy
+++ /dev/null
@@ -1,61 +0,0 @@
-package buildSrc
-
-import org.apache.commons.codec.binary.Hex
-import org.gradle.api.DefaultTask
-import org.gradle.api.tasks.*
-
-import java.security.MessageDigest
-
-class DownloadTask extends DefaultTask {
- @OutputFile
- File destFile
-
- @Input
- URL source
-
- String sha256sum
-
- void setSource(URL url) {
- this.@source = url
- if (destFile == null) {
- final basename = url.path.substring(url.path.lastIndexOf('/') + 1)
- destFile = new File(project.buildDir, basename)
- }
- }
-
- void source(URL url) {
- setSource(url)
- }
-
- void source(String sourceUrl) {
- source new URL(sourceUrl)
- }
-
- void sha256sum(String sha256sum) {
- this.@sha256sum = sha256sum
- }
-
- private void checkSha256Sum(File file, String sum) {
- final md = MessageDigest.getInstance('SHA-256')
- final digestBytes = md.digest(file.bytes)
- final digestHex = Hex.encodeHexString(digestBytes)
- if (digestHex != sum) {
- throw new TaskExecutionException(this,
- new Exception("Checksum mismatch, expected ${sum} got ${digestHex}"))
- }
- }
-
- @TaskAction
- void doExecute() {
- final tempFile = new File(destFile.path + '_download')
- project.logger.info("Download ${source} to ${tempFile}")
- ant.get(src: source, dest: tempFile, verbose: true)
-
- if (sha256sum) {
- checkSha256Sum(tempFile, sha256sum)
- }
-
- project.logger.info("Rename downloaded ${tempFile} to ${destFile}")
- ant.rename(src: tempFile, dest: destFile)
- }
-} \ No newline at end of file