buildscript { repositories { mavenLocal() mavenCentral() } dependencies { classpath 'org.xapek.yvesf:gradle-download-task:0.1-SNAPSHOT' } } plugins { id "nebula.ospackage" version "3.5.0" } ext { sshKeyfile = new File(System.getProperty('user.home'), '.ssh/id_rsa') sshKnownHosts = new File(System.getProperty('user.home'), '.ssh/known_hosts') sshUser = 'yvesf' sshHost = 'xapek.org' sshTargetDir = 'public_html/public/debian/files' sshReindexCommand = 'cd public_html/public/debian && make' } allprojects { configurations { sshAntTask } repositories { mavenLocal() mavenCentral() } dependencies { sshAntTask 'org.apache.ant:ant-jsch:1.9.2' } } final reindex = tasks.create('reindex') reindex << { ant.taskdef( name: 'antSsh', classname: 'org.apache.tools.ant.taskdefs.optional.ssh.SSHExec', classpath: configurations.sshAntTask.asPath) ant.antSsh( host: sshHost, username: sshUser, keyfile: file(sshKeyfile), knownhosts: file(sshKnownHosts), command: sshReindexCommand, verbose: true) } subprojects { group 'org.xapek.yvesf.debian' version '1.0-SNAPSHOT' apply plugin: 'nebula.ospackage' ant.taskdef( name: 'antScp', classname: 'org.apache.tools.ant.taskdefs.optional.ssh.Scp', classpath: configurations.sshAntTask.asPath) ospackage { user = 'root' } final buildDeb = project.getTasks().getByName('buildDeb') final upload = tasks.create('upload') upload << { ant.antScp( file: buildDeb.archivePath, todir: "${sshUser}@${sshHost}:${sshTargetDir}", keyfile: file(sshKeyfile), knownhosts: file(sshKnownHosts), verbose: true) } upload.group = 'build' upload.dependsOn(buildDeb) project.afterEvaluate { 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) }