-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.gradle
123 lines (99 loc) · 3.41 KB
/
build.gradle
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
buildscript {
repositories {
mavenCentral()
}
}
plugins {
id "nebula.ospackage" version "9.1.1"
}
apply plugin: 'groovy'
import org.rundeck.gradle.PackageTask
def pSuffix = findProperty('packageSuffix')?: ""
def pGroup = findProperty('packageGroup')?: "org.rundeck"
def pOrg = findProperty('packageOrg')?: "rundeck"
def pType = findProperty('packageType')
def pBundle = findProperty('packageBundle')?: "rundeck"
def pRelease = findProperty('packageRelease')?: "1"
def pInclude = findProperty('packageInclude')?: '.*.war$'
def libsDir = findProperty('libsDir')
def artifacts = fileTree('artifacts').matching {
include {
it.file.name ==~ pInclude
}
}
def fileVersionInfo(file) {
def m = file.name =~ /(?<flavor>rundeck(pro)?)-(?<bundle>[a-zA-Z]+)?-?(?<version>\d.+?)-((?<tag>[a-zA-Z][a-zA-Z0-9]+)-?)?(?<date>\d.+?)?\.war$/
if(! m.matches()) {
throw new GradleException("Unable to parse version [${version}]!".toString())
}
def info = [
flavor: m.group('flavor'),
num: m.group('version'),
tag: m.group('tag'),
date: m.group('date'),
bundle: m.group('bundle'),
]
info.package = info.bundle != null ? "$info.flavor-$info.bundle" : info.flavor
def fullVersion = info.num
fullVersion += info.date != null ? ".$info.date" : ""
fullVersion += info.tag != null ? "~$info.tag" : ""
def fullWarVersion = info.num
fullWarVersion += info.date != null ? "-$info.date" : ""
fullWarVersion += info.tag != null ? "-$info.tag" : ""
info.warVersion = fullWarVersion
info.version = fullVersion
return info
}
def vInfo = fileVersionInfo(artifacts.getFiles()[0])
println vInfo
if (!pSuffix) {
if (vInfo.tag == 'SNAPSHOT') {
pSuffix = '-dev'
} else if (vInfo.tag != null ) {
pSuffix = '-test'
}
}
def repo = "${pOrg}${pSuffix}"
def distro = 'any/any'
if (pType == 'rpm')
distro = 'rpm_any/rpm_any'
else if (pType == 'war' || pType == 'jar')
distro = 'java/maven2'
task publishWar{}
task publishAll{dependsOn publishWar}
task packageArtifacts{}
def firstFile = artifacts.getFiles().each { file ->
def fileVersion = fileVersionInfo(file)
def pTask = task "packageRundeck-$file.name"(type: PackageTask) {
artifact = file
packageVersion = fileVersion.version
packageRelease = pRelease
packageName = fileVersion.package
packageDescription = 'Rundeck!!!!'
libDir = project.file(libsDir)
}
packageArtifacts.dependsOn pTask
def pubWarTask = task "publishWar-$file.name"(type: Exec, group: 'publishing') {
def command = [
"package_cloud push",
"pagerduty/${repo}/java/maven2",
"artifacts/${file.name}",
"--coordinates=${pGroup}:${vInfo.package}:${vInfo.warVersion}"
].join(' ')
commandLine 'bash', '-c', command
}
publishWar.dependsOn pubWarTask
def pubWarAscTask = task "publishWarAsc-$file.name"(type: Exec, group: 'publishing') {
def command = [
"package_cloud push",
"pagerduty/${repo}/anyfile",
"artifacts/${file.name}.asc",
].join(' ')
commandLine 'bash', '-c', command
}
publishWar.dependsOn pubWarAscTask
}
task publish(type: Exec) {
commandLine 'bash', '-c', "package_cloud push pagerduty/${repo}/${distro} ${project.buildDir}/distributions/*.${pType}"
}
publishAll.dependsOn publish