Thursday, September 17, 2009

Grails - dependency resolution done right

Over the past couple of weeks I have been working on improving Grails dependency resolution capabilities for both applications and plugins. In previous versions of Grails (1.1 and below) you had limited options when it came to dependency resolution.

You could use the Grails Maven plugin, but that forced you to use, heavin forbid, Maven. We also shipped with basic Ant + Ivy support, but it was only really designed to be used for automation with continuous integration servers that support Ant and not at development time.

With Grails 1.2 this all changes with the introduction of Grails' dependency resolution DSL, which you can use to define your dependencies. Built on Ivy we have now eliminated one of the last remnants of XML usage in the Grails framework:
    dependencies {
runtime 'com.mysql:mysql-connector-java:5.1.5'
test 'junit:junit:3.8.2'
Grails takes application defined dependencies (defined in grails-app/conf/BuildConfig.groovy) and merges them with dependencies defined in the framework or any installed plugins. If there are conflicts you can exclude dependencies inherited from the framework or you can override plugin dependencies.

By default Grails will only resolve dependencies against your Grails installation but you can enable remote repository resolution easily:
repositories {
mavenRepo ""
If you're addicted to your pom.xml file then we have even added the ability to read dependencies from the pom.xml instead of using the DSL. All in all, Grails 1.2 will give you significantly better control over dependencies and how they are resolved.

We're still on track to release Grails 1.2 by the end of the month, but if you want to hear more about it I'll be talking about Grails 1.2 at upcoming events such as JAOO (Denmark), SpringOne2GX (New Orleans, USA) and the Grails eXchange (London). See you there!


sarbogast said...

And how does a Maven-built application work with a plugin using your dependency DSL? Because I've developed grails-apns plugin using your dependency DSL. And then I have a Grails 1.2 application with apns plugin installed in it. This application runs great with grails alone, but when I try to run it with Maven, I get ClassNotFoundException's for all the classes that are in the libraries my plugin depends on. Is it normal?

she said...

Better late than never. .........................................

sport8341 said...

hello everyone welcome to visit our stations ,chaussures pas cher|Air Max|there are many thingsChaussures Sport|NFL Jerseys|you needcell phones
NFL Jerseys|tn chaussures|chaussures puma|Tn RequinCheap Polo
Chaussures Nike Sport
you must visit!!!

念強 said...


淑純淑純 said...