-
Notifications
You must be signed in to change notification settings - Fork 0
/
hale.gradle
155 lines (131 loc) · 5.55 KB
/
hale.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
import groovy.xml.XmlUtil
def getPackageName() {
def version = haleVersion
version += "-ii-${new Date().format( 'yyyyMMdd' )}"
if (os == 'linux') {
return "hale-studio-${version}-linux.gtk.x86_64.tar.gz"
}
if (os == 'windows') {
return "hale-studio-${version}-win32.win32.x86_64.zip"
}
if (os == 'macos') {
return "hale-studio-${version}-macosx.cocoa.x86_64.tar"
}
throw new IllegalArgumentException()
}
task cleanHale(type: Delete) {
delete new File(haleContents, 'features').listFiles().findAll {it.name.startsWith("de.interactive_instruments") || it.name.contains("xtraserver")}
delete fileTree("${haleContents}/plugins") {
include 'de.interactive_instruments*'
include '*.xtraserver*'
include '*.ldproxy*'
}
doFirst {
println (targetFiles.files)
}
}
task pluginsHale(dependsOn: [cleanHale, bundleFeatures], type: Copy) {
from(buildDir) {
include 'plugins/*'
}
new File(buildDir, 'features').listFiles().each {file ->
from(zipTree(file)) {
eachFile { fcd ->
fcd.relativePath = new RelativePath(true, (['features', file.name.take(file.name.lastIndexOf('.'))] + (fcd.relativePath.segments as List)) as String[])
}
includeEmptyDirs = false
}
}
into haleContents
}
task patchHale(dependsOn: pluginsHale) {
doLast {
// enable debugging
new File(haleContents, 'HALE.ini').append('-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005')
// cleanup bundles.info
def bundlesInfo = new File(haleContents, 'configuration/org.eclipse.equinox.simpleconfigurator/bundles.info')
def bundlesInfoFiltered = bundlesInfo.filterLine {!it.contains("xtraserver") && !it.contains("ldproxy")}
bundlesInfo.write(bundlesInfoFiltered.toString(), 'UTF-8')
// cleanup artifacts.xml
def artifactsXml = new File(haleContents, 'artifacts.xml')
def repository = new XmlSlurper().parse(artifactsXml)
// update time
String current = "${new Date().getTime()}"
repository.'properties'.'property'
.find {it.'@name'.text() == 'p2.timestamp'}.'@value' = current
// remove all xtraserver artifacts
def sizeDiff = 0
repository.artifacts.artifact
.findAll { def x = it.'@id'.text().contains("xtraserver") || it.'@id'.text().contains("ldproxy"); if (x) sizeDiff--; return x }
.replaceNode {}
// add plugins to bundles.info and artifacts.xml
new File(buildDir, 'plugins').listFiles().each {file ->
def id = file.name.take(file.name.lastIndexOf('_'))
def rest = file.name.drop(file.name.lastIndexOf('_')+1)
def version = rest.take(rest.lastIndexOf('.'))
def size = file.size()
println "$id $version"
sizeDiff++
bundlesInfo.append("${id},${version},plugins/${file.name},4,false\n")
repository.artifacts.appendNode {
artifact(classifier: 'osgi.bundle', id: id, version: version) {
'properties'(size: '1') {
'property'(name: 'download.size', value: "${size}")
}
}
}
}
// update platform.xml
def platformXml = new File(haleContents, 'configuration/org.eclipse.update/platform.xml')
def config = new XmlSlurper().parse(platformXml)
config.'@date' = current
// add features to artifacts.xml and platform.xml
new File(buildDir, 'features').listFiles().each {file ->
def base = file.name.take(file.name.lastIndexOf('.'))
def id = file.name.take(file.name.lastIndexOf('_'))
def rest = file.name.drop(file.name.lastIndexOf('_')+1)
def version = rest.take(rest.lastIndexOf('.'))
def size = file.size()
println "$id $version"
sizeDiff++
repository.artifacts.appendNode {
artifact(classifier: 'org.eclipse.update.feature', id: id, version: version) {
'properties'(size: '1') {
'property'(name: 'download.size', value: "${size}")
}
'repositoryProperties'(size: '1') {
'property'(name: 'artifact.folder', value: 'true')
}
}
}
config.site.appendNode {
feature(id: id, version: version, url: "features/${base}/")
}
}
// update number of artifacts
if (sizeDiff != 0) {
repository.artifacts.'@size' = String.valueOf(Integer.parseInt(repository.artifacts.'@size'.text()) + sizeDiff)
}
// write adjusted artifacts.xml and platform.xml
artifactsXml.write(XmlUtil.serialize(repository), 'UTF-8')
platformXml.write(XmlUtil.serialize(config), 'UTF-8')
}
}
task hale(dependsOn: patchHale, type:Exec) {
workingDir haleDir
if (os == 'windows') {
commandLine 'cmd', '/c', 'HALE.exe'
} else if (os == 'macos') {
commandLine 'arch', '-x86_64', './hale studio.app/Contents/MacOS/HALE'
} else {
commandLine './HALE'
}
}
task packageHale(dependsOn: patchHale, type: os == "windows" ? Zip : Tar) {
archiveFileName = getPackageName()
destinationDirectory = file("$buildDir/dist")
if (os != "windows")
compression = Compression.GZIP
from haleDir
into haleReleaseName - (os == "windows" ? ".zip" : ".tar.gz")
}