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.
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.
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.