Experimental combined task for download and checksum verification

Not working yet:
<https://github.com/michel-kraemer/gradle-download-task/issues/108>.
This commit is contained in:
Ben Liblit 2018-03-05 13:05:31 -06:00
parent ba455f4737
commit 4749fe47c0
1 changed files with 18 additions and 8 deletions

View File

@ -6,23 +6,33 @@ sourceSets.test.java.srcDirs = ['src']
// download JLex
//
task downloadJLex {
outputs.file 'src/JLex/Main.java'
doLast {
class VerifiedDownload extends org.gradle.api.DefaultTask {
@Input String src
@Input String checksum
@OutputFile File dest
@TaskAction
downloadAndVerify() {
download {
src 'http://www.cs.princeton.edu/~appel/modern/java/JLex/current/Main.java'
dest outputs.files.singleFile
src this.src
dest this.dest
overwrite true
onlyIfModified true
useETag true
}
verifyChecksum {
src outputs.files.singleFile
checksum 'fe0cff5db3e2f0f5d67a153cf6c783af'
src this.dest
checksum this.checksum
}
}
}
task downloadJLex(type: VerifiedDownload) {
src 'http://www.cs.princeton.edu/~appel/modern/java/JLex/current/Main.java'
checksum 'fe0cff5db3e2f0f5d67a153cf6c783af'
dest file('src/JLex/Main.java')
}
task cleanDownloadJLex(type: Delete) {
delete files(downloadJLex).singleFile.parent
}