-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
71 lines (59 loc) · 1.73 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
import groovy.text.SimpleTemplateEngine
import java.util.Date
import java.text.SimpleDateFormat
apply plugin: 'java'
archivesBaseName = 'groovy'
version = "2.1.3"
task rpmSourceTar(type: Tar) {
archiveName = "${archivesBaseName}-${version}.tgz"
compression = Compression.GZIP
destinationDir = new File("${buildDir}/SOURCES")
from tarTree("${projectDir}/src/${archivesBaseName}-${version}.tar.gz")
into "/"
}
task makeRpmEnv << {
//Copy the specfile template
copy{
from "${projectDir}/template.spec"
into "${buildDir}/SPECS"
rename 'template.spec', "${archivesBaseName}.spec"
}
//Populate template variables in the specfile
def specFile = new File("${buildDir}/SPECS/${archivesBaseName}.spec")
def dateFormatter = new SimpleDateFormat("EEE MMM dd yyyy 'T' HH:mm:ss.SSS")
def builtDate = dateFormatter.format(new Date())
def binding = [
"name":archivesBaseName,
"date":builtDate,
"user": System.getProperty('user.name'),
"version":version,
"release":"0",
"changelog":"HERE ARE THE CHANGES"
]
def engine = new SimpleTemplateEngine()
def template = engine.createTemplate(specFile.text).make(binding)
specFile.write(template.toString())
//Use rpmbuild to create RPM
exec{
workingDir './build'
commandLine 'rpmbuild', '-bb', '--define', "_topdir ${buildDir}","SPECS/${archivesBaseName}.spec"
//TODO on windows:
//commandLine 'cmd', '/c', 'stop.bat'
}
}
makeRpmEnv.dependsOn(rpmSourceTar)
task rpmZip (dependsOn: makeRpmEnv, type: Tar) {
description = 'Creates Tar archive of rpm.'
compression = Compression.GZIP
baseName = project.archivesBaseName
//Copy all RPMs into the tar.
from('build/RPMS')
}
configurations {
rpm
rpmSource
}
artifacts {
archives rpmZip
rpmSource rpmSourceTar
}