lunes, mayo 19, 2014

Grails, reusing domains with a binary plugin

How should I do in order to reuse my domains?
Use your own domain's plugin, this is how.

Just create your plugin:

grails create-plugin book-remote
...{work as usual with your domains}...

Change your groupId/version and set binary as default type of packaging:


String groupId = ''
String version = '0.1'
String packaging = 'binary'

Install into local maven repo (or wherever you want to):

grails  maven install --binary

Then, you have include your plugin as a dependency for your grails app:

    dependencies {
    //Since it is  binary plugin is goes here instead of in the 'plugins' section
compile ''

That's it! :D
PD: There is no need for the plugin to be 'binary' unless you're planning to use those domains in another groovy (no grails) project (which was my case).

miércoles, mayo 14, 2014

Integrando Gorm en Griffon

Con los últimos anuncios de Graeme Rocher sobre la integración de Gorm en cualquier script Groovy:(ver

Lo que pedía el cuerpo era hacer un intento para incluir Gorm en un ejemplo sencillo de Griffon.
El código completo esta en el siguiente repo (, y las partes relevantes son:


    repositories {
        mavenRepo ""
        mavenRepo ""
        mavenRepo ""
        mavenRepo ""
        mavenRepo ""
        mavenRepo ""
    dependencies {
        runtime "org.grails:grails-datastore-gorm-hibernate4:3.0.0.RELEASE"
        runtime "org.grails:grails-spring:2.3.6"
        runtime "com.h2database:h2:1.3.164"
        compile "org.springframework:spring-expression:3.2.4.RELEASE"


//TODO Should be a Spring bean
new HibernateDatastoreSpringInitializer("bookgorm").
configureForDataSource(new DriverManagerDataSource(,
"jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE", 'sa', ''


package bookgorm
import grails.persistence.Entity

class Book{
String title
String author
  static constraints = {
        title blank:false
        author blank:false


    void loadData(){
        List books=Book.list()
    def addBook= {evt=null->
        Book b=new Book(title:view.titleField.text,author:view.authorField.text)
    def clearAll= {evt=null->
        Book.executeUpdate("delete Book")

Mola, no?
¡A cuidarse!