Permalink
Browse files

initial version of plugin

  • Loading branch information...
0 parents commit 44685b04889dcd7b0166e54885c4798dc07b2c8d @fterrier committed Mar 24, 2012
Showing with 6,438 additions and 0 deletions.
  1. +17 −0 .classpath
  2. +4 −0 .gitignore
  3. +19 −0 .project
  4. +42 −0 BuildInfoTagGrailsPlugin.groovy
  5. 0 README
  6. +5 −0 application.properties
  7. +37 −0 grails-app/conf/BuildConfig.groovy
  8. +24 −0 grails-app/conf/Config.groovy
  9. +44 −0 grails-app/taglib/org/chai/buildinfo/BuildInfoTagLib.groovy
  10. +11 −0 grails-app/views/error.gsp
  11. +9 −0 grails-app/views/templates/_buildInfo.gsp
  12. +28 −0 plugin.xml
  13. +27 −0 scripts/_Events.groovy
  14. +14 −0 test/projects/test-build-info/.classpath
  15. +19 −0 test/projects/test-build-info/.project
  16. +6 −0 test/projects/test-build-info/application.properties
  17. +5 −0 test/projects/test-build-info/grails-app/conf/ApplicationResources.groovy
  18. +7 −0 test/projects/test-build-info/grails-app/conf/BootStrap.groovy
  19. +48 −0 test/projects/test-build-info/grails-app/conf/BuildConfig.groovy
  20. +93 −0 test/projects/test-build-info/grails-app/conf/Config.groovy
  21. +43 −0 test/projects/test-build-info/grails-app/conf/DataSource.groovy
  22. +13 −0 test/projects/test-build-info/grails-app/conf/UrlMappings.groovy
  23. +3 −0 test/projects/test-build-info/grails-app/conf/spring/resources.groovy
  24. +55 −0 test/projects/test-build-info/grails-app/i18n/messages.properties
  25. +55 −0 test/projects/test-build-info/grails-app/i18n/messages_cs_CZ.properties
  26. +56 −0 test/projects/test-build-info/grails-app/i18n/messages_da.properties
  27. +55 −0 test/projects/test-build-info/grails-app/i18n/messages_de.properties
  28. +55 −0 test/projects/test-build-info/grails-app/i18n/messages_es.properties
  29. +19 −0 test/projects/test-build-info/grails-app/i18n/messages_fr.properties
  30. +19 −0 test/projects/test-build-info/grails-app/i18n/messages_it.properties
  31. +55 −0 test/projects/test-build-info/grails-app/i18n/messages_ja.properties
  32. +55 −0 test/projects/test-build-info/grails-app/i18n/messages_nl.properties
  33. +59 −0 test/projects/test-build-info/grails-app/i18n/messages_pt_BR.properties
  34. +34 −0 test/projects/test-build-info/grails-app/i18n/messages_pt_PT.properties
  35. +31 −0 test/projects/test-build-info/grails-app/i18n/messages_ru.properties
  36. +55 −0 test/projects/test-build-info/grails-app/i18n/messages_sv.properties
  37. +55 −0 test/projects/test-build-info/grails-app/i18n/messages_th.properties
  38. +18 −0 test/projects/test-build-info/grails-app/i18n/messages_zh_CN.properties
  39. +11 −0 test/projects/test-build-info/grails-app/views/error.gsp
  40. +116 −0 test/projects/test-build-info/grails-app/views/index.gsp
  41. +30 −0 test/projects/test-build-info/grails-app/views/layouts/main.gsp
  42. +33 −0 test/projects/test-build-info/web-app/WEB-INF/applicationContext.xml
  43. +14 −0 test/projects/test-build-info/web-app/WEB-INF/sitemesh.xml
  44. +572 −0 test/projects/test-build-info/web-app/WEB-INF/tld/c.tld
  45. +671 −0 test/projects/test-build-info/web-app/WEB-INF/tld/fmt.tld
  46. +550 −0 test/projects/test-build-info/web-app/WEB-INF/tld/grails.tld
  47. +311 −0 test/projects/test-build-info/web-app/WEB-INF/tld/spring.tld
  48. +109 −0 test/projects/test-build-info/web-app/css/errors.css
  49. +585 −0 test/projects/test-build-info/web-app/css/main.css
  50. +82 −0 test/projects/test-build-info/web-app/css/mobile.css
  51. BIN test/projects/test-build-info/web-app/images/apple-touch-icon-retina.png
  52. BIN test/projects/test-build-info/web-app/images/apple-touch-icon.png
  53. BIN test/projects/test-build-info/web-app/images/favicon.ico
  54. BIN test/projects/test-build-info/web-app/images/grails_logo.jpg
  55. BIN test/projects/test-build-info/web-app/images/grails_logo.png
  56. BIN test/projects/test-build-info/web-app/images/leftnav_btm.png
  57. BIN test/projects/test-build-info/web-app/images/leftnav_midstretch.png
  58. BIN test/projects/test-build-info/web-app/images/leftnav_top.png
  59. BIN test/projects/test-build-info/web-app/images/skin/database_add.png
  60. BIN test/projects/test-build-info/web-app/images/skin/database_delete.png
  61. BIN test/projects/test-build-info/web-app/images/skin/database_edit.png
  62. BIN test/projects/test-build-info/web-app/images/skin/database_save.png
  63. BIN test/projects/test-build-info/web-app/images/skin/database_table.png
  64. BIN test/projects/test-build-info/web-app/images/skin/exclamation.png
  65. BIN test/projects/test-build-info/web-app/images/skin/house.png
  66. BIN test/projects/test-build-info/web-app/images/skin/information.png
  67. BIN test/projects/test-build-info/web-app/images/skin/shadow.jpg
  68. BIN test/projects/test-build-info/web-app/images/skin/sorted_asc.gif
  69. BIN test/projects/test-build-info/web-app/images/skin/sorted_desc.gif
  70. BIN test/projects/test-build-info/web-app/images/spinner.gif
  71. BIN test/projects/test-build-info/web-app/images/springsource.png
  72. +9 −0 test/projects/test-build-info/web-app/js/application.js
  73. +33 −0 web-app/WEB-INF/applicationContext.xml
  74. +14 −0 web-app/WEB-INF/sitemesh.xml
  75. +572 −0 web-app/WEB-INF/tld/c.tld
  76. +671 −0 web-app/WEB-INF/tld/fmt.tld
  77. +550 −0 web-app/WEB-INF/tld/grails.tld
  78. +311 −0 web-app/WEB-INF/tld/spring.tld
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="src" path="src/groovy"/>
+ <classpathentry kind="src" path="grails-app/conf"/>
+ <classpathentry kind="src" path="grails-app/controllers"/>
+ <classpathentry kind="src" path="grails-app/domain"/>
+ <classpathentry kind="src" path="grails-app/services"/>
+ <classpathentry kind="src" path="grails-app/taglib"/>
+ <classpathentry kind="src" path="test/integration"/>
+ <classpathentry kind="src" path="test/unit"/>
+ <classpathentry kind="src" path="test/projects"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="com.springsource.sts.grails.core.CLASSPATH_CONTAINER"/>
+ <classpathentry exported="true" kind="con" path="GROOVY_DSL_SUPPORT"/>
+ <classpathentry kind="output" path="web-app/WEB-INF/classes"/>
+</classpath>
@@ -0,0 +1,4 @@
+.settings/
+*.class
+target
+*.log
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>build-info-tag</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.springsource.sts.grails.core.nature</nature>
+ <nature>org.eclipse.jdt.groovy.core.groovyNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,42 @@
+class BuildInfoTagGrailsPlugin {
+ // the plugin version
+ def version = "0.1"
+ // the version or versions of Grails the plugin is designed for
+ def grailsVersion = "2.0 > *"
+ // the other plugins this plugin depends on
+ def dependsOn = [:]
+ // resources that are excluded from plugin packaging
+ def pluginExcludes = [
+ "grails-app/views/error.gsp"
+ ]
+
+ def title = "Build Info Tag Plugin" // Headline display name of the plugin
+ def author = "François Terrier"
+ def authorEmail = "fterrier@gmail.com"
+ def description = '''\
+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).
+'''
+
+ // URL to the plugin's documentation
+ def documentation = "http://grails.org/plugin/build-info-tag"
+
+ // Extra (optional) plugin metadata
+
+ // License: one of 'APACHE', 'GPL2', 'GPL3'
+ def license = "APACHE"
+
+ // Details of company behind the plugin (if there is one)
+ def organization = [ name: "CHAI", url: "http://www.clintonhealthaccess.org/" ]
+
+ // Any additional developers beyond the author specified above.
+// def developers = [ [ name: "Joe Bloggs", email: "joe@bloggs.net" ]]
+
+ // Location of the plugin's issue tracker.
+// def issueManagement = [ system: "JIRA", url: "http://jira.grails.org/browse/GPMYPLUGIN" ]
+
+ // Online location of the plugin's browseable source code.
+ def scm = [ url: "http://github.com/fterrier/grails-build-info-tag" ]
+
+}
No changes.
@@ -0,0 +1,5 @@
+#Grails Metadata file
+#Sat Mar 24 13:44:31 CAT 2012
+app.grails.version=2.0.0
+app.name=build-info-tag
+plugins.svn=1.0.1
@@ -0,0 +1,37 @@
+grails.project.class.dir = "target/classes"
+grails.project.test.class.dir = "target/test-classes"
+grails.project.test.reports.dir = "target/test-reports"
+grails.project.target.level = 1.6
+//grails.project.war.file = "target/${appName}-${appVersion}.war"
+
+grails.project.dependency.resolution = {
+ // inherit Grails' default dependencies
+ inherits("global") {
+ // uncomment to disable ehcache
+ // excludes 'ehcache'
+ }
+ log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
+ repositories {
+ grailsCentral()
+ // uncomment the below to enable remote dependency resolution
+ // from public Maven repositories
+ //mavenCentral()
+ //mavenLocal()
+ //mavenRepo "http://snapshots.repository.codehaus.org"
+ //mavenRepo "http://repository.codehaus.org"
+ //mavenRepo "http://download.java.net/maven/2/"
+ //mavenRepo "http://repository.jboss.com/maven2/"
+ }
+ dependencies {
+ // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
+
+ // runtime 'mysql:mysql-connector-java:5.1.5'
+ }
+
+ plugins {
+ build(":tomcat:$grailsVersion",
+ ":release:1.0.0") {
+ export = false
+ }
+ }
+}
@@ -0,0 +1,24 @@
+// configuration for plugin testing - will not be included in the plugin zip
+
+log4j = {
+ // Example of changing the log pattern for the default console
+ // appender:
+ //
+ //appenders {
+ // console name:'stdout', layout:pattern(conversionPattern: '%c{2} %m%n')
+ //}
+
+ error 'org.codehaus.groovy.grails.web.servlet', // controllers
+ 'org.codehaus.groovy.grails.web.pages', // GSP
+ 'org.codehaus.groovy.grails.web.sitemesh', // layouts
+ 'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
+ 'org.codehaus.groovy.grails.web.mapping', // URL mapping
+ 'org.codehaus.groovy.grails.commons', // core / classloading
+ 'org.codehaus.groovy.grails.plugins', // plugins
+ 'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
+ 'org.springframework',
+ 'org.hibernate',
+ 'net.sf.ehcache.hibernate'
+
+ warn 'org.mortbay.log'
+}
@@ -0,0 +1,44 @@
+package org.chai.buildinfo
+
+import grails.util.GrailsUtil;
+import grails.util.Metadata;
+
+class BuildInfoTagLib {
+
+ static namespace = "build"
+
+ def grailsApplication
+
+ def buildInstance
+ def buildInitialized = false
+
+ def getBuild() {
+ if (!buildInitialized) {
+ def resource = grailsApplication.parentContext.getResource("classpath:build.info")
+ if (resource.exists()) buildInstance = Metadata.getInstance(resource.inputStream)
+ else buildInstance = null
+ buildInitialized = true
+ }
+ return buildInstance
+ }
+
+ def buildInfo = {attrs, body ->
+ if (GrailsUtil.environment == 'production') {
+ if (build == null) {
+ out << "no build info found"
+ }
+ else {
+ out << render(plugin:'buildInfoTag', template:'/templates/buildInfo', model:[
+ buildDate: build.'app.buildDate',
+ gitCommit: build.'app.gitCommit',
+ systemName: build.'app.systemName',
+ timezone: build.'app.timezone'
+ ])
+ }
+ }
+ else {
+ out << "no build info in ${GrailsUtil.environment} environment"
+ }
+ }
+
+}
@@ -0,0 +1,11 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Grails Runtime Exception</title>
+ <meta name="layout" content="main">
+ <link rel="stylesheet" href="${resource(dir: 'css', file: 'errors.css')}" type="text/css">
+ </head>
+ <body>
+ <g:renderException exception="${exception}" />
+ </body>
+</html>
@@ -0,0 +1,9 @@
+${grailsApplication.metadata['app.name']}
+${grailsApplication.metadata['app.version']}
+
+Build ${buildDate}
+Git ${gitCommit}
+
+<!-- System ${systemName} -->
+<!-- Timezone ${timezone} -->
+
@@ -0,0 +1,28 @@
+<plugin name='build-info-tag' version='0.1' grailsVersion='2.0.0 &gt; *'>
+ <author>François Terrier</author>
+ <authorEmail>fterrier@gmail.com</authorEmail>
+ <title>Build Info Tag Plugin</title>
+ <description>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).
+</description>
+ <documentation>http://grails.org/plugin/build-info-tag</documentation>
+ <type>BuildInfoTagGrailsPlugin</type>
+ <resources>
+ <resource>org.chai.buildinfo.BuildInfoTagLib</resource>
+ </resources>
+ <repositories />
+ <dependencies />
+ <plugins>
+ <runtime>
+ <plugin group='org.grails.plugins' name='resources' version='1.1.5' />
+ <plugin group='org.grails.plugins' name='hibernate' version='2.0.0' />
+ <plugin group='org.grails.plugins' name='jquery' version='1.7.1' />
+ </runtime>
+ <build>
+ <plugin group='org.grails.plugins' name='tomcat' version='2.0.0' />
+ </build>
+ </plugins>
+ <runtimePluginRequirements />
+ <behavior />
+</plugin>
@@ -0,0 +1,27 @@
+import grails.util.Metadata;
+
+import java.text.SimpleDateFormat;
+
+eventCreateWarStart = { warName, stagingDir ->
+
+ def formatter = new SimpleDateFormat("ddMMyyyy-HHmmss")
+ def buildDate = formatter.format(new Date(System.currentTimeMillis()))
+ buildDate += '-'+Calendar.getInstance().getTimeZone().getDisplayName(false, TimeZone.SHORT)
+
+ def gitCommit = ''
+ try {
+ // TODO make it platform independant
+ def proc = "git rev-parse HEAD".execute()
+ gitCommit = proc.text
+ } catch (Exception e) {}
+
+ Metadata build = Metadata.getInstance(new File("${stagingDir}/WEB-INF/classes/build.info"));
+ build.'app.buildDate' = buildDate
+ build.'app.gitCommit' = gitCommit
+ build.'app.systemName' = InetAddress.getLocalHost().getHostName()
+ build.'app.timezone' = Calendar.getInstance().getTimeZone().getID()
+ build.persist()
+
+ println "Compile Starting on build #${buildDate}, git commit: ${gitCommit}"
+
+}
@@ -0,0 +1,14 @@
+<classpath>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="src" path="src/groovy"/>
+ <classpathentry kind="src" path="grails-app/conf"/>
+ <classpathentry kind="src" path="grails-app/controllers"/>
+ <classpathentry kind="src" path="grails-app/domain"/>
+ <classpathentry kind="src" path="grails-app/services"/>
+ <classpathentry kind="src" path="grails-app/taglib"/>
+ <classpathentry kind="src" path="test/integration"/>
+ <classpathentry kind="src" path="test/unit"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="com.springsource.sts.grails.core.CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="web-app/WEB-INF/classes"/>
+</classpath>
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>test-build-info</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.springsource.sts.grails.core.nature</nature>
+ <nature>org.eclipse.jdt.groovy.core.groovyNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,6 @@
+#Grails Metadata file
+#Sat Mar 24 15:37:03 CAT 2012
+app.grails.version=2.0.0
+app.name=test-build-info
+app.servlet.version=2.5
+app.version=0.1
@@ -0,0 +1,5 @@
+modules = {
+ application {
+ resource url:'js/application.js'
+ }
+}
@@ -0,0 +1,7 @@
+class BootStrap {
+
+ def init = { servletContext ->
+ }
+ def destroy = {
+ }
+}
@@ -0,0 +1,48 @@
+grails.servlet.version = "2.5" // Change depending on target container compliance (2.5 or 3.0)
+grails.project.class.dir = "target/classes"
+grails.project.test.class.dir = "target/test-classes"
+grails.project.test.reports.dir = "target/test-reports"
+grails.project.target.level = 1.6
+grails.project.source.level = 1.6
+//grails.project.war.file = "target/${appName}-${appVersion}.war"
+
+grails.plugin.location.'build-info-tag' = "../../.."
+
+grails.project.dependency.resolution = {
+ // inherit Grails' default dependencies
+ inherits("global") {
+ // uncomment to disable ehcache
+ // excludes 'ehcache'
+ }
+ log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
+ checksums true // Whether to verify checksums on resolve
+
+ repositories {
+ inherits true // Whether to inherit repository definitions from plugins
+ grailsPlugins()
+ grailsHome()
+ grailsCentral()
+ mavenCentral()
+
+ // uncomment these to enable remote dependency resolution from public Maven repositories
+ //mavenCentral()
+ //mavenLocal()
+ //mavenRepo "http://snapshots.repository.codehaus.org"
+ //mavenRepo "http://repository.codehaus.org"
+ //mavenRepo "http://download.java.net/maven/2/"
+ //mavenRepo "http://repository.jboss.com/maven2/"
+ }
+ dependencies {
+ // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
+
+ // runtime 'mysql:mysql-connector-java:5.1.16'
+ }
+
+ plugins {
+ runtime ":hibernate:$grailsVersion"
+ runtime ":jquery:1.7.1"
+ runtime ":resources:1.1.5"
+
+ build ":tomcat:$grailsVersion"
+ }
+}
Oops, something went wrong.

0 comments on commit 44685b0

Please sign in to comment.