-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
176 lines (155 loc) · 5.47 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
/*
*/
apply plugin: 'java'
repositories {
mavenCentral()
}
ext {
preset_file = 'master_preset.xml'
josm_preset_file = 'josm_preset.xml'
vespucci_preset_file = 'vespucci_preset.xml'
presetBasename = 'MUTCD'
}
configurations {
resoveableRuntimeOnly.extendsFrom runtimeOnly {
canBeResolved = true
}
}
dependencies {
resoveableRuntimeOnly 'ch.poole:preset-utils:0.36.0'
}
defaultTasks 'generateAllPresetTypes'
task copyCss(type: Copy) {
from zipTree(project.configurations.resoveableRuntimeOnly.filter{it.name.startsWith('preset-utils')}.singleFile)
include "preset.css"
into new File(projectDir.getPath() + '/website')
}
task copyResources(type: Copy) {
from zipTree(project.configurations.resoveableRuntimeOnly.filter{it.name.startsWith('preset-utils')}.singleFile)
include "josm-preset-1.0.xlmns"
include "vespucci-preset-1.0.xlmns"
include "toJOSM.xslt"
into new File(buildDir.getPath() + '/xml')
}
task updateWebsite(dependsOn: ["copyCss"], type: JavaExec) {
main = "ch.poole.osm.presetutils.Preset2Html"
classpath = configurations.resoveableRuntimeOnly
args('-input', preset_file,
'-output', 'index.html',
'-vespucci', 'https://github.com/simonpoole/' + project.name + '/raw/gh-pages/gen/' + presetBasename + '.zip',
'-josm', 'https://github.com/simonpoole/' + project.name + '/raw/gh-pages/gen/' + presetBasename + '-josm.zip')
}
updateWebsite.group = 'preset utils'
updateWebsite.description = 'Update the website'
task updatePot(type: JavaExec) {
main = "ch.poole.osm.presetutils.Preset2Pot"
classpath = configurations.resoveableRuntimeOnly
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'
// tasks to generate a zipped preset for JOSM
task josmIcons(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/' + josm_preset_file
mkdir('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(projectDir, output))
}
}
task generateAndValidateJosm(dependsOn: ["transformToJosm"], type: Exec) {
def input = 'gen/' + 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) {
archiveBaseName = presetBasename + '-josm'
destinationDirectory = new File(projectDir, 'gen')
from ('icons/png')
from ('gen/' + 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 'gen'
filteringCharset = 'UTF-8'
rename (preset_file, vespucci_preset_file)
expand([
ICONPATH: '',
ICONTYPE: 'png'
])
}
task generateAndValidateVespucci(dependsOn: ["vespucciIcons","copyResources"], type: Exec) {
def input = 'gen/' + vespucci_preset_file
mkdir('gen')
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
// validation
commandLine 'cmd', '/c', 'xmlstarlet', 'val', '-s', 'build/xml/vespucci-preset-1.0.xlmns', '-e', input
} else {
// validation
commandLine 'xmlstarlet', 'val', '-s', 'build/xml/vespucci-preset-1.0.xlmns', '-e', input
}
}
task vespucciZip(dependsOn: ["generateAndValidateVespucci"], type: Zip) {
archiveBaseName = presetBasename
destinationDirectory = new File(projectDir, 'gen')
from ('icons/png')
from ('gen/' + vespucci_preset_file)
from ('i18n')
exclude ('*.pot')
}
vespucciZip.group = 'preset'
vespucciZip.description = 'Generate zipped preset file for vespucci'
task vespucciNoTranslationsZip(dependsOn: ["generateAndValidateVespucci"], type: Zip) {
archiveBaseName = 'vespucci_zip_no_translations'
destinationDirectory = new File(projectDir, 'gen')
from ('icons/png')
from ('gen/' + vespucci_preset_file)
}
vespucciNoTranslationsZip.group = 'preset'
vespucciNoTranslationsZip.description = 'Generate zipped preset file for vespucci without translations'
// generate everything
task generateAllPresetTypes {
dependsOn "vespucciNoTranslationsZip"
dependsOn "vespucciZip"
dependsOn "josmZip"
dependsOn "updatePot"
dependsOn "updateWebsite"
}
generateAllPresetTypes.group = 'preset'
generateAllPresetTypes.description = 'Generate all preset types'