The Grails app-info-hibernate plugin
Wednesday, November 28th, 2012The original app-info plugin had support for displaying lots of information about your Grails application, and several pages for Hibernate information and graphs. The Hibernate features ended up being about half of the plugin, so originally I wanted to split out the Hibernate features into a separate plugin. This didn’t work because I wasn’t able to get the GSPs rendered; at the time it wasn’t possible to use a
plugin
attribute for the render
method to tell Grails where to find the controller mixin’s GSPs.
When Grails 2.0 was released my hand was forced though, since there wasn’t a version of the Hibernate Tools library that I use to generate table and entity graphs which worked with the updated version of Hibernate that Grails now uses. I was able to create a mostly-working version of the db-reverse-engineer plugin which also uses Hibernate Tools by forking the Gant script in its own JVM and using a different Hibernate jar, but that wasn’t possible in the app-info plugin because the functionality is part of the runtime, not just a script. So I removed the Hibernate features with plans to create an app-info-hibernate plugin once there was a compatible Hibernate Tools jar; I wrote about this here
.
Fortunately there is finally a “CR1” version of the Hibernate Tools library in Maven Central, and in my testing I discovered that the plugin
attribute does work in the Grails 2.0 render method, so I finished up the work for the plugin and released it today. I also released an update of the db-reverse-engineer plugin which uses the updated library and no longer needs the hackish workaround of forking a new process; install version 0.5 by adding compile ':db-reverse-engineer:0.5'
to your BuildConfig.groovy.
Using the plugin is very similar to what I described in the original blog post. Add the plugin to BuildConfig.groovy:
plugins { ... compile ':app-info-hibernate:0.2' }
(that there’s no need to add the app-info plugin since it will be transitively installed) and configure the grails.plugins.dynamicController.mixins
map in Config.groovy:
grails.plugins.dynamicController.mixins = [ 'com.burtbeckwith.grails.plugins.appinfo.IndexControllerMixin': 'com.burtbeckwith.appinfo_test.AdminManageController', 'com.burtbeckwith.grails.plugins.appinfo.Log4jControllerMixin' : 'com.burtbeckwith.appinfo_test.AdminManageController', 'com.burtbeckwith.grails.plugins.appinfo.SpringControllerMixin' : 'com.burtbeckwith.appinfo_test.AdminManageController', 'com.burtbeckwith.grails.plugins.appinfo.MemoryControllerMixin' : 'com.burtbeckwith.appinfo_test.AdminManageController', 'com.burtbeckwith.grails.plugins.appinfo.PropertiesControllerMixin' : 'com.burtbeckwith.appinfo_test.AdminManageController', 'com.burtbeckwith.grails.plugins.appinfo.ScopesControllerMixin' : 'com.burtbeckwith.appinfo_test.AdminManageController', 'com.burtbeckwith.grails.plugins.appinfo.ThreadsControllerMixin' : 'com.burtbeckwith.appinfo_test.AdminManageController', 'com.burtbeckwith.grails.plugins.appinfo.hibernate.HibernateControllerMixin' : 'com.burtbeckwith.appinfo_test.AdminManageController', 'app.info.custom.example.MyConfigControllerMixin' : 'com.burtbeckwith.appinfo_test.AdminManageController' ]
One thing to be aware of is that the HibernateControllerMixin
package has changed; it’s now in the com.burtbeckwith.grails.plugins.appinfo.hibernate
package.
Note that due to some issues in the updated grails.org site, the app-info
plugin page isn’t editable, so it’s out of date, and there’s no plugin page yet for the app-info-hibernate plugin. It will be at http://grails.org/plugin/app-info-hibernate
when the issues are resolved. You can install the plugin, it’s just not viewable in the plugin portal.
You can download a sample application that uses the plugin here.