From a37f38a412bfe4472a9d295069fae863d34afd9f Mon Sep 17 00:00:00 2001 From: shadowislord Date: Fri, 20 Mar 2015 23:51:15 -0400 Subject: [PATCH] Build: fix build failure if not building from git repo --- jme3-core/build.gradle | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/jme3-core/build.gradle b/jme3-core/build.gradle index 78bc24dd1..bd699f52a 100644 --- a/jme3-core/build.gradle +++ b/jme3-core/build.gradle @@ -26,14 +26,29 @@ import org.ajoberstar.grgit.* task updateVersion << { - def grgit = Grgit.open(project.file('.').parent) + def verfile = file('src/main/java/com/jme3/system/JmeVersion.java') + def jmeGitHash + def jmeShortGitHash + def jmeBuildDate + def jmeBranchName - def jmeGitHash = grgit.head().id - def jmeShortGitHash = grgit.head().abbreviatedId - def jmeBuildDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()) - def jmeBranchName = grgit.branch.current.name + try { + def grgit = Grgit.open(project.file('.').parent) + jmeGitHash = grgit.head().id + jmeShortGitHash = grgit.head().abbreviatedId + jmeBuildDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + jmeBranchName = grgit.branch.current.name + } catch (ex) { + // Failed to get repo info + logger.warn("Failed to get repository info: " + ex.message + ". " + \ + "Only partial build info will be generated.") + + jmeGitHash = "" + jmeShortGitHash = "" + jmeBuildDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + jmeBranchName = "unknown" + } - def verfile = file('src/main/java/com/jme3/system/JmeVersion.java') verfile.text = "\npackage com.jme3.system;\n\n" + "/**\n * THIS IS AN AUTO-GENERATED FILE..\n * DO NOT MODIFY!\n */\n" + "public class JmeVersion {\n" +