Newer
Older
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "org.yaml:snakeyaml:1.33"
}
}
import org.yaml.snakeyaml.Yaml
ext {
nshmDir = "nshms";
downloadNshm = {nshm ->
def repo = nshm.repo
def uri = "https://code.usgs.gov/ghsc/nshmp/nshms/${repo}.git"
def nshmFile = new File("${projectDir}/${nshmDir}/${repo}-${year}")
if (nshmFile.exists()) {
delete nshmFile
}
grgit.clone(
dir: nshmFile,
uri: uri,
refToCheckout: tag)
// Returns a NSHM from nshms.yml array
findNshm = {repo, year ->
def yaml = new Yaml()
def nshmConfig = new Yaml().load(new File("${projectDir}/nshms.yml").newInputStream())
def nshm = nshmConfig.nshms.find{nshm -> nshm.repo == repo && nshm.year == year}
if (nshm == null) {
throw new Exception("NSHM ${repo} ${year} not found.")
}
return nshm
}
task cleanNshm(type: Delete) {
delete nshmDir
// Download all NSHMs
task nshms() {
dependsOn cleanNshm
def yaml = new Yaml()
def nshmConfig = new Yaml().load(new File("${projectDir}/nshms.yml").newInputStream())
doLast {
for (nshm in nshmConfig.nshms) {
// Download NSHM
downloadNshm(nshm)
}
}
}
task cleanGenerated(type: Delete) {
delete "src/test/resources/e2e/actual"
}
// Generate Alaska 2007 for CI
task generateAlaska2007(type: JavaExec) {
description = "Generate alaska-2007 acutal for CI/CD"
classpath = sourceSets.test.runtimeClasspath
doFirst {
downloadNshm(findNshm("nshm-alaska", 2007))
}
main = "gov.usgs.earthquake.nshmp.model.GenerateActual"
}
// Generate Alaska 2023 for CI
task generateAlaska2023(type: JavaExec) {
description = "Generate alaska-2023 acutal for CI/CD"
classpath = sourceSets.test.runtimeClasspath
doFirst {
downloadNshm(findNshm("nshm-alaska", 2023))
}
main = "gov.usgs.earthquake.nshmp.model.GenerateActual"
}
// Generate CONUS 2018 for CI
task generateConus2018(type: JavaExec) {
description = "Generate conus-2018 acutal for CI/CD"
classpath = sourceSets.test.runtimeClasspath
doFirst {
downloadNshm(findNshm("nshm-conus", 2018))
}
main = "gov.usgs.earthquake.nshmp.model.GenerateActual"
}
// Generate CONUS 2023 for CI
task generateConus2023(type: JavaExec) {
description = "Generate conus-2023 acutal for CI/CD"
classpath = sourceSets.test.runtimeClasspath
doFirst {
downloadNshm(findNshm("nshm-conus", 2023))
}
main = "gov.usgs.earthquake.nshmp.model.GenerateActual"
}
// Generate Hawaii 2021 for CI
task generateHawaii2021(type: JavaExec) {
description = "Generate hawaii-2021 acutal for CI/CD"
classpath = sourceSets.test.runtimeClasspath
doFirst {
downloadNshm(findNshm("nshm-hawaii", 2021))
}
main = "gov.usgs.earthquake.nshmp.model.GenerateActual"
}
// Generate PRVI 2025 for CI
task generatePrvi2025(type: JavaExec) {
description = "Generate prvi-2025 acutal for CI/CD"
classpath = sourceSets.test.runtimeClasspath
doFirst {
downloadNshm(findNshm("nshm-prvi", 2025))
}
jvmArgs("-DNSHM=nshm-prvi-2025")
main = "gov.usgs.earthquake.nshmp.model.GenerateActual"
}
*/
// Test Alaska 2007 NSHM
task testAlaska2007(type: Test) {
description = "Test Alaska 2007 NSHM"
group = "verification"
doFirst {
downloadNshm(findNshm("nshm-alaska", 2007))
}
testLogging {
exceptionFormat "full"
}
)
filter {
includeTestsMatching "gov.usgs.earthquake.nshmp.model.NshmTests.testAlaska2007"
}
}
// Test Alaska 2023 NSHM
task testAlaska2023(type: Test) {
description = "Test Alaska 2023 NSHM"
group = "verification"
downloadNshm(findNshm("nshm-alaska", 2023))
testLogging {
exceptionFormat "full"
}
)
filter {
includeTestsMatching "gov.usgs.earthquake.nshmp.model.NshmTests.testAlaska2023"
}
}
// Test CONUS 2018 NSHM
task testConus2018(type: Test) {
description = "Test CONUS 2018 NSHM"
group = "verification"
downloadNshm(findNshm("nshm-conus", 2018))
testLogging {
exceptionFormat "full"
}
includeTestsMatching "gov.usgs.earthquake.nshmp.model.NshmTests.testConus2018"
}
}
// Test CONUS 2023 NSHM
task testConus2023(type: Test) {
description = "Test CONUS 2023 NSHM"
group = "verification"
downloadNshm(findNshm("nshm-conus", 2023))
testLogging {
exceptionFormat "full"
}
)
filter {
includeTestsMatching "gov.usgs.earthquake.nshmp.model.NshmTests.testConus2023"
}
}
// Test Hawaii 2021 NSHM
task testHawaii2021(type: Test) {
description = "Test Hawaii 2021 NSHM"
group = "verification"
downloadNshm(findNshm("nshm-hawaii", 2021))
testLogging {
exceptionFormat "full"
}
)
filter {
includeTestsMatching "gov.usgs.earthquake.nshmp.model.NshmTests.testHawaii2021"
}
}
// Test PRVI 2025 NSHM
/*
task testPrvi2025(type: Test) {
description = "Test PRVI 2025 NSHM"
group = "verification"
doFirst {
downloadNshm(findNshm("nshm-prvi", 2025))
}
testLogging {
exceptionFormat "full"
}
systemProperties(System.getProperties())
useJUnitPlatform()
jvmArgs(
"-Xms2g",
"-Xmx${xmx}",
)
filter {
includeTestsMatching "gov.usgs.earthquake.nshmp.model.NshmTests.testPrvi2025"
}
}
*/