-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
316 lines (251 loc) · 7.38 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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
plugins {
id 'base'
id 'java'
id 'com.github.node-gradle.node' version '7.0.1'
id 'org.ajoberstar.grgit' version '5.2.1' apply false
}
import org.ajoberstar.grgit.Grgit
tasks.build.dependsOn 'assemble'
node {
version = '18.17.1'
download = true
}
allprojects {
apply plugin: 'java'
repositories {
mavenCentral()
}
project.ext.distVersion = { ->
def json = new groovy.json.JsonSlurper()
def packageData = json.parse(file("${rootProject.projectDir}/package.json"))
return packageData.version;
}
project.ext.antvilleBuildDir = "${rootProject.buildDir}/tmp/antville"
project.ext.antvilleInstallDir = "${rootProject.buildDir}/install/antville"
project.ext.antvilleDistFiles = copySpec {
from fileTree(antvilleBuildDir).matching {
}
}
// Hide some purely Java-related tasks
project.tasks.buildDependents.group = null;
project.tasks.buildNeeded.group = null;
project.tasks.classes.group = null;
project.tasks.jar.group = null;
project.tasks.javadoc.group = null;
project.tasks.testClasses.group = null;
}
version = distVersion()
dependencies {
implementation 'org.commonmark:commonmark:0.21.0'
implementation 'org.commonmark:commonmark-ext-autolink:0.21.0'
implementation 'org.commonmark:commonmark-ext-gfm-strikethrough:0.21.0'
implementation 'org.commonmark:commonmark-ext-gfm-tables:0.21.0'
implementation 'org.jsoup:jsoup:1.17.2'
implementation 'rome:rome:1.0'
implementation('org.lesscss:lesscss:1.7.0.1.1') {
exclude group: 'org.mozilla', module: 'rhino'
exclude group: 'org.slf4j', module: 'slf4j-api'
exclude group: 'org.slf4j', module: 'slf4j-simple'
}
}
task assemble(type: Copy, overwrite: true) {
dependsOn 'installAntville'
dependsOn 'installJars'
dependsOn 'buildStaticFiles'
from fileTree(antvilleBuildDir).matching {
exclude 'node_modules'
exclude 'package.json'
exclude 'tests'
exclude 'tools/client'
exclude 'tools/antclick'
exclude 'package-lock.json'
} into antvilleInstallDir
}
task installAntville {
description 'Clone the Antville repository and remove all unnecessary files.'
group 'installation'
def tempDir = "$project.buildDir/tmp/repo"
outputs.dirs tempDir, antvilleBuildDir
doFirst {
delete tempDir
Grgit.clone(dir: tempDir, uri: project.ext['antville.repo.url'])
}
doLast {
def git = Grgit.open(dir: tempDir)
def hash = git.head().abbreviatedId
def date = new Date().format('d MMM yyyy')
copy {
from "$tempDir/code/app.properties"
into "$antvilleBuildDir/code"
filter { line -> line.replaceAll('(version =) 0.0.0', "\$1 $version.$hash")
.replaceAll('(buildDate =) 18 Jun 2001', "\$1 $date")
}
}
copy {
from fileTree(tempDir).matching {
exclude 'code/app.properties'
exclude '*gradle*'
exclude '.*'
exclude 'i18n/*.po*'
} into antvilleBuildDir
}
}
}
task installJars(type: Copy) {
description 'Download required JAR libraries.'
group 'installation'
dependsOn 'installAntville'
def outputDir = "$antvilleBuildDir/lib"
outputs.dir outputDir
from configurations.runtimeClasspath
into outputDir
}
task installNodeModules(type: NpmTask) {
description 'Download required Node modules.'
group 'build'
dependsOn 'installAntville'
inputs.files "$antvilleBuildDir/package-lock.json"
outputs.dir "$antvilleBuildDir/node_modules"
args = ['--silent', 'install']
execOverrides {
it.workingDir = antvilleBuildDir
}
}
task buildStaticFiles(type: Copy) {
description 'Build fonts, client-side scripts and stylesheets.'
group 'build'
dependsOn 'installAntville'
dependsOn 'installNodeModules'
dependsOn 'buildMainScript'
dependsOn 'buildMainStyles'
dependsOn 'buildEditorScript'
dependsOn 'buildEditorStyles'
dependsOn 'buildGalleryScript'
dependsOn 'buildLicenses'
def inputDir = "$antvilleBuildDir/node_modules/uikit/dist/fonts"
def outputDir = "$antvilleBuildDir/static/fonts"
inputs.dir inputDir
outputs.dir outputDir
from inputDir
into outputDir
}
['main', 'editor', 'gallery'].each { name ->
task "build${name.capitalize()}Script" (type: NpmTask) {
description "Build the ${name} client-side scripts."
group 'build'
dependsOn 'installNodeModules'
def inputFile = "tools/client/${name}.js"
def outputFile = "static/scripts/${name}.min.js"
inputs.files "$antvilleBuildDir/$inputFile"
outputs.files "$antvilleBuildDir/$outputFile"
args = [
'--silent',
'exec', '--',
'browserify',
inputFile,
'--outfile', outputFile,
'-g', 'uglifyify'
]
execOverrides {
it.workingDir = antvilleBuildDir
}
}
}
['main', 'editor'].each { name ->
task "build${name.capitalize()}Styles" (type: NpmTask) {
description "Build the ${name} stylesheet."
group 'build'
dependsOn 'installNodeModules'
def inputFile = "tools/client/${name}.less"
def outputFile = "static/styles/${name}.min.css"
inputs.files "$antvilleBuildDir/$inputFile"
outputs.files "$antvilleBuildDir/$outputFile"
args = [
'--silent',
'exec', '--',
'lessc',
'--clean-css',
inputFile,
outputFile
]
execOverrides {
it.workingDir = antvilleBuildDir
}
}
}
task buildLicenses(type: NpmTask) {
description 'Build licenses file from client-side dependecies.'
group 'build'
dependsOn 'installNodeModules'
def outputFile = "$antvilleBuildDir/static/licenses.txt"
inputs.file "$antvilleBuildDir/package-lock.json"
outputs.file outputFile
args = [
'--silent',
'exec', '--',
'generate-license-file',
'--input', "$antvilleBuildDir/package.json",
'--output', outputFile,
'--overwrite',
'--eol', 'lf'
]
execOverrides {
it.workingDir = antvilleBuildDir
it.standardOutput = new FileOutputStream(outputFile)
}
}
task jsdoc(type: NpmTask) {
description 'Generates JavaScript API documentation for the main source code.'
group 'documentation'
dependsOn 'installNodeModules'
def inputDir = "$antvilleBuildDir/code"
def outputDir = "${project.buildDir}/docs/jsdoc"
inputs.dir inputDir
outputs.dir outputDir
args = [
'--silent',
'exec', '--',
'jsdoc',
'--recurse',
'--destination',
outputDir,
inputDir
]
execOverrides {
it.workingDir = antvilleBuildDir
}
}
task assembleDist {
description 'Creates the Antville download packages.'
group 'distribution'
dependsOn 'assemble'
dependsOn 'distZip'
dependsOn 'distTar'
}
task distZip(type: Zip) {
description 'Creates the Antville download package as Zip file.'
group 'distribution'
dependsOn 'assemble'
def version = project.distVersion()
def outputDir = "${project.buildDir}/distributions"
def outputFile = "antville-${version}.zip"
inputs.dir antvilleInstallDir
outputs.file "$outputDir/$outputFile"
from antvilleInstallDir
destinationDirectory = file(outputDir)
archiveFileName = outputFile
}
task distTar(type: Tar) {
description 'Creates the Antville download package as Bzip2 file.'
group 'distribution'
dependsOn 'assemble'
def version = project.distVersion()
def outputDir = "${project.buildDir}/distributions"
def outputFile = "antville-${version}.tbz"
inputs.dir antvilleInstallDir
outputs.file "$outputDir/$outputFile"
from antvilleInstallDir
compression = Compression.BZIP2
destinationDirectory = file(outputDir)
archiveFileName = outputFile
}