Issues with new Plugin Publishing Plugin

I am seeing this stacktrace when trying convert an existing plugin project to use the new publishing plugin.

Caused by: java.lang.NoSuchMethodError: com.google.common.collect.ImmutableList.of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Lcom/google/common/collect/ImmutableList;
    at com.gradle.publish.PublishTask.<clinit>(PublishTask.java:47)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at org.gradle.api.internal.DependencyInjectingInstantiator.newInstance(DependencyInjectingInstantiator.java:48)
    at org.gradle.api.internal.ClassGeneratorBackedInstantiator.newInstance(ClassGeneratorBackedInstantiator.java:36)
    at org.gradle.api.internal.project.taskfactory.TaskFactory$1.call(TaskFactory.java:124)
    ... 71 more

It seems that this issue is caused by applying both com.github.hierynomus.license and com.gradle.plugin-publish plugins.

To be more succint, just applying com.github.hierynomus.license with com.gradle.publish:plugin-publish-plugin:0.9.0 in the classpath will cause the problem.

Hi Schalk!

The problem comes from the license plugin which uses a different version of Guava than the one provided by Gradle. So far I didn’t find any workaround.

Hey Cedric,

You’re the man with the clue! It works if you add the following into the buildscript.dependencies closure.

classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.11.0', {
    exclude module : 'guava'
}

Note that solutions like this will work perfectly fine as long as the dependency getting its transitive dependency removed doesn’t actually need the features in the version being excluded, as opposed to the other version. Watch out for this when/if you ever change the version of the dependency that you’re excluding the transitive dependency from. If you change that version, you should check to see if you can remove the exclusion.

Indeed David, but at least it get’s those of who use both plugins to keep working for the moment.