forked from Unidata/tds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
344 lines (286 loc) · 12.9 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
import javax.xml.transform.TransformerFactory
description = 'The THREDDS Data Server (TDS) is a web server that provides catalog and data access services for ' +
'scientific data using OPeNDAP, OGC WCS and WMS, HTTP, and other remote-data-access protocols.'
ext.title = 'THREDDS Data Server (TDS)'
ext.url = 'https://www.unidata.ucar.edu/software/tds/'
apply from: "$rootDir/gradle/any/dependencies.gradle"
apply from: "$rootDir/gradle/any/war-published.gradle"
apply from: "$rootDir/gradle/any/gretty.gradle"
dependencies {
implementation enforcedPlatform (project(':tds-platform'))
testImplementation enforcedPlatform (project(':tds-testing-platform'))
implementation 'edu.ucar:bufr'
implementation 'edu.ucar:cdm-core'
implementation 'edu.ucar:cdm-radial'
implementation 'edu.ucar:cdm-misc'
implementation 'edu.ucar:cdm-image'
implementation 'edu.ucar:cdm-s3'
implementation 'edu.ucar:cdm-zarr'
implementation 'edu.ucar:grib'
implementation 'edu.ucar:netcdf4'
implementation 'edu.ucar:httpservices'
implementation 'edu.ucar:opendap'
implementation project(':opendap:opendap-servlet')
implementation project(':tdcommon')
implementation 'edu.ucar:cdm-mcidas'
implementation 'edu.ucar:waterml'
implementation project(':tds-ugrid')
implementation 'net.openhft:chronicle-map'
implementation 'jakarta.validation:jakarta.validation-api'
// DAP4 Dependencies (technically forward)
implementation 'edu.ucar:dap4'
implementation project(':dap4:d4servlet')
// Server stuff
providedCompile "jakarta.servlet:jakarta.servlet-api:${depVersion.jakartaServletApi}"
runtimeOnly "jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api"
runtimeOnly "org.glassfish.web:jakarta.servlet.jsp.jstl"
runtimeOnly 'org.apache.taglibs:taglibs-standard-spec'
runtimeOnly 'org.apache.taglibs:taglibs-standard-impl'
// Apache httpclient libraries
implementation 'org.apache.httpcomponents:httpclient'
implementation 'org.apache.httpcomponents:httpcore'
implementation 'com.coverity.security:coverity-escapers' // todo: replace with google escapers?
implementation 'org.jdom:jdom2'
implementation 'org.quartz-scheduler:quartz'
implementation 'com.google.code.findbugs:jsr305'
implementation 'com.google.guava:guava'
implementation 'joda-time:joda-time'
implementation 'org.apache.commons:commons-lang3'
// WaterML
implementation 'org.apache.xmlbeans:xmlbeans'
implementation 'org.n52.sensorweb:52n-xml-waterML-v20'
implementation 'org.n52.sensorweb:52n-xml-om-v20'
// Spring
implementation 'org.springframework:spring-core'
implementation 'org.springframework:spring-context'
implementation 'org.springframework:spring-beans'
implementation 'org.springframework:spring-web'
implementation 'org.springframework:spring-webmvc'
runtimeOnly 'org.springframework.security:spring-security-web' // Needed for FilterChainProxy in applicationContext.xml.
runtimeOnly 'org.springframework.security:spring-security-config' // Needed for "xmlns:security" schema in applicationContext.xml.
// Needed for XPath operations in mock tests
testImplementation 'jaxen:jaxen'
// Needed for XPaths in WmsDetailedConfig
runtimeOnly 'jaxen:jaxen'
// edal ncwms related libs
implementation('uk.ac.rdg.resc:edal-common')
implementation ('uk.ac.rdg.resc:edal-cdm')
implementation ('uk.ac.rdg.resc:edal-graphics')
implementation ('uk.ac.rdg.resc:edal-wms')
implementation('uk.ac.rdg.resc:edal-godiva')
// json writing
'org.json:json'
// JSR 303 with Hibernate Validator, which is dragging in jboss logging
runtimeOnly 'org.hibernate.validator:hibernate-validator'
runtimeOnly 'org.glassfish:jakarta.el'
annotationProcessor "org.hibernate.validator:hibernate-validator-annotation-processor:${depVersion.hibernateValidator}"
// @Resource annotation (removed post Java 8)
implementation 'jakarta.annotation:jakarta.annotation-api'
implementation 'org.thymeleaf:thymeleaf-spring6'
// Testing
testImplementation "jakarta.servlet:jakarta.servlet-api:${depVersion.jakartaServletApi}"
testImplementation 'org.springframework:spring-test'
testImplementation 'org.hamcrest:hamcrest-core'
testImplementation 'commons-io:commons-io'
testImplementation 'pl.pragmatists:JUnitParams'
testImplementation 'com.google.truth:truth'
testImplementation 'junit:junit'
testImplementation project(':tds-test-utils');
testImplementation 'edu.ucar:cdm-test-utils' // Contains stuff like the JUnit @Category classes.
testImplementation 'edu.ucar:httpservices'
testImplementation 'com.beust:jcommander'
// Logging
implementation 'org.slf4j:slf4j-api'
runtimeOnly 'org.apache.logging.log4j:log4j-slf4j-impl'
runtimeOnly 'org.apache.logging.log4j:log4j-jakarta-web'
testRuntimeOnly 'ch.qos.logback:logback-classic'
// This is for freshInstallTest
testImplementation 'org.xmlunit:xmlunit-core' // For comparing catalog XML.
}
// "testRuntime" extends from "runtime", meaning that "testRuntime" will get the log4j dependencies declared in
// "runtime". However, we want logback-classic to be the logger during tests, so exclude all of the log4j stuff.
configurations.testRuntimeOnly {
exclude group: 'org.apache.logging.log4j'
}
configurations.testRuntimeClasspath {
resolutionStrategy {
force "jakarta.servlet:jakarta.servlet-api:${depVersion.testJakartaServletApi}"
}
}
task copyWebappFilesForTests(type: Copy) {
// Tests expect for certain webapp files to be accessible from the classpath (e.g. WEB-INF/applicationContext.xml).
from 'src/main/webapp'
from 'src/main/webapp/WEB-INF/classes'
into sourceSets.test.java.outputDir
}
processTestResources {
dependsOn copyWebappFilesForTests
}
war {
// Assert that no servlet-api JAR is slated for inclusion in the WAR.
doFirst {
File servletApiJar = classpath.find { it.name.contains('servlet-api') }
if (servletApiJar) {
// This will fail the build.
throw new GradleException("Found a servlet-api JAR in the WAR classpath: ${servletApiJar.name}")
}
}
// Replace '$projectVersion' and '$buildTimestamp' placeholders with the correct values.
// Currently, we only use those placeholders in tds.properties and README.txt.
def properties = [:]
properties['projectVersion'] = project.version
properties['buildTimestamp'] = project.buildTimestamp // Defined in root project.
// War CopySpec already includes everything in 'src/main/webapp', which tds.properties lives within.
// So, the from() and into() methods aren't needed.
filesMatching('**/tds.properties') {
expand properties
}
from('README.txt') {
into 'docs'
expand properties
}
}
////////////////////////////////////// Godiva 3 //////////////////////////////////////
// Adapted from https://blog.eveoh.nl/2012/01/using-google-web-toolkit-with-gradle/
// 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6' is also available, but it has problems.
// First, it modifies the testRuntime configuration after project evaluation:
// https://github.com/steffenschaefer/gwt-gradle-plugin/issues/89. In the case of TDS, this lead to an old version
// of "validation-api" being present on the classpath, which caused hibernate-validator to fail.
//
// Second, it adds gwt-dev and gwt-user to the "compile" config and gwt-servlet to the "runtime" config.
// None of those are necessary at runtime: http://stackoverflow.com/a/5135151/3874643.
// Even worse, the JARs are *huge*, and inflated the size of tds.war by ~59 MB.
configurations {
gwt
}
dependencies {
// These are needed by the compileGwt task but nowhere else, which is why we place them in their own config.
gwt "com.google.gwt:gwt-user:${depVersion.gwt}"
gwt "com.google.gwt:gwt-dev:${depVersion.gwt}"
}
ext {
gwtDir = "${project.buildDir}/gwt"
extraDir = "${project.buildDir}/extra"
}
task compileGwt (dependsOn: classes, type: JavaExec) {
inputs.files(sourceSets.main.java.srcDirs).skipWhenEmpty()
inputs.dir sourceSets.main.output.resourcesDir
outputs.dir gwtDir
doFirst {
file(gwtDir).mkdirs()
}
main = 'com.google.gwt.dev.Compiler'
classpath {
[
configurations.gwt, // For com.google.gwt.dev.Compiler in "gwt-dev".
sourceSets.main.compileClasspath, // For 'uk/ac/rdg/resc/godiva/Godiva.gwt.xml' in "edal-java".
sourceSets.main.resources.srcDirs // For Godiva3.gwt.xml in 'tds/src/main/resources'.
]
}
args = [
'Godiva3', // The GWT module, from edal-godiva.
'-war', gwtDir,
'-logLevel', 'WARN', // Only get log messages at level WARN or above. We don't want the spammy output.
'-localWorkers', '2',
'-compileReport',
'-extra', extraDir,
]
maxHeapSize = '512M'
}
war {
dependsOn compileGwt
from gwtDir
destinationDirectory = new File(rootProject.getBuildDir(), "downloads")
archiveFileName = "thredds-${project.getVersion()}.war"
}
jar {
archiveClassifier = 'classes'
}
configurations.all {
// STAX is already included in Java 1.6+; no need for a third-party dependency.
/*
./gradlew -q tds:dependencyInsight --configuration runtime --dependency stax-api
stax:stax-api:1.0.1
+--- org.apache.xmlbeans:xmlbeans:2.6.0
| ...
\--- org.codehaus.jettison:jettison:1.3.7
\--- net.openhft:chronicle-map:2.4.15
...
*/
exclude group: 'stax', module: 'stax-api'
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
exclude group: 'net.openhft', module: 'chronicle-analytics'
}
////////////////////////////////////// Integration Tests //////////////////////////////////////
import org.akhikhl.gretty.AppBeforeIntegrationTestTask
import org.akhikhl.gretty.AppAfterIntegrationTestTask
import java.nio.file.Paths
test {
jvmArgs = jvmArguments
}
gretty {
httpPort = 8081
contextPath = '/thredds'
jvmArgs = jvmArguments
}
def testInfomation = [[name: 'freshInstallTest',
contentDir: file("$buildDir/tdsFreshContentDir"),
description: description = 'Runs tests on a fresh installation of TDS (no existing catalog.xml).'],
[name: 'integrationTests',
contentDir: file("$projectDir/src/test/content"),
description: description = 'Runs tds integration tests.']]
def previousTestTask = test
def previousTestTaskFinalizer = null
testInfomation.forEach { testInfo ->
sourceSets.create(testInfo.name) {
resources.srcDirs = [file("src/${testInfo.name}/resources")]
// Need 'sourceSets.test.output' because we use TestOnLocalServer in our test.
compileClasspath += sourceSets.test.output + configurations.testCompileClasspath
runtimeClasspath += output + sourceSets.test.output + configurations.testRuntimeClasspath
}
def thisTestTask = tasks.create("${testInfo.name}", Test) {
group = 'verification'
description testInfo.description as String
testClassesDirs = sourceSets.getByName("${testInfo.name}").output
classpath = sourceSets."${testInfo.name}".runtimeClasspath
mustRunAfter previousTestTask
// Use built-in Xalan XSLT instead of Saxon-HE.
// This works around an error we were seeing in org.xmlunit.builder.DiffBuilder.build():
// java.lang.ClassCastException: net.sf.saxon.value.ObjectValue cannot be cast to net.sf.saxon.om.NodeInfo
// ...
// at thredds.tds.TestFreshTdsInstall.shouldReturnExpectedClientCatalog(TestFreshTdsInstall.java:72)
// See buildSrc/build.gradle for another example of working around JAXP weirdness.
systemProperty TransformerFactory.name, // See javax.xml.transform.TransformerFactory.newInstance().
'com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl'
// Replace the system property that was propagated from the Gradle process in any/testing.gradle.
systemProperty 'tds.content.root.path',testInfo.contentDir.absolutePath
}
task ("before${testInfo.name.capitalize()}", type: AppBeforeIntegrationTestTask, group: 'gretty') {
dependsOn assemble
description = "Starts server before ${testInfo.name}."
inplace = false
integrationTestTask thisTestTask.getName()
debug = false // Start the embedded sever in debug mode.
// for integration tests that rely on gretty, make sure the embedded server is stopped before
// moving on to next test set.
if (previousTestTaskFinalizer != null) {
mustRunAfter previousTestTaskFinalizer
}
prepareServerConfig {
// The embedded TDS that this task launches will have a non-existent content root directory.
systemProperty 'tds.content.root.path', testInfo.contentDir.absolutePath
}
doFirst {
if(testInfo.name == "freshInstallTest") {
assert testInfo.contentDir.deleteDir(): "Couldn't delete ${testInfo.contentDir}."
}
}
}
previousTestTaskFinalizer = tasks.create("after${testInfo.name.capitalize()}", AppAfterIntegrationTestTask) {
group = "gretty"
description = "Stops server after ${testInfo.name}."
integrationTestTask thisTestTask.getName()
}
check.dependsOn thisTestTask
previousTestTask = thisTestTask
}