Archinamon / android-gradle-aspectj

gradle plug-in adding supports of AspectJ into Android project
Apache License 2.0
365 stars 58 forks source link

Unresolved reference when compiling against android library with kotlin sources, woven by aspectj #88

Closed amelin closed 5 years ago

amelin commented 5 years ago

Hi!

I've got error when compiling against kotlin android library with top-level functions. The problem is that android-gradle-aspectj is not copying files, unprocessed by ajc, includingMETA-INF/*.kotlin_module, to transform's target directory. *.kotlin_module contains top-level function definitions, needed by kotlin compiler to successfully process kotlins-sources, that depend on them.

Simple project, that demonstrates problem - https://github.com/amelin/android-gradle-aspectj . It's compilation fails with current plugin version. With the supplied patch, it compiles successfully.

Supplied patch copies all files, unprocessed by ajc. If copying all files in a row is not desirable, for this specific problem it's ok to just copy META-INF/*.kotlin_module. Though I think, that by default all files must be copied either by ajc, or by plugin itself, since missing files can cause problems in other cases.

Error:

> Task :aspectLib:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug
:aspectLib:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug spend 43ms
:aspectLib:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug spend 43ms
e: /Users/lemeh/src/android-aspectj-sample/app/src/main/kotlin/TopLevelConsumer.kt: (3, 9): Unresolved reference: coreTopLevelFunction