Archinamon / android-gradle-aspectj

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

Regression: Java based aspects are not getting weaved on latest version #104

Open ashj11 opened 4 years ago

ashj11 commented 4 years ago

Preconditions: Application's build.gradle has the aspectj plugin enabled apply plugin: 'com.archinamon.aspectj' Aspects are added to another module( library module ), with the plugin com.archinamon.aspectj-provides applied. This has been configured with includeAspectsFromJar in the app's build.gradle

Problem: If the tests are launched with version plugin version3.4.5( com.archinamon:android-gradle-aspectj:3.4.5), then app/tests fails with the below error java.lang.RuntimeException: java.lang.NoSuchMethodError: No static method aspectOf()L<classname>; in class L<classname>; or its super classes (declaration of '<classname> appears in /data/app/<appname>/base.apk:classes2.dex)

at .....
at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:46)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)

So it looks like the java aspects are not getting weaved, if they are part of a separate module. This works in version 3.4.0 and hence this is a regression.

There have been many changes related to aspectj-provides after 3.4.0.

3.4.3 -- Once more fix :( hotfixed provides plugin mode — transformation should not starts; 3.4.2 -- Hotfix provides hotfixed provides plugin mode — transformation should not starts; 3.4.1 -- Fix provides fixed aspectj-provides plugin mode — do not cleanup destination dir;

@Archinamon Could you please have a look?

ashj11 commented 4 years ago

@Archinamon Any update on this?