0

I'm totally confused how and where to specify my own plugin dependencies in Grails 2.2.X The documentation (Understanding Plugin Load Order) says that you can specify the dependencies in plugin descriptor class MyGrailsPlugin.groovy. Whereas, the "Upgrading from" chapter says that only pom dependencies will be taken into account. As I understand this unclear statement, only if I would specify the dependency in BuildConfig as a compile dependency that it would be used.

Using dependsOn brought me some problems in my main application (could not resolve a dependency in plugin even if it exists - I think some wild card problem "def dependsOn =['jquery-ui': "* > 1.8.24"]").

The only way how the plugin dependency works for me is specifying it in BuildConfig (MyPlugin):

grails.project.work.dir = 'target'

grails.project.dependency.resolution = {
   inherits 'global'
   log 'warn'

   repositories {
      grailsCentral()

      mavenLocal()
      mavenCentral()
   }

   plugins {
      build(':release:2.2.1', ':rest-client-builder:1.0.3') {
         export = false
      }
      compile ":resources:1.1.6"
      compile ":jquery:1.8.3"
      compile ":jquery-ui:1.8.24"
   }
}

But my application uses resources plugin of version 1.2. When I run the app it always asks me if I'd like to upgrade to 1.1.6.

So the question is, how and where should I specify my dependencies.

Thanks, Mateo

kuceram
  • 3,795
  • 9
  • 34
  • 54
  • If a grails app/plugin is mavenized, yes in that case dependency is redolved from pom. In your case, since you have not mentioned maven anywhere I assume, you should be good with BuildConfig. Best example is right in front of you, resource plugin is versioned 1.1.6 in BuildConfig so it always asks for an upgrade. Change that to 1.2. – dmahapatro Jul 03 '13 at 10:46

2 Answers2

0

Actually, I am using grails 2.1.0. In that i replace resource with 1.2( runtime ":resources:1.2") in BuildConfig.groovy. And then refresh dependencies. It is worked fine.

Visme
  • 983
  • 8
  • 29
0

After reading more about Grails plug-in I realized that this behavior makes sense. If the plugin specify certain version of its dependency and your project specifies a different one, you're in conflict. You need to use following in order to exclude dependecy from the plugin and use yours:

runtime ":resources:1.2"

compile ':my-plugin:2.0.8', {
   exclude 'resources'
}

In this case the plugin creator cannot assure that his plugin will run properly with newer version of dependency.

Regarding the resources plugin dependency. In my opinion it is better to use following

compile ":resources:1.1.6" {
   export = false
}

which won't include the dependency for your plugin. This should be used just when you defines some ApplicationResources.groovy. If you use something from this plugin in your plugin you should not exclude resource plugin...

In my opinion you should specify your plugin dependencies in BuildConfig.groovy

Hope these things will be improved in further Grails versions.

Further reading from Burt: http://www.slideshare.net/burtbeckwith/plugins-21828912

kuceram
  • 3,795
  • 9
  • 34
  • 54