Search This Blog

In my daily life as a programmer I come across problems. This blog, is where I record them (and more importantly their solutions) so that I can dig them out in the future. I hope it might save others some problem solving time too.

Modularize/partition Grails config files

If you find that your Config.groovy is getting large, you can split it into multiple files using the same mechanism that might already be using to include an external file.
So your Config.groovy may already have something like the following defined:

One might expect files in the conf directory that follow the convention of ending in Config.groovy of being automatically included but this in not the case. I imagine the reason is a question of precedence - and a lack of clarity thereof. If two files in the conf directory ending in Config.groovy defined the same property which one would win?
So only the Config.groovy file is auto-read by Grails, and within this file you can define other Config files to include. It's not very convention over configuration, but you can understand why.

The files to include can be defined in one of two lists. grails.config.locations and grails.config.default.locations. Files defined in grails.config.locations are parsed after the property definitions of Config.groovy, and files defined in grails.config.default.locations are parsed before. Where the same property is defined twice, the last one parsed wins.

You might see a number of suggestions on how to modularize a config but the only one I found to work was to place your "partial configs" in the src/java directory and then define them with in the locations list with a classname prefix.

Comments

Post a Comment

Popular posts from this blog

Whether you checkout Twitter or any of the other uber popular web apps, you will find dates displayed are often in a very user friendly "from now" format. Examples of this format are "Just now", "A few minutes ago", and "2 days ago". In these three examples a date value is displayed as an approximation of the difference between the absolute date value and the current time. This "from now" format could be applied on the server, but it is generally better to apply this on the client side via javascript so that it can be continually updated to reflect the every passing time. 2 javascript examples I've come across for applying the "from now" format are John Resig's lightweight pretty date library, and the other is more built-out Moment.js. In this post I explain how to apply a sliver of the power of MomentJs in an AngularJs application.
AngularJs is a delightful Client side javascript framework. One of its features is ca…

The one thing missing from the great text editor that is Mac Vim is a project / file explorer side bar. Competing text editors such as Sublime and Text Mate have one, so why not MacVim? It doesn't seem like it would require too much additional work of the developers. Reading through debates the community has had on the issue, the reason appears to be the elitist and idealistic nature of the Mac Vim community. Please don't read that last sentence pejoratively; these guys are purists, and very good at what they do. There were quite a few in the community who believed NERDTree was more than enough for any code jocky's needs, so I decided to checkout what all the fuss was about.

I use pathogen to manage vim plugins, and it is especially useful in conjunction with a public source control system like github. Once you have pathogen installed simply pull the NerdTree Github project to your vim plugins directory.

Introduction
There are a number of different functional test frameworks that can be used with Grails. Each of which can be incorporated into the overall test infrastructure of your Grails app by including the relevant plugin:
Canoo WebtestG-FuncGebSelenium-RCWebDriver
Grails doesn't hold any opinion on which one to choose. This is fair, and gives developers choice, but it can also be a headache; one has to make the choice of which framework, and also do the necessary setup and configuration. The functional test framework of the day is currently Geb, which builds on top of another functional framework in WebDriver. Geb can be used with the test runners JUnit, TestNG, or Spock. Spock, like Geb is the tool dejour and they are commonly used together. The best thing about Spock tests is that they are easy to read.
New Dependencies in your BuildConfig
To run your functional tests you need to include a number of libraries and plugins in your BuildConfig.groovy. Here is what you typica…