5

Related to this ticket Parameters for annotation processors are disabled and undocumented

How do we use annotation_processors and annotation_processor_deps ?

Im using realm in a sample Android app and without the annotations (for @RealmClass and @RealmMoudule) the app crashes when built via buck (works normally if built via gradle).

Sandeep Chayapathi
  • 1,490
  • 2
  • 13
  • 31

1 Answers1

7

In case anyone stumbles on this, the way to use annotation processors with buckbuild is:

  • The annotation_processors is a immutable list of processor class. You can identify this by the package name used in META-INF/services/javax.annotation.processing.Processor file, example: Realm Processor
  • The annotation_processor_deps is a immutable list of Rules (generally prebuilt_jar or android_prebuilt_aar) holding the annotation processor

A sample buck build file of a project that uses Realm Java

prebuilt_jar(
  name = 'realm',
  binary_jar = 'libs/realm-android-0.82.2.jar'
)

android_library(
  name = 'main-lib',
  srcs = glob(['app/src/main/java/com/yourcompany/project/**/*.java']),
  deps = [
    ':supportv4',
    ':all-jars',
    ':build-config',
    ':res',
  ],
  annotation_processors = ['io.realm.processor.RealmProcessor'],
  annotation_processor_deps = [':realm']
)
Sandeep Chayapathi
  • 1,490
  • 2
  • 13
  • 31
  • 2
    We haven't documented it yet because we are considering changing the API (possibly something more like Bazel's java_plugin). – sdwilsh Oct 22 '15 at 14:47