forked from researchspace/researchspace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
450 lines (361 loc) · 16.5 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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
/**
* ResearchSpace
* Copyright (C) 2020, © Trustees of the British Museum
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
plugins {
// Apply the war plugin to add support for Java webpapp build
id 'war'
// Apply java-library plugin to be able to use the whole researchspace as SDK
id 'java-library'
// To run app in the development mode with jetty container
id 'org.gretty' version '3.1.3'
// To run webpack-dev-server in the background
id 'com.github.psxpaul.execfork' version '0.1.13'
// To generate eclipse project files
id 'eclipse'
// To show task dependency graph
id "com.dorongold.task-tree" version "1.5"
}
version = findProperty('buildVersion') ?: '4.0-SNAPSHOT'
// currently we use Java 11 for development
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
clean {
delete "${projectDir}/src/main/webpapp/assets"
delete "${projectDir}/node_modules"
}
// set default formatter for eclipse project generated by gradle
def eclipseJdtProps = new Properties()
file("${projectDir}/.eclipse/org.eclipse.jdt.core.prefs").withInputStream {
eclipseJdtProps.load(it)
}
eclipse {
classpath {
downloadJavadoc = true
downloadSources = true
}
jdt {
file {
withProperties { properties ->
properties.putAll(eclipseJdtProps)
}
}
}
}
// configuration for war packaging
war {
from 'COPYING'
from 'COPYING.GPLv3'
manifest {
attributes('Version': version)
}
}
farms {
farm 'researchspace', {
// setup blazegraph for local development
webapp 'com.blazegraph:blazegraph-war:2.2.0-20160908.003514-6',
contextPath: '/blazegraph',
overlays: [':blazegraph-vocabularies']
// setup digilib for local development
webapp 'digilib:digilib-webapp:2.9.1',
contextPath: '/digilib',
initParameters: ["config-file": "./bundle-config/digilib-config.xml"]
webapp project,
contextPath: '/'
}
}
products {
product 'researchspace', {
additionalFiles = [
"./bundle-config/RWStore.properties": "./bundle-config/RWStore.properties",
"./bundle-config/digilib-config.xml": "./bundle-config/digilib-config.xml",
"./bundle-config/digilib-log4j-config.xml": "./bundle-config/digilib-log4j-config.xml",
"./bundle-config/ZipReadme.txt": "./README.txt",
"./LICENSE": "./LICENSE.txt",
"./COPYING": "./COPYING",
"./COPYING": "./COPYING.GPLv3",
"${projectDir.getAbsolutePath()}/src/main/resources/org/researchspace/apps/default/config/shiro.ini": "./runtime-data/config/shiro.ini"
]
}
}
def defaultJvmArgs = [
// blazegraph options, for runAll
"-Dcom.bigdata.rdf.sail.webapp.ConfigParams.propertyFile=./bundle-config/RWStore.properties",
// for properties that get value from project.properties see gradle.properties file for more details
"-Dconfig.environment.sparqlEndpoint=${project.properties['sparqlEndpoint']}",
"-Dconfig.proxy.IIIF.targetUri=${project.properties['iiifScaler']}",
"-Dconfig.environment.upload-iiifFolder=file://${projectDir.getAbsolutePath()}${project.properties['iiifFolder']}",
// delopment storages for image upload functionality
"-Dconfig.storage.images.type=nonVersionedFile",
"-Dconfig.storage.images.mutable=true",
// tmp storage is needed for image upload functionality
"-Dconfig.storage.tmp.type=nonVersionedFile",
"-Dconfig.storage.tmp.mutable=true",
// "-Dconfig.global.loadDefaultConfig=1",
// Increase size limit for file upload
"-Dorg.eclipse.jetty.server.Request.maxFormContentSize=104857600"
]
// configuration for local jetty container
gretty {
// see actual jetty version in gradle.properties
servletContainer = 'jetty9.4'
httpPort = 10214
contextPath = '/'
// to serve web assets directly from src/main/webpapp folder
// see https://akhikhl.github.io/gretty-doc/Gretty-configuration.html#_inplacemode
// see https://akhikhl.github.io/gretty-doc/Fast-reload.html
inplaceMode = 'hard'
redeployMode = 'redeploy'
// don't restart jetty when templates in the resource folder are changed
fastReload = "${projectDir.getAbsolutePath()}/src/main/resources/org/researchspace/apps".toString()
// use custom jetty-env.xml to disable websocket support
contextConfigFile = "${projectDir}/jetty-env.xml"
recompileOnSourceChange = false
if (project.gradle.startParameter.taskNames.contains('buildZip')) {
jvmArgs = defaultJvmArgs + [
"-DruntimeDirectory=./runtime-data",
"-Dorg.researchspace.config.baselocation=./runtime-data/config",
"-Dconfig.storage.images.root=./runtime-data/images",
"-Dconfig.storage.tmp.root=./runtime-data/tmp",
"-Dlog4j.configurationFile=classpath:org/researchspace/logging/log4j2.xml",
]
} else {
jvmArgs = defaultJvmArgs + [
"-Dconfig.storage.images.root=${project.properties['imageStorageRoot']}",
"-Dconfig.storage.tmp.root=${java.nio.file.Files.createTempDirectory('images-tmp')}",
// set development mode to true to make sure that assets are always up to date
// see bindings for AssetsMapProvider in MainGuiceModule.java
"-DisDevelopmentMode=true",
"-DruntimeDirectory=${projectDir.getAbsolutePath()}/runtime-data",
// sets the location to the config folder to a temporary location for development
"-Dorg.researchspace.config.baselocation=${projectDir.getAbsolutePath()}/runtime-data/config",
// make apps writable in local development mode
'-Dconfig.mutablePluginApps=true',
// You may change the log4j settings by switching to one of the predefined log4j2 config files,
// see /src/main/resources/org/researchspace/logging for options (descriptions of log behavior is given in the files).
// - Development log files: log4j2-debug.xml, log4j2-trace.xml, log4j2-trace2.xml
// - Production log files: log4j2.xml, log4j2-debug.xml
"-Dlog4j.configurationFile=classpath:org/researchspace/logging/${findProperty('logLevel')}.xml",
"-Dconfig.environment.shiroConfig=${projectDir.getAbsolutePath()}/src/main/resources/org/researchspace/apps/default/config/shiro.ini"
]
}
}
// install npm dependencies in development mode
task npmInstall(type: Exec) {
executable 'npm'
args 'i', '--no-audit', '--no-fund', '--loglevel=error'
}
// we want to get clean node_modules when we are building on CI or production version locally
// see https://docs.npmjs.com/cli/ci
task npmInstallCi(type: Exec) {
executable 'npm'
args 'ci', '--no-audit', '--no-fund', '--loglevel=error'
}
// execute webpack in production mode with minifications, etc
task runProdWebpack(type: Exec) {
executable 'npm'
args 'run', 'prod'
}
tasks.runProdWebpack.dependsOn npmInstallCi
// task to execute webpack in watch mode, see ./webpack/package.json
task startWebpack(type: com.github.psxpaul.task.ExecFork) {
executable = 'npm'
args = [ 'run', 'dev' ]
timeout = 1200
// wait for message produces by webpack in minimal log mode
waitForOutput = 'modules'
}
tasks.startWebpack.dependsOn npmInstall
// define custom start task so we have more convenient names than
// farmRunresearchspace, appRun, farmRunDebugresearchspace, appRunDebug, archiveProductresearchspace
task runAll
task run
task debugAll
task debug
task buildZip
// here we connect our custom tasks to builtins
// see https://stackoverflow.com/a/33960441 on why project.afterEvaluate is needed
project.afterEvaluate {
// run production webpack build if we are building war package
tasks.war.dependsOn runProdWebpack
// run webpack in dev mode if we are running local gretty task
tasks.prepareInplaceWebApp.dependsOn startWebpack
// for some reason overlay explode task that is needed for farm overlays is not added as a dependency
tasks.farmRunresearchspace.dependsOn tasks['farmOverlayArchiveresearchspaceblazegraph-war-2.2.0-20160908.003514-6.war']
tasks.farmRunDebugresearchspace.dependsOn tasks['farmOverlayArchiveresearchspaceblazegraph-war-2.2.0-20160908.003514-6.war']
tasks.buildProductresearchspace.dependsOn tasks['farmOverlayArchiveresearchspaceblazegraph-war-2.2.0-20160908.003514-6.war']
// connect our custom tasks with tasks from gretty
tasks.debugAll.dependsOn tasks.farmRunDebugresearchspace
tasks.debug.dependsOn tasks.appRunDebug
tasks.runAll.dependsOn tasks.farmRunresearchspace
tasks.run.dependsOn tasks.appRun
tasks.buildZip.dependsOn tasks.archiveProductresearchspace
}
// execute frontend tests
task testKarma(type: Exec) {
workingDir "$projectDir/webpack"
executable 'npm'
args 'run', 'test-ci'
}
tasks.testKarma.dependsOn npmInstall
test.dependsOn testKarma
task runWiremock(type: JavaExec) {
group = "Execution"
description = "Run WireMock recorder"
classpath = sourceSets.test.runtimeClasspath
main = "com.github.tomakehurst.wiremock.standalone.WireMockServerRunner"
args "--port", "10220"
}
repositories {
mavenCentral()
// for blazegraph war
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
// for digilib war
maven { url 'https://robcast.github.io/digilib-repo/maven-repo' }
// needed for SMAL2 integration
maven { url 'https://build.shibboleth.net/nexus/content/repositories/releases/' }
}
ext {
RDF4J_VERSION = '3.5.1'
LOG4J_VERSION = '2.15.0'
JERSEY_VERSION = '2.30.1'
JACKSON_VERSION = '2.10.3'
GUICE_VERSION = '4.2.3'
SHIRO_VERSION = '1.7.1'
IMAGEIO_VERSION = '3.5'
}
configurations.all {
// we use httpclient instead of httpclient-osgi used in RDF4J
exclude group: "org.apache.httpcomponents", module: "httpclient-osgi"
// excludes xml.bind-api from javax we already have jakarta one in the classpath
exclude group: 'javax.xml.bind', module: 'jaxb-api'
}
dependencies {
implementation platform('com.amazonaws:aws-java-sdk-bom:1.11.994')
implementation 'com.amazonaws:aws-java-sdk-s3'
implementation 'org.semarglproject:semargl-rdf:0.7'
compileOnly (
"javax.servlet:javax.servlet-api:3.1.0",
// add jetty as compile dependency so we get sources and javadocs and can debug it locally
"org.eclipse.jetty:jetty-server:${jetty94_version}",
"org.eclipse.jetty:jetty-servlet:${jetty94_version}"
)
api (
//security
// shiro-jaxrs includes shiro-core and shiro-web
//
// All shiro 1.x versions have bug with duplicated classes in the classpath, see https://issues.apache.org/jira/browse/SHIRO-632 . It will be solved in shiro 2.0
"org.apache.shiro:shiro-jaxrs:${SHIRO_VERSION}",
) {
// excludes old-style ws.rs-api used in shiro-jaxrs, we have jakarta ws.rs-api in the classpath coming from jersey
exclude group: 'javax.ws.rs', module: 'javax.ws.rs-api'
}
api (
// RDF4J dependencies
"org.eclipse.rdf4j:rdf4j-sail-nativerdf:${RDF4J_VERSION}",
"org.eclipse.rdf4j:rdf4j-sail-memory:${RDF4J_VERSION}",
"org.eclipse.rdf4j:rdf4j-sail-federation:${RDF4J_VERSION}",
"org.eclipse.rdf4j:rdf4j-rio-binary:${RDF4J_VERSION}",
"org.eclipse.rdf4j:rdf4j-rio-n3:${RDF4J_VERSION}",
"org.eclipse.rdf4j:rdf4j-rio-nquads:${RDF4J_VERSION}",
"org.eclipse.rdf4j:rdf4j-rio-ntriples:${RDF4J_VERSION}",
"org.eclipse.rdf4j:rdf4j-rio-rdfjson:${RDF4J_VERSION}",
"org.eclipse.rdf4j:rdf4j-rio-rdfxml:${RDF4J_VERSION}",
"org.eclipse.rdf4j:rdf4j-rio-trig:${RDF4J_VERSION}",
"org.eclipse.rdf4j:rdf4j-rio-trix:${RDF4J_VERSION}",
"org.eclipse.rdf4j:rdf4j-rio-turtle:${RDF4J_VERSION}",
"org.eclipse.rdf4j:rdf4j-rio-jsonld:${RDF4J_VERSION}",
"org.eclipse.rdf4j:rdf4j-queryrender:${RDF4J_VERSION}",
"org.eclipse.rdf4j:rdf4j-queryresultio-sparqljson:${RDF4J_VERSION}",
"org.eclipse.rdf4j:rdf4j-queryresultio-text:${RDF4J_VERSION}",
"org.eclipse.rdf4j:rdf4j-repository-manager:${RDF4J_VERSION}",
// logging related dependencies
"org.apache.logging.log4j:log4j-api:${LOG4J_VERSION}",
"org.apache.logging.log4j:log4j-core:${LOG4J_VERSION}",
"org.apache.logging.log4j:log4j-web:${LOG4J_VERSION}",
"org.apache.logging.log4j:log4j-1.2-api:${LOG4J_VERSION}",
"org.apache.logging.log4j:log4j-slf4j-impl:${LOG4J_VERSION}",
"org.apache.logging.log4j:log4j-jul:${LOG4J_VERSION}",
"org.apache.logging.log4j:log4j-jcl:${LOG4J_VERSION}",
// Jersey, JAX-RS implementation
"org.glassfish.jersey.core:jersey-server:${JERSEY_VERSION}",
"org.glassfish.jersey.containers:jersey-container-servlet:${JERSEY_VERSION}",
"org.glassfish.jersey.media:jersey-media-json-jackson:${JERSEY_VERSION}",
"org.glassfish.jersey.media:jersey-media-multipart:${JERSEY_VERSION}",
"org.glassfish.jersey.inject:jersey-hk2:${JERSEY_VERSION}",
// Jackson, for JSON handling
"com.fasterxml.jackson.core:jackson-core:${JACKSON_VERSION}",
"com.fasterxml.jackson.core:jackson-databind:${JACKSON_VERSION}",
"com.fasterxml.jackson.core:jackson-annotations:${JACKSON_VERSION}",
"com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:${JACKSON_VERSION}",
"com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:${JACKSON_VERSION}",
// Google Guice, for dependency injection
"com.google.inject:guice:${GUICE_VERSION}",
"com.google.inject.extensions:guice-servlet:${GUICE_VERSION}",
//jersey-guice integration
"org.glassfish.hk2:guice-bridge:2.6.1",
"io.buji:buji-pac4j:6.0.0-RC1",
"org.pac4j:pac4j-oidc:5.0.0-RC1",
"org.pac4j:pac4j-saml:5.0.0-RC1",
// Apache commons stuff
"org.apache.commons:commons-compress:1.20",
"org.apache.commons:commons-lang3:3.10",
// configuration
"org.apache.commons:commons-configuration2:2.7",
"commons-beanutils:commons-beanutils:1.9.4",
//guava
"com.google.guava:guava:28.2-jre",
//security
"org.apache.shiro:shiro-guice:${SHIRO_VERSION}",
//templates
"com.github.jknack:handlebars:4.2.0",
//semantic versioning
"com.github.zafarkhaja:java-semver:0.9.0",
// java classes and resources reflection, i.e. annotation scanning on classpath
"io.github.classgraph:classgraph:4.8.68",
// http client
"org.apache.httpcomponents:httpclient:4.5.12",
// extracting the prefered mime type, for example, sparql servlet
"org.commonjava.mimeparse:mimeparse:0.1.3.3",
//pf4j plugin framework
"ro.fortsoft.pf4j:pf4j:1.3.0",
"org.mitre.dsmiley.httpproxy:smiley-http-proxy-servlet:1.12",
//JsonPath
"com.jayway.jsonpath:json-path:2.5.0",
// JGit for Git storage support
"org.eclipse.jgit:org.eclipse.jgit:5.13.1.202206130422-r",
"org.eclipse.jgit:org.eclipse.jgit.ssh.apache:5.13.1.202206130422-r",
"com.twelvemonkeys.imageio:imageio-tiff:${IMAGEIO_VERSION}",
"com.twelvemonkeys.imageio:imageio-core:${IMAGEIO_VERSION}",
)
testImplementation (
"org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-inmemory:${JERSEY_VERSION}",
"org.hamcrest:hamcrest-library:1.3",
"org.hamcrest:hamcrest-core:1.3",
"com.novocode:junit-interface:0.11",
"org.mockito:mockito-core:1.9.5",
"junit:junit:4.10",
"com.github.sdorra:shiro-unit:1.0.1",
"org.jukito:jukito:1.4.1",
"org.skyscreamer:jsonassert:1.5.0",
"com.github.tomakehurst:wiremock-jre8:2.27.2"
)
testImplementation(
"com.github.tomakehurst:wiremock-jre8:2.27.2"
) {
exclude group: "org.hamcrest", module: "hamcrest-core"
}
}