Search code examples
grailsmaven-2grails-plugin

Grails Plugin Maven Integration


I'm trying to create Mavenized Grails application. Everything 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


Solution

  • 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