-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.gradle
315 lines (254 loc) · 7.56 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
plugins {
id 'base'
id 'java'
id 'com.github.node-gradle.node' version '7.0.1'
}
tasks.build.dependsOn 'assemble'
node {
version = '20.9.0'
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'
}
}
assemble {
dependsOn 'installAntville'
dependsOn 'installJars'
dependsOn 'buildStaticFiles'
doFirst {
copy {
from fileTree(antvilleBuildDir).matching {
exclude 'node_modules'
exclude 'package.json'
exclude 'tests'
exclude 'tools/client'
exclude 'tools/antclick'
exclude 'package-lock.json'
} into antvilleInstallDir
}
}
}
tasks.register('installAntville') {
description 'Clone the Antville repository and remove all unnecessary files.'
group 'installation'
outputs.dirs antvilleBuildDir
doLast {
def date = new Date().format('d MMM yyyy')
def gitOutput = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = gitOutput
errorOutput = new ByteArrayOutputStream()
ignoreExitValue = true
}
def tag = gitOutput.toString().trim()
copy {
from "${project.projectDir}/code/app.properties"
into "$antvilleBuildDir/code"
filter { line -> line.replaceAll('(version =) 0.0.0', "\$1 $version.$tag")
.replaceAll('(buildDate =) 18 Jun 2001', "\$1 $date")
}
}
copy {
from fileTree(project.projectDir).matching {
include 'claustra/**'
include 'code/**'
exclude 'code/app.properties'
include 'compat/**'
include 'db/**'
include 'i18n/**'
exclude 'i18n/*.po*'
include 'static/**'
include 'tools/**'
include 'CHANGES.md'
include 'INSTALL.md'
include 'README.md'
} into antvilleBuildDir
}
}
}
tasks.register('installJars', Copy) {
description 'Download required JAR libraries.'
group 'installation'
dependsOn 'installAntville'
def outputDir = "$antvilleBuildDir/lib"
outputs.dir outputDir
from configurations.runtimeClasspath
into outputDir
}
tasks.register('installNodeModules', NpmTask) {
description 'Download required Node modules.'
group 'build'
dependsOn 'installAntville'
inputs.files "${project.projectDir}/package-lock.json"
outputs.dir "${project.projectDir}/node_modules"
args = ['--silent', 'install']
execOverrides {
it.workingDir = antvilleBuildDir
}
}
tasks.register('buildStaticFiles', 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 = "${project.projectDir}/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 ->
tasks.register("build${name.capitalize()}Script", NpmTask) {
description "Build the ${name} client-side scripts."
group 'build'
dependsOn 'installNodeModules'
def inputFile = "${project.projectDir}/tools/client/${name}.js"
def outputFile = "$antvilleBuildDir/static/scripts/${name}.min.js"
inputs.files inputFile
outputs.files outputFile
args = [
'--silent',
'exec', '--',
'browserify', inputFile,
'--outfile', outputFile,
'-g', 'uglifyify'
]
}
}
['main', 'editor'].each { name ->
tasks.register("build${name.capitalize()}Styles", NpmTask) {
description "Build the ${name} stylesheet."
group 'build'
dependsOn 'installNodeModules'
def inputFile = "${project.projectDir}/tools/client/${name}.less"
def outputFile = "$antvilleBuildDir/static/styles/${name}.min.css"
inputs.files inputFile
outputs.files outputFile
args = [
'--silent',
'exec', '--',
'lessc',
'--clean-css',
inputFile,
outputFile
]
}
}
tasks.register('buildLicenses', NpmTask) {
description 'Build licenses file from client-side dependencies.'
group 'build'
dependsOn 'installNodeModules'
def outputFile = "$antvilleBuildDir/static/licenses.txt"
inputs.file "${project.projectDir}/package-lock.json"
outputs.file outputFile
args = [
'--silent',
'exec', '--',
'generate-license-file',
'--input', "${project.projectDir}/package.json",
'--output', outputFile,
'--overwrite',
'--eol', 'lf'
]
execOverrides {
it.workingDir = antvilleBuildDir
it.standardOutput = new FileOutputStream(outputFile)
}
}
tasks.register('jsdoc', 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
}
}
tasks.register('assembleDist') {
description 'Creates the Antville download packages.'
group 'distribution'
dependsOn 'assemble'
dependsOn 'distZip'
dependsOn 'distTar'
}
tasks.register('distZip', 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
}
tasks.register('distTar', 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
}