From 645b1949d6b8d274fe604c390208920d198ae15c Mon Sep 17 00:00:00 2001
From: Brandon Clayton <bclayton@usgs.gov>
Date: Thu, 14 Sep 2023 13:09:26 -0600
Subject: [PATCH] switch to git clone

---
 gradle/nshm.gradle | 26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)

diff --git a/gradle/nshm.gradle b/gradle/nshm.gradle
index ea8f4b10..a8ca1f44 100644
--- a/gradle/nshm.gradle
+++ b/gradle/nshm.gradle
@@ -1,4 +1,4 @@
-apply plugin: "de.undercouch.download"
+apply plugin: "org.ajoberstar.grgit"
 
 buildscript {
   repositories {
@@ -16,32 +16,22 @@ ext {
   envMemory = System.getenv("CI_RUNNER_MEMORY")
   xmx = envMemory ? envMemory : "16g"
 
-  // Download and unzip NSHM
+  // Clone repo
   downloadNshm = {nshm ->
     def repo = nshm.repo
     def tag = nshm.tag
     def year = nshm.year
-
-    def zipName = "${repo}-${tag}.zip";
-    def zipFile = new File(nshmDir, zipName)
-    def nshmFile = file("${nshmDir}/${repo}-${year}")
+    def uri = "https://code.usgs.gov/ghsc/nshmp/nshms/${repo}.git"
+    def nshmFile = new File("${projectDir}/${nshmDir}/${repo}-${year}")
 
     if (nshmFile.exists()) {
       delete nshmFile
     }
 
-    download.run {
-      src "https://code.usgs.gov/ghsc/nshmp/nshms/${repo}/-/archive/${tag}/${zipName}"
-      dest zipFile
-    }
-    copy {
-      from zipTree(zipFile)
-      into nshmDir
-    }
-    file("${nshmDir}/${repo}-${tag}").renameTo(nshmFile)
-    delete {
-      delete zipFile
-    }
+    grgit.clone(
+        dir: nshmFile,
+        uri: uri,
+        refToCheckout: tag)
   }
 
   // Returns a NSHM from nshms.yml array
-- 
GitLab