This repository has been archived by the owner on Apr 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.gradle
300 lines (235 loc) · 9.48 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
plugins {
id 'war'
id 'java-library'
id 'jacoco'
id 'org.gretty' version '3.0.4'
id 'com.diffplug.spotless' version '5.11.1'
id 'edu.ucar.unidata.site.jekyll' version '0.0.3'
id 'edu.ucar.unidata.nexus' version '0.0.1'
id 'org.owasp.dependencycheck' version '6.5.0.1'
}
repositories {
maven {
url 'https://artifacts.unidata.ucar.edu/repository/unidata-all/'
}
maven {
url 'https://artifacts.unidata.ucar.edu/repository/unidata-snapshots/'
}
}
import org.apache.commons.io.FileUtils
compileJava {
options.compilerArgs << '-Xlint:deprecation' << '-Xlint:unchecked'
}
group = 'edu.ucar.unidata'
version = '0.3.0-SNAPSHOT'
description = """rosetta"""
sourceCompatibility = 1.8
targetCompatibility = 1.8
ext {
// needed for Jekyll
// It makes sense to publish major.minor versions of the docs, as
// any patch bumps should be backwards compatible bug fixes only
// To do this, we need to make a special "doc version" string.
// First, drop any dangling snapshot, alpha, beta tags
cleanVersion = "$version".split('-')[0]
// tokenize version on the '.' character, which gives us a list of [major, minor, patch]
docVersionParts = cleanVersion.tokenize('.')
// we should always have a major, minor, and patch value in our version
assert docVersionParts.size == 3
// keep major and minor parts of the version and use those to version the docs
docVersion = docVersionParts[0] + '.' + docVersionParts[1]
}
dependencies {
implementation enforcedPlatform('edu.ucar:netcdf-java-bom:5.5.3-SNAPSHOT')
implementation enforcedPlatform('edu.ucar:netcdf-java-platform:5.5.3-SNAPSHOT')
implementation enforcedPlatform('org.springframework:spring-framework-bom:5.3.18')
implementation enforcedPlatform('org.springframework.security:spring-security-bom:5.6.2')
implementation enforcedPlatform('com.fasterxml.jackson:jackson-bom:2.13.2')
implementation enforcedPlatform('org.apache.logging.log4j:log4j-bom:2.17.2')
// Spring Framework
implementation 'org.springframework:spring-beans'
implementation 'org.springframework:spring-context'
implementation 'org.springframework:spring-core'
implementation 'org.springframework:spring-expression'
implementation 'org.springframework:spring-web'
implementation 'org.springframework:spring-webmvc'
implementation 'org.springframework:spring-jdbc'
implementation 'org.springframework:spring-jcl' // logging bridge for spring
// Spring Security
implementation 'org.springframework.security:spring-security-web'
implementation 'org.springframework.security:spring-security-config'
implementation 'org.springframework.security:spring-security-taglibs'
// netCDF-Java/CDM deps
implementation 'edu.ucar:cdm-core'
implementation 'edu.ucar:netcdf4'
// handle intellij annotation warnings
implementation group: 'com.intellij', name: 'annotations', version: '12.0'
// JSON / xml processing
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.2'
implementation 'com.fasterxml.jackson.core:jackson-core:2.13.2'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.13.2'
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
// takes the place of javax.activation package
implementation 'com.sun.activation:javax.activation:1.2.0'
implementation 'commons-codec:commons-codec:1.11'
implementation 'commons-dbcp:commons-dbcp:1.4'
implementation 'commons-fileupload:commons-fileupload:1.3.3'
implementation 'commons-io:commons-io:2.11.0'
implementation 'org.apache.commons:commons-lang3:3.4'
implementation 'org.apache.commons:commons-text:1.3'
implementation 'org.apache.httpcomponents:httpclient'
implementation 'org.apache.derby:derby:10.14.2.0'
implementation 'org.apache.taglibs:taglibs-standard-jstlel:1.2.5'
implementation 'javax.servlet:javax.servlet-api:3.1.0'
implementation 'javax.annotation:javax.annotation-api:1.3.2'
// input validation
implementation 'org.hibernate:hibernate-validator:6.0.22.Final'
implementation 'javax.validation:validation-api:2.0.1.Final'
implementation('net.sourceforge.jexcelapi:jxl:2.6.12') {
exclude group: 'log4j', module: 'log4j'
}
// replace log4j 1.x with the log4j 1.2 bridge
runtimeOnly 'org.apache.logging.log4j:log4j-1.2-api'
// logging
implementation 'org.apache.logging.log4j:log4j-api'
runtimeOnly 'org.apache.logging.log4j:log4j-core'
runtimeOnly 'org.apache.logging.log4j:log4j-web'
// edu.ucar:httpservices uses uses Apache Commons Logging 1.x, so add the JCL bridge
runtimeOnly "org.apache.logging.log4j:log4j-jcl"
// Testing
testImplementation 'de.bechte.junit:junit-hierarchicalcontextrunner:4.12.2'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.hamcrest:hamcrest-library:1.3'
testImplementation 'org.hamcrest:hamcrest-core:1.3'
testImplementation 'org.mockito:mockito-all:1.10.19'
testImplementation 'org.mockito:mockito-core:2.18.3'
testImplementation 'org.apache.httpcomponents:httpmime'
// Spring Test
testImplementation 'org.springframework:spring-test'
testImplementation 'org.springframework.security:spring-security-test'
}
war {
archiveFileName = 'rosetta.war'
manifest {
attributes 'Implementation-Version': project.version,
'Implementation-Title': project.name,
'Implementation-Vendor': 'UCAR/Unidata',
'Implementation-Vendor-Id': project.group,
'Built-On': new Date(),
'Build-Jdk': JavaVersion.current()
}
}
test {
testLogging {
events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
}
useJUnit {
excludeCategories 'edu.ucar.unidata.rosetta.util.test.category.NeedsLocalServer'
}
}
dependencyCheck {
data {
directory="$rootDir/project-files/owasp-dependency-check/nvd"
}
scanConfigurations = ['compileClasspath', 'runtimeClasspath']
suppressionFile = "$rootDir/project-files/owasp-dependency-check/dependency-check-suppression.xml"
// fail the build if any vulnerable dependencies are identified (any CVSS score > 0).
failBuildOnCVSS = 0
}
/////////////
sourceSets {
integrationTests {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/test/java')
}
resources.srcDir file('src/test/resources')
}
}
configurations {
integrationTestsCompile.extendsFrom testImplementation
integrationTestsRuntime.extendsFrom testRuntimeOnly
}
task integrationTests(type: Test) {
description 'Runs tests that require a rosetta server running at localhost:8888.'
testLogging {
events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
}
useJUnit {
includeCategories 'edu.ucar.unidata.rosetta.util.test.category.NeedsLocalServer'
}
testClassesDirs = sourceSets.integrationTests.output.classesDirs
classpath = sourceSets.integrationTests.runtimeClasspath
outputs.upToDateWhen { false }
}
// allow servlet container to be configured by setting a system property
// default to tomcat 9.x.x
def servletContainerName = System.getProperty('tds.test.gretty.container')
if (servletContainerName == null || servletContainerName.isEmpty()) {
servletContainerName = 'tomcat9'
}
gretty {
servletContainer "$servletContainerName"
httpPort = 8888
// make sure to run as a war, otherwise WEB-INF/classes won't be picked up
inplace = false
contextPath = '/rosetta'
jvmArgs = ["-Drosetta.content.root.path=$rootDir/src/test/rosetta_home"]
integrationTestTask = 'integrationTests'
configurations {
grettyRunnerTomcat85 {
exclude group: 'org.slf4j', module: 'log4j-over-slf4j'
}
}
onStop {
// cleans up ROSETTA_HOME, which is populated during the integration test process
print 'Cleaning up test ROSETTA_HOME'
File folder = new File("$rootDir/src/test/rosetta_home" as String)
FileUtils.cleanDirectory(folder)
}
}
wrapper {
// to upgrade gradle, bump the version here and then run
// ./gradlew wrapper
distributionType = Wrapper.DistributionType.ALL
gradleVersion = '6.9.1'
}
spotless {
java {
target '**/*.java'
eclipse().configFile 'styles/eclipse-style-guide.xml'
encoding 'UTF-8'
}
}
//////////////////////////////////////////////// Nexus ////////////////////////////////////////////////
apply from: "$rootDir/gradle/any/properties.gradle" // For Nexus credential properties.
import edu.ucar.build.publishing.tasks.PublishToRawRepoTask
tasks.withType(PublishToRawRepoTask).all { // Common PublishToRawRepoTask config.
group = 'Documentation'
host = 'https://artifacts.unidata.ucar.edu/'
repoName = 'docs-rosetta'
onlyIf {
// Will be evaluated at task execution time, not during configuration.
// Fails the build if the specified properties haven't been provided.
username = getPropertyOrFailBuild NEXUS_USERNAME_KEY
password = getPropertyOrFailBuild NEXUS_PASSWORD_KEY
return true
}
}
tasks.register('publishAsVersionedUserGuide', PublishToRawRepoTask) {
description = 'Publish user guide (versioned) to Nexus under /major.minor/.'
publishSrc = buildJekyllSite.destinationDirectory.get()
destPath = "$project.docVersion/userguide/"
dependsOn tasks.getByName('buildJekyllSite')
}
tasks.register('publishAsCurrentUserGuide', PublishToRawRepoTask) {
description = 'Publish the user guide to Nexus under /current/.'
publishSrc = buildJekyllSite.destinationDirectory.get()
destPath = 'current/userguide/'
dependsOn tasks.getByName('buildJekyllSite')
}
// need to run test task before jacocoTestReport
jacocoTestReport.dependsOn test
check.dependsOn integrationTests
integrationTests.mustRunAfter test