Skip to content
Snippets Groups Projects
Commit ce0a9ab6 authored by Clayton, Brandon Scott's avatar Clayton, Brandon Scott
Browse files

add function and task

parent 9a0fc467
No related branches found
No related tags found
2 merge requests!690Production Release | nshmp-haz,!689Resolves: NSHM Gradle Download
...@@ -15,16 +15,11 @@ ext { ...@@ -15,16 +15,11 @@ ext {
nshmDir = "nshms"; nshmDir = "nshms";
// Download and unzip NSHM // Download and unzip NSHM
downloadNshm = {repo, year -> downloadNshm = {nshm ->
def yaml = new Yaml() def repo = nshm.repo
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.")
}
def tag = nshm.tag def tag = nshm.tag
def year = nshm.year
def zipName = "${repo}-${tag}.zip"; def zipName = "${repo}-${tag}.zip";
def zipFile = new File(nshmDir, zipName) def zipFile = new File(nshmDir, zipName)
def nshmFile = file("${nshmDir}/${repo}-${year}") def nshmFile = file("${nshmDir}/${repo}-${year}")
...@@ -46,6 +41,20 @@ ext { ...@@ -46,6 +41,20 @@ ext {
delete zipFile delete zipFile
} }
} }
// 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) { task cleanNshm(type: Delete) {
...@@ -53,13 +62,27 @@ task cleanNshm(type: Delete) { ...@@ -53,13 +62,27 @@ task cleanNshm(type: Delete) {
} }
clean.dependsOn cleanNshm clean.dependsOn cleanNshm
// 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)
}
}
}
// Test Alaska 2023 NSHM // Test Alaska 2023 NSHM
task testAlaska2023(type: Test) { task testAlaska2023(type: Test) {
description = "Test Alaska 2023 NSHM" description = "Test Alaska 2023 NSHM"
group = "verification" group = "verification"
doFirst { doFirst {
downloadNshm("nshm-alaska", 2023) downloadNshm(findNshm("nshm-alaska", 2023))
} }
testLogging { testLogging {
...@@ -83,7 +106,7 @@ task testConus2018(type: Test) { ...@@ -83,7 +106,7 @@ task testConus2018(type: Test) {
group = "verification" group = "verification"
doFirst { doFirst {
downloadNshm("nshm-conus", 2018) downloadNshm(findNshm("nshm-conus", 2018))
} }
testLogging { testLogging {
...@@ -107,7 +130,7 @@ task testConus2023(type: Test) { ...@@ -107,7 +130,7 @@ task testConus2023(type: Test) {
group = "verification" group = "verification"
doFirst { doFirst {
downloadNshm("nshm-conus", 2023) downloadNshm(findNshm("nshm-conus", 2023))
} }
testLogging { testLogging {
...@@ -131,7 +154,7 @@ task testHawaii2021(type: Test) { ...@@ -131,7 +154,7 @@ task testHawaii2021(type: Test) {
group = "verification" group = "verification"
doFirst { doFirst {
downloadNshm("nshm-hawaii", 2021) downloadNshm(findNshm("nshm-hawaii", 2021))
} }
testLogging { testLogging {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment