forked from simonpoole/beautified-JOSM-preset
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
289 lines (257 loc) · 9.29 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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
/*
*/
version = '1.3.0'
apply plugin: 'java'
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.com.github.breadmoirai:github-release:2.2.9"
}
}
apply plugin: "com.github.breadmoirai.github-release"
repositories {
jcenter()
maven { url 'https://dl.bintray.com/content/simonpoole/osm' }
}
ext {
preset_file = 'master_preset.xml'
josm_preset_file = 'josm_preset.xml'
vespucci_preset_file = 'vespucci_preset.xml'
vespucci_preset_build_file = 'vespucci_preset_build.xml'
vespucci_preset_version = '1.4'
generated = 'build/gen/'
github_token = System.getenv('GITHUB_TOKEN')
}
dependencies {
runtime 'ch.poole:preset-utils:0.9.0'
}
task copyCss(type: Copy) {
from zipTree(project.configurations.runtime.filter{it.name.startsWith('preset-utils')}.singleFile)
include "preset.css"
into new File(projectDir.getPath() + '/website')
}
task copyResources(type: Copy) {
from zipTree(project.configurations.runtime.filter{it.name.startsWith('preset-utils')}.singleFile)
include "josm-preset-1.0.xlmns"
include "vespucci-preset-${vespucci_preset_version}.xlmns"
include "toJOSM.xslt"
include "href2wiki.xslt"
include "wiki2href.xslt"
into new File(buildDir.getPath() + '/xml')
}
task updateWebsite(dependsOn: ["copyCss"], type: JavaExec) {
main = "ch.poole.osm.presetutils.Preset2Html"
classpath = configurations.runtime
args('-input', preset_file,
'-output', 'index.html',
'-vespucci', 'https://github.com/simonpoole/' + project.name + '/releases/latest/download/vespucci_zip.zip',
'-josm', 'https://github.com/simonpoole/' + project.name + '/releases/latest/download/josm.zip')
}
updateWebsite.group = 'preset utils'
updateWebsite.description = 'Update the website'
task updatePot(type: JavaExec) {
main = "ch.poole.osm.presetutils.Preset2Pot"
classpath = configurations.runtime
args('-input', preset_file,
'-output', 'i18n/preset.pot')
}
updatePot.group = 'preset utils'
updatePot.description = 'Update the translation template'
task updateTranslations(type: Exec) {
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
commandLine 'cmd', '/c', 'tx.exe', 'pull', '-a'
} else {
commandLine 'tx', 'pull', '-a'
}
}
updateTranslations.group = 'transifex'
updateTranslations.description = 'Update translations by executing the transifex tx utility'
// one time transformation to new format
task transformHrefToWiki(type: Exec) {
def output = 'build/temp/no_href.xml'
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
// remove extensions
commandLine 'cmd', '/c', 'xmlstarlet', 'tr', 'build/xml/href2wiki.xslt', 'master_preset.xml'
} else {
// remove extensions
commandLine 'xmlstarlet', 'tr', 'build/xml/href2wiki.xslt', 'master_preset.xml'
}
doFirst {
standardOutput = new FileOutputStream(new File(projectDir, output))
}
}
// tasks to generate a zipped preset for JOSM
task josmIcons(dependsOn: ["replaceVersion"], type: Copy) {
from projectDir
include preset_file
into 'build/temp'
filteringCharset = 'UTF-8'
rename preset_file, josm_preset_file
expand([
ICONPATH: '',
ICONTYPE: 'png'
])
}
task transformToJosm(dependsOn: ["josmIcons", "copyResources"], type: Exec) {
def output = 'gen/new_' + josm_preset_file
mkdir('build/gen')
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
// remove extensions
commandLine 'cmd', '/c', 'xmlstarlet', 'tr', 'build/xml/toJOSM.xslt', 'build/temp/' + josm_preset_file
} else {
// remove extensions
commandLine 'xmlstarlet', 'tr', 'build/xml/toJOSM.xslt', 'build/temp/' + josm_preset_file
}
doFirst {
standardOutput = new FileOutputStream(new File(buildDir, output))
}
}
task transformToOldJosm(dependsOn: ["josmIcons", "copyResources"], type: Exec) {
def output = 'gen/' + josm_preset_file
mkdir('build/gen')
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
// remove extensions
commandLine 'cmd', '/c', 'xmlstarlet', 'tr', 'build/xml/wiki2href.xslt', generated + 'new_' + josm_preset_file
} else {
// remove extensions
commandLine 'xmlstarlet', 'tr', 'build/xml/wiki2href.xslt', generated + 'new_' + josm_preset_file
}
doFirst {
standardOutput = new FileOutputStream(new File(buildDir, output))
}
}
task generateAndValidateJosm(dependsOn: ["transformToJosm", "transformToOldJosm"], type: Exec) {
def input = generated + josm_preset_file
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
// validation
commandLine 'cmd', '/c', 'xmlstarlet', 'val', '-s', 'build/xml/josm-preset-1.0.xlmns', '-e', input
} else {
// validation
commandLine 'xmlstarlet', 'val', '-s', 'build/xml/josm-preset-1.0.xlmns', '-e', input
}
}
task josmZip(dependsOn: ["generateAndValidateJosm"], type: Zip) {
baseName 'josm'
version ''
destinationDir = new File(buildDir, 'gen')
from ('icons/png')
from (generated + josm_preset_file)
}
josmZip.group = 'preset'
josmZip.description = 'Generate zipped preset file for JOSM'
// tasks to generate a zipped preset for vespucci
task vespucciIcons(type: Copy) {
from projectDir
include preset_file
into 'build/gen'
filteringCharset = 'UTF-8'
rename (preset_file, vespucci_preset_file)
expand([
ICONPATH: '',
ICONTYPE: 'png'
])
}
task generateAndValidateVespucci(dependsOn: ["vespucciIcons", "copyResources"], type: Exec) {
def input = generated + vespucci_preset_file
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
// validation
commandLine 'cmd', '/c', 'xmlstarlet', 'val', '-s', "build/xml/vespucci-preset-${vespucci_preset_version}.xlmns", '-e', input
} else {
// validation
commandLine 'xmlstarlet', 'val', '-s', "build/xml/vespucci-preset-${vespucci_preset_version}.xlmns", '-e', input
}
}
// special for building vespucci
task vespucciBuild(dependsOn: ["replaceVersion"], type: Copy) {
from projectDir
include preset_file
into 'build/gen'
filteringCharset = 'UTF-8'
rename (preset_file, vespucci_preset_build_file)
expand([
ICONPATH: 'icons/png/',
ICONTYPE: 'png'
])
}
task generateAndValidateVespucciBuild(dependsOn: ["vespucciBuild", "copyResources"], type: Exec) {
def input = generated + vespucci_preset_build_file
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
// validation
commandLine 'cmd', '/c', 'xmlstarlet', 'val', '-s', "build/xml/vespucci-preset-${vespucci_preset_version}.xlmns", '-e', input
} else {
// validation
commandLine 'xmlstarlet', 'val', '-s', "build/xml/vespucci-preset-${vespucci_preset_version}.xlmns", '-e', input
}
}
task vespucciZip(dependsOn: ["generateAndValidateVespucci", "updateTranslations"], type: Zip) {
baseName 'vespucci_zip'
version ''
destinationDir = new File(buildDir, 'gen')
from ('icons/png')
from (generated + vespucci_preset_file)
from ('i18n')
exclude ('*.pot')
}
vespucciZip.group = 'preset'
vespucciZip.description = 'Generate zipped preset file for vespucci'
vespucciZip.group = 'preset'
vespucciZip.description = 'Generate zipped preset file for vespucci'
task vespucciIconsZip(type: Zip) {
baseName 'vespucci_icons'
version ''
destinationDir = new File(buildDir, 'gen')
from ('icons/png')
}
vespucciZip.group = 'preset'
vespucciZip.description = 'Generate zipped icon file for vespucci'
task vespucciNoTranslationsZip(dependsOn: ["generateAndValidateVespucci"], type: Zip) {
baseName 'vespucci_zip_no_translations'
version ''
destinationDir = new File(buildDir, 'gen')
from ('icons/png')
from (generated + vespucci_preset_file)
}
vespucciNoTranslationsZip.group = 'preset'
vespucciNoTranslationsZip.description = 'Generate zipped preset file for vespucci without translations'
// this copies the zip files to their legacy location
task copyToGen(dependsOn: ["vespucciNoTranslationsZip", "vespucciZip"]) {
mkdir('gen')
copy {
from new File(buildDir, 'gen')
include 'vespucci_zip_no_translations.zip', 'vespucci_zip.zip'
into 'gen'
}
}
task replaceVersion {
inputs.file('build.gradle')
ant.replaceregexp(match:'presets version="([0-9\\.]+)"', replace:"presets version=\"${version}\"", flags:'g', byline:true) {
fileset(dir: '.', includes: 'master_preset.xml')
}
}
githubRelease {
token "${github_token}"
owner "simonpoole"
tagName "${version}"
releaseName "${version}"
body ""
releaseAssets new File(buildDir, 'gen').listFiles()
overwrite true
}
build {
dependsOn "vespucciNoTranslationsZip"
dependsOn "vespucciZip"
dependsOn "vespucciIconsZip"
dependsOn "generateAndValidateVespucciBuild"
dependsOn "josmZip"
dependsOn "updatePot"
dependsOn "updateWebsite"
dependsOn "copyToGen"
}
check {
dependsOn "generateAndValidateVespucci"
dependsOn "generateAndValidateJosm"
}