From de1e05cdea94cf97c9376f988f276daa39bfde2e Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Sat, 21 May 2016 17:14:48 +0200 Subject: update ospackage version, add "activator" support --- build.gradle | 48 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 856347d..ccdc612 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ buildscript { } plugins { - id "nebula.ospackage" version "3.2.0" + id "nebula.ospackage" version "3.5.0" } ext { @@ -36,7 +36,7 @@ allprojects { } } -def reindex = tasks.create('reindex') +final reindex = tasks.create('reindex') reindex << { ant.taskdef( name: 'antSsh', @@ -67,9 +67,9 @@ subprojects { user = 'root' } - def buildDeb = project.getTasks().getByName('buildDeb') + final buildDeb = project.getTasks().getByName('buildDeb') - def upload = tasks.create('upload') + final upload = tasks.create('upload') upload << { ant.antScp( file: buildDeb.archivePath, @@ -82,6 +82,44 @@ subprojects { upload.dependsOn(buildDeb) project.afterEvaluate { - ospackage.version = "${project.version}-${new Date().format("yyyyMMdd-HHmmss")}" + ospackage.version = project.version + ospackage.release = "${new Date().format("yyyyMMdd")}T${new Date().format("HHmmss")}" } + + final activatorExtension = [ + env : [:], + bin : [:], + requirements: [] + ] + project.extensions.add('activator', activatorExtension) + + final createActivatorTask = task('createActivator') + createActivatorTask << { + final activatorDir = new File(project.buildDir, "activator") + + activatorExtension.bin.each { entry -> + final starter = new File(activatorDir, "bin/${entry.key}") + starter.parentFile.mkdirs() + starter.withPrintWriter { + it.append '#!/bin/sh\n' + it.append "${entry.value} \$*" + } + } + project.extensions.getByName('ospackage').from(new File(activatorDir, "bin")) { + into("/opt/activator/${project.name}/bin") + fileMode = 0555 + } + + activatorExtension.env.each { entry -> + final envFile = new File(activatorDir, "env/${entry.key}") + envFile.parentFile.mkdirs() + envFile.write(entry.value as String) + } + project.extensions.getByName('ospackage').from(new File(activatorDir, "env")) { + into("/opt/activator/${project.name}/env") + fileMode = 0444 + } + } + + tasks.getByName('buildDeb').dependsOn(createActivatorTask) } -- cgit v1.2.1