Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code re-use between Grails project - keeping it DRY

Tags:

grails

The Grails framework has a lot of constructs/features that allows for adhering to the DRY principle ("don't repeat yourself") within a project. That is: within a specific project you're seldom required to repeat identical blocks of settings or code. So far so good.

However, the more I've worked with Grails the more of I've observed that I repeat code not within the same project but between projects. That is project A has controllers, GSP:s and images that overlaps with project B. This is a maintenance nightmare since bug fixes in project A must also be fixed in project B, etc.

I'd like to take DRY to the next level by not duplicating code between my projects.

My question: How do you tackle this problem (violated "inter-projects DRY") in your own internal Grails projects?

Please be very specific/concrete. If possible try to include specific code examples on how you solve it in practice.

like image 688
knorv Avatar asked Sep 03 '09 06:09

knorv


1 Answers

Writing a custom plugin is the best way. You don't need to release it to the public repository, as you can use a private repository somewhere within your own network.

I haven't had enough duplicated code yet to pull out a plugin (most of the code repeated in my projects seem to be covered by the various public plugins), but a plugin can be as simple as a few common domain classes or services.

like image 115
leebutts Avatar answered Sep 30 '22 09:09

leebutts