Plugin condition dependencies based on other plugins

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Plugin condition dependencies based on other plugins

candrews
For the Grails Cache Ehcache plugin http://grails.org/plugin/cache-ehcache I'd like to conditionally depend on artifacts based on the version of the Hibernate plugin (if the Hibernate plugin is installed). For example, I'd like to do something like this in BuildConfig.groovy:

grails.project.dependency.resolution = {
  dependencies {
    String hibernateVersion = Holders.pluginManager.getPlugin('hibernate')?.version
    if(hibernateVersion){
      if(GrailsVersionUtils.isVersionGreaterThan(hibernateVersion, "4.0.0")){
        // Using Hibernate plugin version 4 or later, so this is Hibernate 4.x
        runtime "net.sf.ehcache:sizeofengine-hibernate:0.9.0"
      }else{
        // Using Hibernate plugin version less than 4 (Hibernate plugin 2.x and 3.x are Hibernate 3.x), so this is Hibernate 3.x
        runtime "net.sf.ehcache:sizeofengine-hibernate3:0.9.0"
    }
  }
}

But, Holders.pluginManager doesn't work in BuildConfig.groovy. So how can I accomplish this conditional dependency?

Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Plugin condition dependencies based on other plugins

candrews
*bump* Anyone have any thoughts?