diff --git a/gradle/app-version.gradle b/gradle/app-version.gradle
index f7e96ed1e21cc2211ce833d495462f485030fcaf..47452e9a3b0b56f3c0149efee2315161bbbcc2d5 100644
--- a/gradle/app-version.gradle
+++ b/gradle/app-version.gradle
@@ -1,8 +1,9 @@
-apply plugin: "com.palantir.git-version"
 
 tasks.withType(JavaCompile) {
   doFirst {
     try {
+      apply plugin: "com.palantir.git-version"
+
       def versionFile = new File("${projectDir}/src/main/resources/version/nshmp-haz-version.json")
       new File(versionFile.getParent()).mkdirs()
       def details = versionDetails()
@@ -23,6 +24,7 @@ tasks.withType(JavaCompile) {
       versionFile.write(groovy.json.JsonOutput.prettyPrint(json))
     } catch (Exception e) {
       println("Failed to create version file.")
+      throw new Exception(e)
     }
   }
 }