jbwiv
jbwiv

Reputation: 1015

Overriding Grails built-in library?

Grails "rendering" plugin uses org.xhtmlrenderer. Grails itself comes packaged with org.xhtmlrenderer:core-renderer:R8, which apparently from dependency-report is used grails-docs.

There's a bug in this version of xhtmlrender which conflicts with twitter bootstrap and which is only fixed in the github repository. I've built this new version and successfully installed it via maven, but for the life of me I can't get the "rendering" plugin to use it. I've even tried to build my own version of the rendering plugin, but that doesn't work, and according to dependency-report "rendering" doesn't even depend on org.xhtmlrenderer:core-renderer:R8.

In BuildConfig.groovy, I've tried (among many, many other things):

inherits("global") {
        // specify dependency exclusions here; for example, uncomment this to disable ehcache:
        // excludes 'ehcache'
        excludes 'core-renderer-M8', 'org.xhtmlrenderer', 'core-renderer'
    }

and

compile 'org.xhtmlrenderer:flying-saucer-core:9.0.1-custom' 
runtime 'org.xhtmlrenderer:flying-saucer-core:9.0.1-custom'

to no avail.

How can I get "rendering" to use my custom build of org.xhtmlrenderer? Is the trick to build a local version of the "rendering" plugin and add the exclude and dependency info I tried in the project BuildConfig.groovy to the plugin BuildConfig.groovy?

Upvotes: 3

Views: 1170

Answers (1)

doelleri
doelleri

Reputation: 19682

What you need to do is exclude grails-docs from the inherited global dependencies and then specifically add it excluding xhtmlrenderer (although it looks like that's just the package name and you need to exclude flying-sauce-core). This will let you specify your own version of the library.

grails.project.dependency.resolution = {
    // inherit Grails' default dependencies
    inherits("global") {
        excludes 'grails-docs'
    }

    dependencies {
        // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
        // runtime 'mysql:mysql-connector-java:5.1.24'
        build('org.grails:grails-docs:2.3.7') {
            excludes 'flying-saucer-core'
        }
    }
}

Upvotes: 6

Related Questions