Skip to content

Grails 2.2.5 and Earlier

Ken Siprell edited this page Apr 2, 2015 · 3 revisions

Grails 2.2.5 and Earlier

Background

The Drools plugin version 1.0.0 will work out-of-the-box with Grails versions 2.3.0 and later. The plugin will also work with earlier versions, but it will require you to download the plugin source, edit two files, and install it locally.

The problem lies with different Spring versions. Drools can require a later version than the one that ships with a particular Grails version, and Ivy will evict the earlier Spring version required by Grails. Even if you declare the plugin's Drools dependencies with a different version in your application's BuildConfig.groovy file, Ivy will still use the version defined in the plugin and evict the one required by Grails.

The plugin will work with Grails 2.2.x if you use Drools 6.1.0.Final. It might work with Grails 2.1.x if you use Drools 6.0.0.Final although I have not tested it.

How-to

This section assumes you are on a *nix system with git, gvm, and Perl installed, allowing you to copy and paste the commands below. If you are on Windows, use the commands as a guide and adjust the directory paths. If Perl is not installed, edit the plugin's DroolsGrailsPlugin.groovy file and append -LOCAL to the plugin's version, thereby avoiding any repository conflicts. Also edit the plugin's BuildConfig.groovy and change String droolsVersion = "6.2.0.Final" to whatever version you prefer.

git clone https://github.com/kensiprell/grails-drools.git

cd grails-drools

perl -i -pe "s/def version = \"1.0.0\"/def version = \"1.0.0-LOCAL\"/" DroolsGrailsPlugin.groovy

grep "def version =" DroolsGrailsPlugin.groovy

perl -i -pe "s/droolsVersion = \"6.2.0.Final\"/droolsVersion = \"6.1.0.Final\"/" grails-app/conf/BuildConfig.groovy

grep "String droolsVersion =" grails-app/conf/BuildConfig.groovy

gvm use grails 2.4.5

grails compile

grails maven-install

Now that you have the plugin installed in your local Maven repository, you can follow the steps in the README.md. However, you must ensure that your application's BuildConfig.groovy is similar to the example below. Specifically, mavenLocal() must be declared in the repositories block and the plugin dependency must use the version number changed above.

grails.project.dependency.resolution = {
    // other stuff
    repositories {
        // other repositories
        mavenLocal()
        // other repositories
    }
    plugins {
        // other plugins
        compile ":drools:1.0.0-LOCAL"
        // other plugins
    }
}
Clone this wiki locally