summaryrefslogtreecommitdiff
path: root/build.gradle
blob: 856347db26d3ab028c0f5650c4b0f0b218abd38e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
buildscript {
  repositories {
    mavenLocal()
    mavenCentral()
  }
  dependencies {
    classpath 'org.xapek.yvesf:gradle-download-task:0.1-SNAPSHOT'
  }
}

plugins {
  id "nebula.ospackage" version "3.2.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'
  }
}

def 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'
  }

  def buildDeb = project.getTasks().getByName('buildDeb')

  def 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}-${new Date().format("yyyyMMdd-HHmmss")}"
  }
}