stanfy/spoon-gradle-plugin

plugin breaks lint on new versions of android plugin

andaag opened this issue · 6 comments

Hi

See this thread : https://groups.google.com/forum/#!topic/adt-dev/ezM6RmO_ADY

We tracked it down to this plugin. If we remove that lint works fine.

As you can see in build.gradle we do not have a direct dependency on guava.
Here is a piece of runtime deps report.

runtime - Runtime classpath for source set 'main'.
+--- com.squareup.spoon:spoon-runner:1.1.2
|    +--- com.android.tools.ddms:ddmlib:23.2.1
|    |    \--- com.android.tools:common:23.2.1
|    |         \--- com.google.guava:guava:17.0 -> 18.0
|    +--- com.github.spullara.mustache.java:compiler:0.8.14
|    |    \--- com.google.guava:guava:13.0.1 -> 18.0
|    +--- com.google.guava:guava:18.0
\--- com.android.tools.build:gradle:0.14.1
     +--- com.android.tools.lint:lint:23.2.1
     |    +--- org.eclipse.jdt.core.compiler:ecj:4.2.2
     |    \--- com.android.tools.lint:lint-checks:23.2.1
     |         +--- com.android.tools.lint:lint-api:23.2.1
     |         |    +--- com.android.tools.external.lombok:lombok-ast:0.2.2
     |         |    |    \--- com.google.guava:guava:15.0 -> 18.0

Looks like Android Lint relies on guava 15.0.
But spoon-runner has a dep on 18.0, which causes the conflict and crash.

I see the following exception

Caused by: java.lang.NoSuchMethodError: com.google.common.io.Files.newOutputStreamSupplier(Ljava/io/File;)Lcom/google/common/io/OutputSupplier;
    at com.android.tools.lint.checks.ApiLookup.writeDatabase(ApiLookup.java:611)

This means that lint directly uses guava in ApiLookup method. However, there is not guava in their pom file.

My current workaround is

    classpath('com.stanfy.spoon:spoon-gradle-plugin:0.14.1') {
      exclude module: 'guava'
    }
    classpath 'com.google.guava:guava:17.0'

With this configuration

gradle clean lint spoon

works for example in this repo.

@andaag please close if it works for you

Works! Might be worth it to update the Readme.md or the sample, I'd imagine other people might run into this as well :)

Thank you very much for your help :)

README updated in de86098.

When using the workaround above (which fixes the lint issue), Spoon does not work anymore with multiple devices are attached. One device still works though.

More info at #36