-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
252 lines (212 loc) · 8.28 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
import org.apache.tools.ant.filters.*
plugins {
id 'base'
id 'java-library'
id "com.github.node-gradle.node" version "3.6.0"
id 'org.barfuin.gradle.taskinfo' version '1.0.5'
}
ext.architecture = "linux-x86_64" // TODO make adjustable
ext.toolDir = "$buildDir/tools"
ext.xmlDir = file('data/xml', PathValidation.DIRECTORY)
node {
download = true
workDir = file("$toolDir/node")
}
if (!project.hasProperty('dataDir')) {
def dataDirCandidate = rootProject.file('data/xml')
if (dataDirCandidate.isDirectory())
project.ext.dataDir = dataDirCandidate
else {
throw new FileNotFoundException("Data directory not found. Either put data into $dataDirCandidate, or set the dataDir property.")
}
logger.info("Using data from $dataDirCandidate")
}
group = 'net.faustedition'
version = '1.0-SNAPSHOT'
description = 'Faust-Edition Site Generation'
sourceCompatibility = '17'
targetCompatibility = '17'
repositories {
mavenLocal()
// Firefox and SlimerJS need to be downloaded directly:
ivy {
url "https://ftp.mozilla.org/pub"
patternLayout {
artifact "[module]/releases/[revision]/$architecture/en-US/[module]-[revision](.[ext])"
}
metadataSources { artifact() }
content { includeGroup "org.mozilla" }
}
ivy {
url "https://download.slimerjs.org/"
patternLayout {
artifact "releases/[revision]/[module]-[revision](.[ext])"
}
metadataSources { artifact() }
content { includeGroup "slimerjs" }
}
maven { url = 'https://repo.osgeo.org/repository/release/' } // jai_core, cf. https://stackoverflow.com/questions/26993105
mavenCentral()
maven { url "http://dev.digital-humanities.de/nexus/content/groups/public"
allowInsecureProtocol true }
maven { url = 'https://dev.dariah.eu/nexus/content/groups/public' }
maven { url = 'https://maven.restlet.com' }
maven { url = 'https://raw.github.com/eXist-db/mvn-repo/master/' } // for < 5.0.0
}
configurations {
tools
exist
}
dependencies {
implementation group: 'com.xmlcalabash', name: 'xmlcalabash', version: '1.3.2-100'
implementation group: 'net.sf.saxon', name: 'Saxon-HE', version: '10.5'
implementation 'org.nanohttpd:nanohttpd-webserver:2.2.0'
implementation 'de.faustedition:faust:1.4-SNAPSHOT'
implementation 'com.mycila:mycila-xmltool:4.4.ga'
implementation 'com.google.guava:guava-collections:r03'
// tools 'slimerjs:slimerjs:[email protected]'
// tools 'org.mozilla:firefox:[email protected]'
// exist 'org.exist-db:exist-ant:4.4.0' // ≥ 5.0.0
exist 'org.exist-db:exist-core:4.4.0' // < 5.0.0
exist 'org.exist-db:exist-optional:4.4.0' // < 5.0.0
testImplementation 'junit:junit:4.12'
}
task installTools(type: Copy) {
description "Installs SlimerJS and Firefox"
configurations.tools.asFileTree.each {
from(tarTree(it))
}
into toolDir
outputs.dir(toolDir)
}
task prepareWeb(type: NpmTask) {
workingDir = rootProject.file('src/main/web')
npmCommand = ['install']
}
task copyWeb(type: CopyWithSymlink) {
description "Copy the web page sources"
dependsOn prepareWeb
from fileTree("src/main/web")
into "$buildDir/www"
}
task copySource(type: CopyWithSymlink) {
from xmlDir
into "$buildDir/www/xml"
}
task copyTextXml(type: CopyWithSymlink) {
from("$buildDir/lesetext") {
include 'faust.xml'
}
into "$buildDir/www/download"
}
task copyWitnessStats(type: CopyWithSymlink) {
from("$buildDir/www/macrogenesis") { include 'witness-stats.json' }
into "$buildDir/www/data"
dependsOn copyWeb
}
task generateSVGs(type: JavaExec) {
description "Generates SVGs of diplomatic transcripts and overlays"
// dependsOn installTools
dependsOn npmInstall
dependsOn classes
dependsOn copyWeb // there are symlinks from svg_rendering/page to build/www. Probably not the best solution.
inputs.dir("$xmlDir/transcript")
outputs.dir("$buildDir/www/transcript")
environment 'LANG', 'en_US.UTF-8'
environment 'LC_ALL', 'en_US.UTF-8'
environment 'SLIMERJSLAUNCHER', "$toolDir/firefox/firefox"
def setupTask = tasks.getByName('nodeSetup')
def nodeDir = setupTask.nodeDir.get().file('bin/node').toString()
systemProperties([
'node.binary' : "$nodeDir",
'node.script' : "${rootDir}/render-multi-pages.js",
// 'phantomjs.binary': "$toolDir/slimerjs-1.0.0/slimerjs" ,
'faust.diplo.target': buildDir
])
systemProperties(project.properties.findAll { key, value -> key.matches('^faust\\.diplo\\..*') })
classpath sourceSets.main.runtimeClasspath
main 'net.faustedition.gen.DiplomaticConversion'
}
task xar(type: Zip) {
description "Assembles the eXist app for the search part"
group "Generate HTML"
dependsOn 'src:main:xproc:generateSearch'
dependsOn 'src:main:xproc:testimony'
dependsOn 'src:main:xproc:metadataHtml'
dependsOn 'src:main:xproc:bibliography'
dependsOn copyWeb
archiveFileName = "${existAppName}.xar"
destinationDir = buildDir
from(project.file('src/main/xproc/exist')) {
include "*.xql"
include "*.xqm"
include "*.xconf"
include "build.xml"
include "config/**/*"
}
from(project.file('src/main/xproc/exist')) {
include "*.xml"
exclude "build.xml"
expand(project.properties)
}
from(project.file('src/main/xproc/xslt')) {
include '*.xsl'
include '*.xml'
into 'xslt'
}
from("$buildDir/search") {
include '**/*'
into 'data'
}
from(project.file('src/main/web/content')) {
include '**/*'
into 'data/info'
}
from("$buildDir/www") {
include 'bibliography.html'
into 'data/info'
}
}
task deployRSync(type: Exec) {
dependsOn 'build'
workingDir buildDir
commandLine 'rsync', '-a', '-u', '--chmod=ug+rwX,o+rX,Dg+s', '--omit-dir-times', '--info=del,stats2,copy,flist2', "${buildDir}/www/", uploadUrl
}
task deployToExist {
dependsOn xar
inputs.file("$buildDir/${existAppName}.xar")
description 'Deploys the search app (xar) to the configured eXist instance'
group 'deploy'
doLast {
ant.taskdef(name: 'xdbStore', classname: 'org.exist.ant.XMLDBStoreTask', classpath: configurations.exist.asPath)
ant.taskdef(name: 'xdbXQuery', classname: 'org.exist.ant.XMLDBXQueryTask', classpath: configurations.exist.asPath)
ant.xdbStore(uri: "xmldb:exist://localhost:8080/exist/xmlrpc/db/upload",
user: 'admin', password: 'geheim', // FIXME before including real credentials extract to credentials plugin
createcollection: true,
srcfile: "$buildDir/${existAppName}.xar",
)
ant.xdbXQuery(uri: "xmldb:exist://localhost:8080/exist/xmlrpc/db",
user: 'admin', password: 'geheim', // FIXME before including real credentials extract to credentials plugin
outputproperty: 'existDeployResult',
query: """
try {
repo:undeploy('http://faustedition.net/exist/${existAppName}'),
repo:remove('http://faustedition.net/exist/${existAppName}')
} catch * {
'Undeployment of previous app ${existAppName} failed'
},
repo:install-and-deploy-from-db('/db/upload/${existAppName}.xar')
"""
)
logger.info(ant.existDeployResult)
}
}
assemble.dependsOn generateSVGs, copyWeb, copySource, xar, copyTextXml, copyWitnessStats, tasks.getByPath("src:main:xproc:assemble"), tasks.getByPath("macrogen:runMacrogenReporting")
task showProps { doLast {
project.properties.each { key, value -> println "$key=$value"}
}}
tasks.getByPath("src:main:xproc:generateSearch").dependsOn(tasks.getByPath("macrogen:runMacrogenAnalysis"))
tasks.getByPath("macrogen:runMacrogenReporting").dependsOn(tasks.getByPath("src:main:xproc:bargraphData"))
// tasks.getByPath("macrogen:runMacrogenAnalysis").dependsOn(tasks.getByPath("src:main:xproc:metadataJs"))
tasks.getByPath("macrogen:runMacrogenAnalysis").dependsOn(tasks.getByName("copyWeb"))
tasks.getByName("copyWitnessStats").dependsOn(tasks.getByPath("macrogen:runMacrogenReporting"))