From a04f1d70f351a0dd2ecc4a164714e4e31ff01f13 Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Mon, 5 Dec 2022 17:11:37 -0700 Subject: [PATCH] create method to download a nshm --- gradle/nshm.gradle | 46 ++++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/gradle/nshm.gradle b/gradle/nshm.gradle index 939658a4..9f31e6cc 100644 --- a/gradle/nshm.gradle +++ b/gradle/nshm.gradle @@ -1,43 +1,37 @@ apply plugin: "de.undercouch.download" ext { - conusArchiveUrl = "https://code.usgs.gov/ghsc/nshmp/nshms/nshm-conus/-/archive" - hawaiiArchiveUrl = "https://code.usgs.gov/ghsc/nshmp/nshms/nshm-hawaii/-/archive" nshmDir = "nshms"; -} -/** - * Download the default NSHM to use for the web services. - */ -task downloadNshms() { - doLast { - // Download and unzip nshm-conus tag 5.2.0 - def conus2018 = new File(nshmDir, "nshm-conus-5.2.0.zip") + // Download and unzip NSHM + downloadNshm = {repo, tag -> + def zipName = "${repo}-${tag}.zip"; + def zipFile = new File(nshmDir, zipName) + download.run { - src "${conusArchiveUrl}/5.2.0/nshm-conus-5.2.0.zip" - dest conus2018 + src "https://code.usgs.gov/ghsc/nshmp/nshms/${repo}/-/archive/${tag}/${zipName}" + dest zipFile } copy { - from zipTree(conus2018) + from zipTree(zipFile) into nshmDir } delete { - delete conus2018 + delete zipFile } + } +} + +/** + * Download the NSHMs + */ +task downloadNshms() { + doLast { + // Download and unzip nshm-conus tag 5.2.0 + downloadNshm("nshm-conus", "5.2.0") // Download and unzip nshm-hawaii tag 2.0.2 - def hawaii2021 = new File(nshmDir, "nshm-hawaii-2.0.2.zip") - download.run { - src "${hawaiiArchiveUrl}/2.0.2/nshm-hawaii-2.0.2.zip" - dest hawaii2021 - } - copy { - from zipTree(hawaii2021) - into nshmDir - } - delete { - delete hawaii2021 - } + downloadNshm("nshm-hawaii", "2.0.2") } } -- GitLab