rharter / auto-value-moshi

AutoValue: Moshi Extension
Apache License 2.0
190 stars 25 forks source link

Processor assumes annotations are on the classpath #106

Closed JakeWharton closed 6 years ago

JakeWharton commented 6 years ago

With AutoValue 1.6, the annotations are no longer part of the AutoValue processor and are in a separate dependency, auto-value-annotations. This processor assumes that these types will be present and so when updating to 1.6, a NoClassDefFoundException is thrown.

Caused by: java.lang.NoClassDefFoundError: com/google/auto/value/AutoValue
        at com.ryanharter.auto.value.moshi.AutoValueMoshiAdapterFactoryProcessor.getSupportedAnnotationTypes(AutoValueMoshiAdapterFactoryProcessor.java:61)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment$ProcessorState.<init>(JavacProcessingEnvironment.java:505)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment$DiscoveredProcessors$ProcessorStateIterator.next(JavacProcessingEnvironment.java:597)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:690)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
        at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
        at com.sun.tools.javac.main.Main.compile(Main.java:523)
        ... 58 more
Caused by: java.lang.ClassNotFoundException: com.google.auto.value.AutoValue
        ... 68 more

The processor should either declare a dependency on auto-value-annotations or migrate away from referencing the @AutoValue by class and instead look it up via FQCN or Types/Elements.

bl00dra1n commented 6 years ago

is there a workaround to be able to compile project with latest autovalue and autovalue-moshi?

joelightshoe commented 5 years ago

I am still experiencing this issue using AutoValue 1.6.3 and AutoValue: Moshi Extension 0.4.5, and gradle 5.1.1

Declaring auto-value-annotations as an additional dependency with the annotationProcessor configuration seems to work for me, similar to what @liujoshua found at one point in auto-value-gson.

annotationProcessor 'com.ryanharter.auto.value:auto-value-moshi:0.4.5'
annotationProcessor 'com.google.auto.value:auto-value-annotations:1.6.3' // include again for auto-value-moshi
mkjensen commented 5 years ago

It looks like this is fixed on master. When someone with the appropriate access rights has time for it, I hope we get a new release. Thank you.

nedtwigg commented 5 years ago

Looks like master has a bunch of great fixes, but there's a few issues still targeted for the 0.5.0 milestone before release. If possible it would be great to get the stuff that's already finished out onto mavencentral.

ZacSweers commented 5 years ago

Working on it!

On Mon, Mar 25, 2019 at 1:06 PM Ned Twigg notifications@github.com wrote:

Looks like master has a bunch of great fixes, but there's a few issues still targeted for the 0.5.0 milestone before release. If possible it would be great to get the stuff that's already finished out onto mavencentral.

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/rharter/auto-value-moshi/issues/106#issuecomment-476356536, or mute the thread https://github.com/notifications/unsubscribe-auth/ABTEvkJEgSnw0YWIV07yiRhJ4W1Df_Usks5vaSwwgaJpZM4TcxwT .