Permalink
Browse files

readme and cleanup

  • Loading branch information...
1 parent a5023a9 commit 6d72b7cb4caaa0df00096f33cde86707b1bda909 @enr enr committed Oct 17, 2012
Showing with 34 additions and 5 deletions.
  1. +19 −3 README.md
  2. +15 −2 scripts/_Events.groovy
View
@@ -1,6 +1,22 @@
-This Grails plugin puts a build.info file in the generated WAR file and provides a GSP tag to display
-the information in it. For now, the build number is the date and the plugin also
-collects the GIT commit number and displays it (won't work on Windows).
+Build Info Tag Plugin
+=====================
+
+This Grails plugin puts a build.info file in the classpath and provides a some GSP tags to display
+the information in it.
+
+For now, the build number is the date and the plugin also
+collects the GIT commit number and displays it (in Windows it manually parses the refs file).
## Installation
+Put in app BuildConfig:
+
+ grails.plugin.location.'build-info-tag' = "/path/to/this/plugin"
+
+## Tags
+
+* build:buildInfo : provides a list of all properties
+* build:buildDate: provides only the value of the buildDate property
+* build:gitCommit: provides only the value of the gitCommit property
+* build:systemName: provides only the value of the systemName property
+* build:timezone: provides only the value of the timezone property
View
@@ -15,10 +15,23 @@ def writeBuildInfoFile(path) {
def gitCommit = ''
try {
- // TODO make it platform independant
def proc = "git rev-parse HEAD".execute()
gitCommit = proc.text
- } catch (Exception e) {}
+ } catch (Exception e) {
+ // workaround for win
+ def headFile = new File(".git/HEAD")
+ def refsHeadPath = ''
+ if (headFile.exists()) {
+ def headContents = headFile.text.trim()
+ refsHeadPath = headContents.split(':')[1].trim()
+ def refsHeadFile = new File(".git/${refsHeadPath}")
+ if (refsHeadFile.isFile()) {
+ gitCommit = refsHeadFile.text.trim()
+ }
+ } else {
+ println "No Git files found... It seems this project is not using Git."
+ }
+ }
Metadata build = Metadata.getInstance(new File(path));
build.'app.buildDate' = buildDate

0 comments on commit 6d72b7c

Please sign in to comment.