Dealing with plugin classpath conflicts

I have an issue where using both the nebula info-plugin and the asciidoctor plugin fails due to a classpath conflict. The long story is described at https://github.com/elygre/asciidoctor-pdf-final-class and http://discuss.asciidoctor.org/Using-asciidoctorj-pdf-from-gradle-tp2731p2986.html, but the short story is this:

  • nebula-info uses an old version of p4java, which include com.jcraft.jzlib:1.0.7.
  • asciidoctor uses jruby which includes (and requires) com.jcraft.jzlib:1.1.2
  • in our build, jruby sees the old version of jzlib (from nebula-info), and fails

So, the questions are:

  • In general, what is the preferred way of dealing with this?
  • Is there any way of removing dependencies used by a plugin? (Remove the jzlib.1.0.7-dependency from nebula-info might just fix our problem)

Eirik

Thanks for the example project.

I think your best bet is to use the buildscript {} way of specifying plugin dependencies and exclude jzlib from the nebula plugin:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath ("com.netflix.nebula:gradle-info-plugin:2.2.0") {
            exclude group: "com.jcraft", module: "jzlib"
        }
    }
}

The plugins {} block isn’t smart enough to handle this yet. I think the plan is to make it easier for plugins to only expose their public interfaces vs all of their dependencies to the classloader.

Thanks for your reply. I tried this, and it works nicely for me :smile:

The plan you outline sound good. As more and more plugins are available, this kind of conflict will only become more and more common. For now, though, this works for me!