generated from rydnr/object-diff
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
247 lines (215 loc) · 7.17 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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
def tag = 'main'
def branchOrTag = 'main'
version = "${tag}-SNAPSHOT" // do not forget to update the version also in docker.gradle
apply plugin: PharoPlugin
pharo {
imageVersion = '80'
}
def imageName = "${project.name}-${project.version}"
def Properties properties = new Properties()
properties.load(project.rootProject.file('gradle-local.properties').newDataInputStream())
def customPharoPath = properties.getProperty('pharoPath')
def customPharoUiPath = properties.getProperty('pharoUiPath')
def customPharoArgs = properties.getProperty('pharoArgs').split(",").toList()
def gtoolkitHome = properties.getProperty('gtoolkitHome')
task removePreviousPharoImage(type: RemovePreviousPharoImageTask)
task removePreviousGtoolkitImage(type: RemovePreviousGtoolkitImageTask)
task downloadFreshPharoImage(type: DownloadPharoImageTask, dependsOn: removePreviousPharoImage)
task retrieveFreshGtoolkitImage(type: RetrieveFreshGtoolkitImageTask, dependsOn: removePreviousGtoolkitImage) {
gtHome = gtoolkitHome
}
task loadPharoEDAAdapters(type: EvalSmalltalkExpressionTask, dependsOn: downloadFreshPharoImage) {
pharoPath = customPharoPath
commonPharoArgs = customPharoArgs
expression = "Metacello new repository: 'github://osoco/pharo-eda-adapters:${branchOrTag}'; baseline: 'PharoEDAAdapters'; onConflictUseLoaded; load"
}
task loadPharoEDAAdaptersGt(type: EvalSmalltalkExpressionTask, dependsOn: retrieveFreshGtoolkitImage) {
pharoPath = customPharoPath
commonPharoArgs = customPharoArgs
expression = "Metacello new repository: 'github://osoco/pharo-eda-adapters:${branchOrTag}'; baseline: 'PharoEDAAdapters'; onConflictUseLoaded; load"
}
task customizeImage(type: RunSmalltalkScriptTask, dependsOn: loadPharoEDAAdapters) {
script = "customize.st"
pharoPath = customPharoPath
commonPharoArgs = customPharoArgs
}
task customizeImageGt(type: RunSmalltalkScriptTask, dependsOn: loadPharoEDAAdaptersGt) {
script = "customize.st"
pharoPath = customPharoPath
commonPharoArgs = customPharoArgs
}
task assemble(type: SavePharoImageTask, dependsOn: customizeImage) {
toImageName = imageName
shouldDeleteOldImage = true
pharoPath = customPharoPath
commonPharoArgs = customPharoArgs
}
task assembleGt(type: SaveGtoolkitImageTask, dependsOn: customizeImageGt) {
toImageName = imageName
shouldDeleteOldImage = true
pharoPath = customPharoPath
commonPharoArgs = customPharoArgs
}
task clean(type: Delete) {
def foldersToDelete = []
new File('.').eachDir {
if (it.name.startsWith('image.')) {
foldersToDelete << it.name
}
}
delete foldersToDelete +
["${imageName}.image", "${imageName}.changes", 'package-cache', 'play-cache', 'pharo-local', 'github-cache', '.gradle', 'PharoDebug.log']
}
class PharoPlugin implements Plugin<Project> {
void apply(Project project) {
project.extensions.create("pharo", PharoPluginExtension)
}
}
class PharoPluginExtension {
String zeroConfUrl = "http://get.pharo.org/64"
String imageVersion = 'stable'
}
class RemovePreviousPharoImageTask extends DefaultTask {
@TaskAction
def removePreviousPharoImage() {
project.exec {
commandLine "bash", "-c", "rm -f Pharo.image Pharo.changes"
}
}
}
class RemovePreviousGtoolkitImageTask extends DefaultTask {
@TaskAction
def removePreviousGtoolkitImage() {
project.exec {
commandLine "bash", "-c", "rm -rf GlamorousToolkit"
}
}
}
class DownloadPharoImageTask extends DefaultTask {
@TaskAction
def downloadFreshImage() {
def cmd = (System.getProperty('os.name').startsWith('Mac') ? 'curl' : 'wget -O-')
project.exec {
commandLine "bash", "-c", "${cmd} ${project.pharo.zeroConfUrl}/${project.pharo.imageVersion} | bash"
}
}
}
class RetrieveFreshGtoolkitImageTask extends DefaultTask {
String gtHome
@TaskAction
def retrieveFreshImage() {
project.exec {
commandLine "bash", "-c", "cp ${gtHome}/*.so . && cp ${gtHome}/blank.image Pharo.image && cp ${gtHome}/blank.changes Pharo.changes"
}
}
}
class SavePharoImageTask extends DefaultTask {
String fromImageName = "Pharo.image"
String pharoPath = "pharo"
def commonPharoArgs
String toImageName
boolean shouldDeleteOldImage
@TaskAction
def renamePharoImage() {
def pharoArgs = []
pharoArgs.addAll(commonPharoArgs)
pharoArgs.addAll([fromImageName, "save", toImageName])
if (shouldDeleteOldImage) {
pharoArgs << "--delete-old"
}
project.exec {
executable "${pharoPath}"
args pharoArgs
}
}
}
class SaveGtoolkitImageTask extends DefaultTask {
String fromImageName = "GlamorousToolkit/GlamorousToolkit.image"
String pharoPath = "pharo"
def commonPharoArgs
String toImageName
boolean shouldDeleteOldImage
@TaskAction
def renameGtoolkitImage() {
def pharoArgs = []
pharoArgs.addAll(commonPharoArgs)
pharoArgs.addAll([fromImageName, "save", toImageName])
if (shouldDeleteOldImage) {
pharoArgs << "--delete-old"
}
project.exec {
executable "${pharoPath}"
args pharoArgs
}
}
}
class LoadMetacelloConfigTask extends DefaultTask {
String image = "Pharo.image"
String pharoPath = "pharo"
def commonPharoArgs
String repository
String configuration
String version
@TaskAction
def loadMetacelloConfig() {
def pharoArgs = []
pharoArgs.addAll(commonPharoArgs)
pharoArgs.addAll([image, "config", repository, configuration, "--install=${version}"])
project.exec {
executable "${pharoPath}"
args pharoArgs
}
}
}
class EvalSmalltalkExpressionTask extends DefaultTask {
String image = "Pharo.image"
String pharoPath = "pharo"
def commonPharoArgs
String expression
@TaskAction
def evalSmalltalkExpression() {
def pharoArgs = []
pharoArgs.addAll(commonPharoArgs)
pharoArgs.addAll([image, "eval", "--save", expression])
project.exec {
executable "${pharoPath}"
args pharoArgs
}
}
}
class RunSmalltalkScriptTask extends DefaultTask {
String image = "Pharo.image"
String pharoPath = "pharo"
def commonPharoArgs
String script
@TaskAction
def runSmalltalkScript() {
def pharoArgs = []
pharoArgs.addAll(commonPharoArgs)
pharoArgs.addAll([image, "st", "--quit", "--save", script])
project.exec {
executable "${pharoPath}"
args pharoArgs
}
}
}
class RunPharoTestsTask extends DefaultTask {
String image = "Pharo.image"
String pharoPath = "pharo"
def commonPharoArgs
String packageName
boolean shouldOutputAsJUnit
@TaskAction
def runTests() {
def pharoArgs = []
pharoArgs.addAll(commonPharoArgs)
pharoArgs.addAll([image, "test", packageName])
if (shouldOutputAsJUnit) {
pharoArgs << "--junit-xml-output"
}
project.exec {
executable "${pharoPath}"
args pharoArgs
}
}
}