Monday, March 8, 2010

Grails inplace plugin tip - BuildConfig.groovy

Hey... it's late... so lets keep this one short!

(Update: check out this article too! )

I have taken it upon myself to get some re-usable functionality out of our companies grails apps and turn them into plugins.... I thought this was a genius idea but alas I wasn't the person to come up with it... creating grails plugins to modularize your applications is common practice these days.

One headache I came across immediately however was developing an application that depended on a plugin that was also in flux... lets call them MyApp and my-plugin....

I found myself going nuts.... I would come across an error or a shortcoming in my-plugin code while developing MyApp (yes... i am man enough to admit it!!) and had to change the code in my-plugin, do a grails clean.... followed by a grails compile... followed by a grails package-plugin..... ..... FOLLOWED BY ..... a grails install-plugin in MyApp directory... followed by a soul crushing 'y' to confirm installation.... HOLY KEYSTROKES BATMAN!!!!!!!! sorry...

Then I came across a nice solution while pestering Peter Ledbrook on his blog on how to best test plugins....

He pointed me to BuildConfig.groovy in the grails-app/conf folder of MyApp... in there I put the magic words:

grails.plugin.location."my-plugin" = "../my-plugin"

This is basically the path to my-plugin relative to MyApp. I have both in the same workspace directory.

By doing this you only need to package your plugin once to ensure all files are generated.

Now if I find I need to change my-plugin while working in MyApp i simply jump to the source in another IDEA window, make the changes and then restart MyApp.... happy days!!

One word of warning though... I had to remove my-plugin from as from what I could gather... grails didn't know this reference would then relate back to the one BuildConfig.groovy.... this resulted in my-plugin being deleted.... thank the higher beings for version control!!!

Hmmm now I need to figure out how to do a plugin repo for our internal plugins.... another late night maybe....

Hope this helps.... thanks to Peter for his time!


  1. I don't think you need to remove the plugin from the application's We've been working like this for months now without a problem

  2. @Olivier

    Thanks for the input! I will give it a try!

  3. hi very good info.
    need to know how i can debug the plug-in code through IntelliJ 8.1.4 , since in place plug-in resides out side the editor.

    1. You can import plugins from project structure of Intellij through your main project and edit.

  4. Hello, i am from USA, I want to share this great testimony about how Dr.Agbazara helped me bring back my ex lover, During my search for solution i came in contact with Dr.Agbazara details and through his help my lover came back to me within 48 hours. So with these i am so bold to advise anyone seeking for a way to get there lover back to contact Dr.Agbazara on WhatsApp: { +234 810 410 2662 } or via email at: { agbazara@gmail. com } I am so happy at least myself and my lover are back to each other again and going to spend the New Year celebration together Thank to Dr.Agbazara once again....