atteo / classindex

Index classes, do not scan them!
Apache License 2.0
263 stars 43 forks source link

Scanning from multiple android modules overwriting index file instead of appending #40

Closed jugutier closed 6 years ago

jugutier commented 6 years ago

Hi @sentinelt

Thanks for this great library! Been playing with it for some time but I encountered the following issue on android. Say we had:

App (Android App Target)

-> some annotated classes

MyLib (Android Library Project)

-> some annotated classes

(code that depends on finding annotated classes from both targets with a compile time annotation)

Adding on App's build.gradle & MyLib's build.gradle seems to be overwriting the index file instead of appending.

Currently using for invocation:

    implementation 'org.atteo.classindex:classindex:3.4'
    annotationProcessor 'org.atteo.classindex:classindex:3.4'

in both gradle files, Also tried all permutations (App & not lib, lib & not app, both) seems like the second time the annotationProcessor directive runs the index file that goes in META-INF/annotations only the latest annotated classes persist and make it into the APK.

Is this something I could extend in this library or just not supported in Android? any leads?

Thanks :)

jugutier commented 6 years ago

This may be resolved by using classindex-transformer, except that I can't seem to find how to run the equivalent from that pom excerpt in the README from gradle

jugutier commented 6 years ago

Resolved by adding

packagingOptions { merge 'META-INF/annotations/*' }

on the App's build.gradle.