Skip to content

Commit

Permalink
Merge pull request #435 from bclayton-usgs/haz-ws
Browse files Browse the repository at this point in the history
Migrate nshmp-haz-ws
  • Loading branch information
pmpowers-usgs authored Sep 24, 2019
2 parents 4a1dbce + 40d8cb9 commit fe41e87
Show file tree
Hide file tree
Showing 139 changed files with 35,885 additions and 6 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ eq-rate*/
Scratch*.java
nshmp-haz-log*
.vscode
config.properties
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.project
.settings
.gradle
.vscode
bin
build
classes
Expand All @@ -12,4 +13,9 @@ eq-prob*/
eq-rate*/
Scratch*.java
nshmp-haz-log*
.vscode
webapp/models
webapp/jsdocs
scratch*.html
Scratch*.js
webapp/config.json
config.properties
156 changes: 151 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'war'
apply plugin: 'eclipse-wtp'

sourceCompatibility = 1.8
compileJava.options.encoding = 'UTF-8'

jacoco {
toolVersion = '0.8.4'
toolVersion = '0.8.4'
}

repositories {
Expand All @@ -20,6 +20,14 @@ dependencies {
transitive = false
}
compile 'com.google.code.gson:gson:2.8.5'

compile 'org.apache.tomcat:tomcat-catalina:8.0.45'
compile 'javax.websocket:javax.websocket-api:1.1'
compile 'com.amazonaws:aws-lambda-java-core:1.1.0'
compile 'com.amazonaws:aws-java-sdk-lambda:1.11.461'
compile 'com.amazonaws:aws-java-sdk-s3:1.11.579'
compile 'com.amazonaws:aws-java-sdk-ec2:1.11.619'

testCompile 'junit:junit:4.12'
}

Expand All @@ -46,6 +54,50 @@ sourceSets {

ext {
projectName = 'nshmp-haz'

propsPath = '/classes/java/main/service.properties'

/* Multi-model repository paths for version tracking */
repo_cous_2008 = '../nshm-cous-2008'
repo_cous_2014 = '../nshm-cous-2014'
repo_cous_2014b = '../nshm-cous-2014b'
repo_cous_2018 = '../nshm-cous-2018'
repo_hi_2020 = '../nshm-hi-2020'
repo_ak_2007 = '../nshm-ak-2007'

/* Explicit model paths */
model_wus_2008 = "${repo_cous_2008}/Western US"
model_ceus_2008 = "${repo_cous_2008}/Central & Eastern US"
model_wus_2014 = "${repo_cous_2014}/Western US"
model_ceus_2014 = "${repo_cous_2014}/Central & Eastern US"
model_wus_2014b = "${repo_cous_2014b}/Western US"
model_wus_2018 = "${repo_cous_2018}/Western US"
model_ceus_2018 = "${repo_cous_2018}/Central & Eastern US"
model_hi_2020 = "${repo_hi_2020}"
model_ak_2007 = "${repo_ak_2007}"

/* Production models */
prod_models = [
[ model_ak_2007, 'models/ak/2007' ],
[ model_ceus_2008, 'models/ceus/2008' ],
[ model_wus_2008, 'models/wus/2008' ],
[ model_ceus_2014, 'models/ceus/2014' ],
[ model_wus_2014, 'models/wus/2014' ],
[ model_wus_2014b, 'models/wus/2014b' ]
]

/* Development models */
dev_models = [
[ model_ceus_2018, 'models/ceus/2018' ],
[ model_wus_2018, 'models/wus/2018' ],
[ model_hi_2020, 'models/hi/2020' ]
]

getGitTag = { gitDir ->
def cmd = 'git --git-dir=' + gitDir + '/.git describe --tags'
return cmd.execute().text.replace('\n', '') ?: 'unknown'
}

/*
* The git-dir option gets the correct tag when
* build is called from nshmp-haz-ws.
Expand Down Expand Up @@ -90,7 +142,6 @@ jacocoTestReport {
}
check.dependsOn jacocoTestReport


javadoc {
options.setUse(true)
options.author(true)
Expand All @@ -107,6 +158,8 @@ javadoc {
'https://google.github.io/guava/releases/23.0/api/docs/',
'https://google.github.io/gson/apidocs/')
include 'gov/usgs/earthquake/nshmp/**'
exclude 'gov/usgs/earthquake/nshmp/www/**'
exclude 'gov/usgs/earthquake/nshmp/aws/**'
exclude 'gov/usgs/earthquake/nshmp/etc/**'
exclude 'gov/usgs/earthquake/nshmp/internal/**'
exclude '**/Scratch*'
Expand Down Expand Up @@ -134,7 +187,6 @@ javadoc {
*/
jar {
doFirst {

/* possible fat jar */
if (rootProject.name == projectName && !thinJar) {
from { configurations.compile.collect {
Expand Down Expand Up @@ -169,4 +221,98 @@ task thinJar(type: Jar) {
}
with jar
}


/**
* Create war file with production models
*/
war {
enabled = true
webAppDirName = 'webapp'

/*
* Exclude existing models directory with symlinks
* to support Eclipse deployments.
*/
exclude 'models'

prod_models.each{model ->
from(model[0]) { into model[1] }
}

doFirst {
/* Record service and model versions */
writeProperties()
}
}

/**
* Create a war file with development models
*/
task assembleDev(type: War, dependsOn: 'war') {
prod_models.each{model ->
from(model[0]) { into model[1] }
}

dev_models.each{model ->
from(model[0]) { into model[1] }
}
}

/**
* Create am exploded war file with production models
*/
task assembleUsgs(type: Sync) {
into "${libsDir}/exploded-war"
with war

doFirst {
/* Record service and model versions */
writeProperties()
}
}

/**
* Create am exploded war file with development models
*/
task assembleUsgsDev(type: Sync) {
into "${libsDir}/exploded-war"
with assembleDev

doFirst {
/* Record service and model versions */
writeProperties()
}
}

/**
* Create a zip file of all dependencies
*/
task dependencies(type: Zip) {
baseName = "nshmp-haz-ws-dependencies"
from {
configurations.compile.collect {
it
}
}

into("java/lib")

destinationDir libsDir
}

/**
* Create properties file
*/
def writeProperties() {
def props = new Properties()
def propsFile = new File(project.buildDir.toString() + propsPath)
propsFile.createNewFile()
props.setProperty('app.version', getGitTag('.'))
props.setProperty('E2007.version', getGitTag(repo_ak_2007))
props.setProperty('E2008.version', getGitTag(repo_cous_2008))
props.setProperty('E2014.version', getGitTag(repo_cous_2014))
props.setProperty('E2014B.version', getGitTag(repo_cous_2014b))
props.setProperty('E2018.version', getGitTag(repo_cous_2018))
props.setProperty('E2020.version', getGitTag(repo_hi_2020))
props.store(propsFile.newWriter(), null)
}
Loading

0 comments on commit fe41e87

Please sign in to comment.