diff options
Diffstat (limited to 'build.gradle')
-rw-r--r-- | build.gradle | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/build.gradle b/build.gradle index 6e39e04..af60897 100644 --- a/build.gradle +++ b/build.gradle @@ -1,15 +1,15 @@ +import de.undercouch.gradle.tasks.download.Download +import de.undercouch.gradle.tasks.download.Verify + buildscript { repositories { - mavenLocal() mavenCentral() } - dependencies { - classpath 'org.xapek.yvesf:gradle-download-task:0.1-SNAPSHOT' - } } plugins { - id "nebula.ospackage" version "3.5.0" + id 'de.undercouch.download' version '3.1.1' + id 'nebula.ospackage' version '3.5.0' } ext { @@ -66,6 +66,35 @@ subprojects { user = 'root' } + // meta task + task download << {} + + ext.makeDownloadTask = { Map params -> + final url = params.url + final basename = url.substring(url.lastIndexOf("/") + 1) + .grep { c -> c == '.' || Character.isAlphabetic((int) (c as char)) } + .join('') + final taskname = params.name ?: basename + final dest = new File(buildDir, "download_${basename}") + dest.parentFile.mkdirs() + + final downloadTask = tasks.create(name: "download_${taskname}", type: Download) + downloadTask.src url + downloadTask.dest dest + downloadTask.overwrite false + + final verifyTask = tasks.create(name: "verify_${taskname}", type: Verify) + verifyTask.src downloadTask.dest + verifyTask.algorithm 'SHA-256' + verifyTask.checksum params.sha256 + + downloadTask.finalizedBy(verifyTask) + + download.dependsOn(downloadTask) + + return downloadTask + } + final buildDeb = project.getTasks().getByName('buildDeb') final upload = tasks.create('upload') @@ -94,7 +123,7 @@ subprojects { final activatorTask = task('activator') activatorTask << { - final activatorDir = new File(project.buildDir, "activator") + final activatorDir = new File(project.buildDir, 'activator') activatorExtension.bin.each { entry -> final starter = new File(activatorDir, "bin/${entry.key}") @@ -104,7 +133,7 @@ subprojects { it.append "${entry.value} \$*" } } - project.extensions.getByName('ospackage').from(new File(activatorDir, "bin")) { + project.extensions.getByName('ospackage').from(new File(activatorDir, 'bin')) { into("/opt/activator/${project.name}/bin") fileMode = 0555 } @@ -114,7 +143,7 @@ subprojects { envFile.parentFile.mkdirs() envFile.write(entry.value as String) } - project.extensions.getByName('ospackage').from(new File(activatorDir, "env")) { + project.extensions.getByName('ospackage').from(new File(activatorDir, 'env')) { into("/opt/activator/${project.name}/env") fileMode = 0444 } |