uPhyca / gradle-android-aspectj-plugin

A Gradle plugin which enables AspectJ for Android builds.
Apache License 2.0
279 stars 55 forks source link

Prevent Re-Weaving via Java Destination Directory Deletion #15

Closed jlchoike-DL closed 9 years ago

jlchoike-DL commented 9 years ago

I observed the following build error if I didn't execute a clean task along with build

Caused by: java.lang.RuntimeException: bad WeaverState.Kind: -115. File was :::0 at org.aspectj.weaver.WeaverStateInfo.read(WeaverStateInfo.java:170) at org.aspectj.weaver.AjAttribute.read(AjAttribute.java:105) at org.aspectj.weaver.bcel.Utility.readAjAttributes(Utility.java:101) at org.aspectj.weaver.bcel.BcelObjectType.ensureAspectJAttributesUnpacked(BcelObjectType.java:383) ... 84 more

In the Maven AspectJ plugin, the potential for encountering this issue is accounted for by segregating output directories to prevent this error from occurring. See http://mojo.codehaus.org/aspectj-maven-plugin/weaveDirectories.html for more details.

        <!-- Modifying output directory of default compile because non-weaved classes must be stored
             in separate folder to not confuse ajc by reweaving already woven classes (which leads to
             to ajc error message like "bad weaverState.Kind: -115") -->

I think the more appropriate fix would be to mimic the design of the Maven plugin, but a temporary solution is to delete the destination directory before invoking the compiler

jlchoike-DL commented 9 years ago

@esmasui Do you see any concerns with this temporary approach; and do you have any plan (or see the need) to update such that the behavior is similar to that of the Maven plugin?