开发者

Grails Plugin Maven Integration

开发者 https://www.devze.com 2023-03-13 14:53 出处:网络
I\'m trying to create Mavenized Grails application. Every开发者_如何转开发thing works fine but as I understood all the dependencies (all .jars like mysql-connector and also all grails (public) plugins

I'm trying to create Mavenized Grails application. Every开发者_如何转开发thing works fine but as I understood all the dependencies (all .jars like mysql-connector and also all grails (public) plugins like spring-security-core plugin) should be listed in pom.xml.

The thing is that I don't know how to include public grails plugins (is there any Maven repository for that, or should I include used plugins into my local repo?). Or is the proper way how to handle grails plugin to list them in "application.properties" and let the grails to manage these plugins?

Thank you for any comment.:-)

Mateo


You can specify your plugin dependencies in grails-app/conf/BuildConfig.groovy, for example:

grails.project.dependency.resolution = {

  plugins { 
    runtime ':hibernate:1.2.1' 
  }
} 

Update

In response to your comments below, a plugin dependency specified in BuildConfig.groovy (or application.properties) will still be resolved by Grails rather than Maven. I don't think there's any way that you can get Maven to resolve a Grails plugin dependency, because Maven can only work with JAR dependencies in Maven repositories. Remember, Grails plugins are not (typically) available from Maven repositories.

If you want to hand as much control as possible over to Maven, you can try excluding the JARs from your plugin dependencies, e.g.

plugins {
    runtime( "org.grails.plugins:hibernate:1.2.1" ) {
        excludes "javassist"
    }
}

and add them to your pom.xml instead. Here be dragons (see below).

Editorializing

FWIW, unless you really have to build your Grails project with Maven (e.g. because another Maven project depends on it), my advice would be don't. I say this because Maven is very much a second-class citizen in the world of Grails build tools. The usual way to build a Grails app is using the built-in GAnt commands. Future versions of Grails will move towards Gradle as the default build tool, so it seems that Maven will be an afterthought for the forseeable future


By default, Grails plugins are included at the source level. A plugin zip is expanded, and the plugin source is compiled as part of the grails build process.

Since 2.0, grails can use binary plugins. You can depend on plain old JARS if those jars represent binary grails plugins.

Binary grails plugins can be referenced by normal maven coordinates.

Your project's BuildConfig.groovy is where you specify maven repositories and binary plugins.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号