Skip to content

Commit fe41e87

Browse files
Merge pull request #435 from bclayton-usgs/haz-ws
Migrate nshmp-haz-ws
2 parents 4a1dbce + 40d8cb9 commit fe41e87

139 files changed

Lines changed: 35885 additions & 6 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ eq-rate*/
1313
Scratch*.java
1414
nshmp-haz-log*
1515
.vscode
16+
config.properties

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.project
33
.settings
44
.gradle
5+
.vscode
56
bin
67
build
78
classes
@@ -12,4 +13,9 @@ eq-prob*/
1213
eq-rate*/
1314
Scratch*.java
1415
nshmp-haz-log*
15-
.vscode
16+
webapp/models
17+
webapp/jsdocs
18+
scratch*.html
19+
Scratch*.js
20+
webapp/config.json
21+
config.properties

build.gradle

Lines changed: 151 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11

2-
apply plugin: 'java'
32
apply plugin: 'jacoco'
3+
apply plugin: 'war'
44
apply plugin: 'eclipse-wtp'
55

66
sourceCompatibility = 1.8
77
compileJava.options.encoding = 'UTF-8'
88

99
jacoco {
10-
toolVersion = '0.8.4'
10+
toolVersion = '0.8.4'
1111
}
1212

1313
repositories {
@@ -20,6 +20,14 @@ dependencies {
2020
transitive = false
2121
}
2222
compile 'com.google.code.gson:gson:2.8.5'
23+
24+
compile 'org.apache.tomcat:tomcat-catalina:8.0.45'
25+
compile 'javax.websocket:javax.websocket-api:1.1'
26+
compile 'com.amazonaws:aws-lambda-java-core:1.1.0'
27+
compile 'com.amazonaws:aws-java-sdk-lambda:1.11.461'
28+
compile 'com.amazonaws:aws-java-sdk-s3:1.11.579'
29+
compile 'com.amazonaws:aws-java-sdk-ec2:1.11.619'
30+
2331
testCompile 'junit:junit:4.12'
2432
}
2533

@@ -46,6 +54,50 @@ sourceSets {
4654

4755
ext {
4856
projectName = 'nshmp-haz'
57+
58+
propsPath = '/classes/java/main/service.properties'
59+
60+
/* Multi-model repository paths for version tracking */
61+
repo_cous_2008 = '../nshm-cous-2008'
62+
repo_cous_2014 = '../nshm-cous-2014'
63+
repo_cous_2014b = '../nshm-cous-2014b'
64+
repo_cous_2018 = '../nshm-cous-2018'
65+
repo_hi_2020 = '../nshm-hi-2020'
66+
repo_ak_2007 = '../nshm-ak-2007'
67+
68+
/* Explicit model paths */
69+
model_wus_2008 = "${repo_cous_2008}/Western US"
70+
model_ceus_2008 = "${repo_cous_2008}/Central & Eastern US"
71+
model_wus_2014 = "${repo_cous_2014}/Western US"
72+
model_ceus_2014 = "${repo_cous_2014}/Central & Eastern US"
73+
model_wus_2014b = "${repo_cous_2014b}/Western US"
74+
model_wus_2018 = "${repo_cous_2018}/Western US"
75+
model_ceus_2018 = "${repo_cous_2018}/Central & Eastern US"
76+
model_hi_2020 = "${repo_hi_2020}"
77+
model_ak_2007 = "${repo_ak_2007}"
78+
79+
/* Production models */
80+
prod_models = [
81+
[ model_ak_2007, 'models/ak/2007' ],
82+
[ model_ceus_2008, 'models/ceus/2008' ],
83+
[ model_wus_2008, 'models/wus/2008' ],
84+
[ model_ceus_2014, 'models/ceus/2014' ],
85+
[ model_wus_2014, 'models/wus/2014' ],
86+
[ model_wus_2014b, 'models/wus/2014b' ]
87+
]
88+
89+
/* Development models */
90+
dev_models = [
91+
[ model_ceus_2018, 'models/ceus/2018' ],
92+
[ model_wus_2018, 'models/wus/2018' ],
93+
[ model_hi_2020, 'models/hi/2020' ]
94+
]
95+
96+
getGitTag = { gitDir ->
97+
def cmd = 'git --git-dir=' + gitDir + '/.git describe --tags'
98+
return cmd.execute().text.replace('\n', '') ?: 'unknown'
99+
}
100+
49101
/*
50102
* The git-dir option gets the correct tag when
51103
* build is called from nshmp-haz-ws.
@@ -90,7 +142,6 @@ jacocoTestReport {
90142
}
91143
check.dependsOn jacocoTestReport
92144

93-
94145
javadoc {
95146
options.setUse(true)
96147
options.author(true)
@@ -107,6 +158,8 @@ javadoc {
107158
'https://google.github.io/guava/releases/23.0/api/docs/',
108159
'https://google.github.io/gson/apidocs/')
109160
include 'gov/usgs/earthquake/nshmp/**'
161+
exclude 'gov/usgs/earthquake/nshmp/www/**'
162+
exclude 'gov/usgs/earthquake/nshmp/aws/**'
110163
exclude 'gov/usgs/earthquake/nshmp/etc/**'
111164
exclude 'gov/usgs/earthquake/nshmp/internal/**'
112165
exclude '**/Scratch*'
@@ -134,7 +187,6 @@ javadoc {
134187
*/
135188
jar {
136189
doFirst {
137-
138190
/* possible fat jar */
139191
if (rootProject.name == projectName && !thinJar) {
140192
from { configurations.compile.collect {
@@ -169,4 +221,98 @@ task thinJar(type: Jar) {
169221
}
170222
with jar
171223
}
172-
224+
225+
/**
226+
* Create war file with production models
227+
*/
228+
war {
229+
enabled = true
230+
webAppDirName = 'webapp'
231+
232+
/*
233+
* Exclude existing models directory with symlinks
234+
* to support Eclipse deployments.
235+
*/
236+
exclude 'models'
237+
238+
prod_models.each{model ->
239+
from(model[0]) { into model[1] }
240+
}
241+
242+
doFirst {
243+
/* Record service and model versions */
244+
writeProperties()
245+
}
246+
}
247+
248+
/**
249+
* Create a war file with development models
250+
*/
251+
task assembleDev(type: War, dependsOn: 'war') {
252+
prod_models.each{model ->
253+
from(model[0]) { into model[1] }
254+
}
255+
256+
dev_models.each{model ->
257+
from(model[0]) { into model[1] }
258+
}
259+
}
260+
261+
/**
262+
* Create am exploded war file with production models
263+
*/
264+
task assembleUsgs(type: Sync) {
265+
into "${libsDir}/exploded-war"
266+
with war
267+
268+
doFirst {
269+
/* Record service and model versions */
270+
writeProperties()
271+
}
272+
}
273+
274+
/**
275+
* Create am exploded war file with development models
276+
*/
277+
task assembleUsgsDev(type: Sync) {
278+
into "${libsDir}/exploded-war"
279+
with assembleDev
280+
281+
doFirst {
282+
/* Record service and model versions */
283+
writeProperties()
284+
}
285+
}
286+
287+
/**
288+
* Create a zip file of all dependencies
289+
*/
290+
task dependencies(type: Zip) {
291+
baseName = "nshmp-haz-ws-dependencies"
292+
from {
293+
configurations.compile.collect {
294+
it
295+
}
296+
}
297+
298+
into("java/lib")
299+
300+
destinationDir libsDir
301+
}
302+
303+
/**
304+
* Create properties file
305+
*/
306+
def writeProperties() {
307+
def props = new Properties()
308+
def propsFile = new File(project.buildDir.toString() + propsPath)
309+
propsFile.createNewFile()
310+
props.setProperty('app.version', getGitTag('.'))
311+
props.setProperty('E2007.version', getGitTag(repo_ak_2007))
312+
props.setProperty('E2008.version', getGitTag(repo_cous_2008))
313+
props.setProperty('E2014.version', getGitTag(repo_cous_2014))
314+
props.setProperty('E2014B.version', getGitTag(repo_cous_2014b))
315+
props.setProperty('E2018.version', getGitTag(repo_cous_2018))
316+
props.setProperty('E2020.version', getGitTag(repo_hi_2020))
317+
props.store(propsFile.newWriter(), null)
318+
}

0 commit comments

Comments
 (0)