Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

documentation for annotation_processors (buck)

Tags:

android

buck

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

like image 894
Sandeep Chayapathi Avatar asked Oct 02 '15 20:10

Sandeep Chayapathi


1 Answers

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']
)
like image 112
Sandeep Chayapathi Avatar answered Nov 15 '22 00:11

Sandeep Chayapathi