Ah, so I found the problem. My test sources are referring to a generated class which only exists once the annotation processor runs. Removing the reference causes the generated java files to be compiled to class files.
I'll make a sample and do more investigating in the morning. An example of an annotation processor that requires this behavior is Google's AutoValue <https://github.com/google/auto/tree/master/value> if others want to take a look in the mean time. On Wed, Jul 9, 2014 at 1:11 AM, Jake Wharton <[email protected]> wrote: > I’m seeing behavior where the Java sources generated by an annotation > processor that is being run only as part of the test compilation are not > present. The sources show up in build/intermediates/classes/test/debug/ > as raw .java files but are not being included compiled as part of the > same javac invocation. > > From running --debug, the javac invocation of both the main variant and > the test variant have identical options passed to them: > > 00:36:31.749 [DEBUG] > [org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler] Compiler > arguments: -source 1.7 -target 1.7 -d > /path/to/repo/tester/build/intermediates/classes/test/debug -g -encoding > UTF-8 -bootclasspath /path/to/sdk/platforms/android-19/android.jar -classpath > /path/to/repo/processor/build/libs/processor.jar:(other dependencies, class > files) > > Digging into the plugin source, both tasks seem to be created from > BasePlugin.createCompileTask. The only difference here is that in the > test variant the compiled classes of the main variant are added to the > classpath. > > The annotation processor is included in the androidTestCompile scope to > force its inclusion on the classpath. Logs inside the annotation processor > verify that it runs every time. The generated .java files in the > aforementioned folder always show up correctly after clean builds. > > The most interesting fact is that errors in the generated sources will > fail the build! This means that they are being compiled but the resulting > class isn’t being written to the filesystem in the same place nor is it > being added into the classpath. They are nowhere to be found under the > build/ folder. > > It seems like a bug but I can’t figure out what is actually causing it. > Any ideas? > > -- You received this message because you are subscribed to the Google Groups "adt-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
