Archinamon / android-gradle-aspectj

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

defaultIncludeAllJars migration? #33

Closed renaudcerrato closed 7 years ago

renaudcerrato commented 7 years ago

Since you removed defaultIncludeAllJars from the plugin, it looks like AJC is not seeing any joint points located into my (java?) modules anymore. What's the proper workaround?

Do I now have to use includeJar: my-module-<version>.jar ?

Archinamon commented 7 years ago

Yep, nowadays it should look like: includeJar 'my-module', 'my-second-module' You don't need to clarify any other info except of name.

saulmm commented 7 years ago

Same here!, I workarounded doing includeJar 'modulename'. I can see the Join points properly generated at ajc-details.log but is not compiling anymore. Here's the trace

Warning:Exception while processing task java.io.IOException: Can't write 
[.../app/build/intermediates/transforms/proguard/debug/jars/3/1f/main.jar] (Can't read 
[.../Android/app/build/intermediates/transforms/aspectj/debug/folders/1/1/aspectj(;;;;;;**.class)] 
(Duplicate zip entry [.../analytics/Analytics.class]))

Thank you!

Archinamon commented 7 years ago

@saulmm did you use 2.3.0 version?

saulmm commented 7 years ago

I tried initially with 2.2.0, then bumped to 2.3.0 and the same happened

Archinamon commented 7 years ago

That's bad. Could you, please, provide a sample project reproducing this error?

renaudcerrato commented 7 years ago

BTW, everything was working fine using defaultIncludeAllJars true. I will try to send you a sample project reproducing it.

saulmm commented 7 years ago

I have just been able to reproduce it, here is the link with a sample project.

It turns out that using the v24.0.3 of buildToolsVersion with the v2.2.3 of the Gradle plugin fires the following trace without compiling:

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: 
com.android.dex.DexException: Multiple dex files define Lcom/example/annotation/Analytics;

It works fine bumping the tools to 25.0.x and Gradle plugin to 2.3.0-beta3. The point is that I'm using the stable version for production.

renaudcerrato commented 7 years ago

Hi :) Any news on that?

On Mon, Jan 30, 2017 at 11:06 AM Saul Molinero notifications@github.com wrote:

I have just been able to reproduce it, here is the link with a sample project https://www.dropbox.com/sh/32zm7up4wtkly97/AAB7cIYyBPgKOXlb_1jmvb5Oa?dl=0 .

It turns out that using the v24.0.3 of buildToolsVersion with the v2.2.3 of the Gradle plugin fires the following trace without compiling:

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/example/annotation/Analytics;

It works fine bumping the tools to 25.0.x and Gradle plugin to 2.3.0-beta3. The point is that I'm using the stable version for production.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Archinamon/GradleAspectJ-Android/issues/33#issuecomment-276103962, or mute the thread https://github.com/notifications/unsubscribe-auth/AB12xbaAWXGYqkhJyHdHPfRMNPZ8sZY_ks5rXgqZgaJpZM4LxbPj .

Archinamon commented 7 years ago

Sorry, I have much work on weekdays :( Hope I'll get look of it on holidays.

renaudcerrato commented 7 years ago

Sure, get it. Sorry for the noise!

On Thu, Feb 2, 2017 at 6:38 AM Edgar notifications@github.com wrote:

Sorry, I have much work on weekdays :( Hope I'll get look of it on holidays.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Archinamon/GradleAspectJ-Android/issues/33#issuecomment-276934955, or mute the thread https://github.com/notifications/unsubscribe-auth/AB12xZ8CT2N3_2Knu17YCGZ7gNICrMjjks5rYcA2gaJpZM4LxbPj .

renaudcerrato commented 7 years ago

Hi! FYI, Android Gradle Plugin 2.5 is in beta, and is supposed to bring a big boost in performance. Can't wait to upgrade.

Archinamon commented 7 years ago

Multiple dex files define

This shit happens again :( Sadly I can't find what is going wrong, but likely now I have some time to look deep into it.

saulmm commented 7 years ago

That works, I'll stay tuned. Thank you! 👍

renaudcerrato commented 7 years ago

Hi @saulmm : the gradle plugin 2.3.0 is now out of beta. Did you tried again on your end?

Archinamon commented 7 years ago

I'd noticed that on gradle 2.3.0 there's able no more to include arbitrary jars from classpath, 'cause they are renamed into random numbers/characters sequence. E.g. .android/build-cache/48e2e63626a1159ec108f75303f63a1b826d7bb9/output/jars/classes.jar. So no weave of library classes :(

renaudcerrato commented 7 years ago

So, basically, the transform API is now almost useless? That can't be... 😕

On Tue, Mar 7, 2017, 7:12 AM Edgar notifications@github.com wrote:

I'd noticed that on gradle 2.3.0 there's able no more to include arbitrary jars from classpath, 'cause they are renamed into random numbers/characters sequence. E.g. .android/build-cache/48e2e63626a1159ec108f75303f63a1b826d7bb9/output/jars/classes.jar. So no weave of library classes :(

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Archinamon/GradleAspectJ-Android/issues/33#issuecomment-284692780, or mute the thread https://github.com/notifications/unsubscribe-auth/AB12xWYREaFySpn9tAwTjzlpq2qWf01bks5rjTuogaJpZM4LxbPj .

Archinamon commented 7 years ago

That can't be and it's useful anyway :) I will investigate more about how to detect concrete jar package to include it to be weave. Much more pain and suffering brings me Multiple dex files define exception :D

Archinamon commented 7 years ago

I've been released 2.3.1 with new old parameter named includeAllJars, so you can try it out :) Notice that in this release changed compilation flow, so it may occur some illegal behaviours. Feel free to feedback!

Archinamon commented 7 years ago

Two-steps compilation doesn't resolve problems with Multiple dex files define :( I'm thinking about a couple of workarounds... But it will work not for all build variants. I.e. won't work with InstantRun and will fail build if corresponding flag won't be set in aspectj-configuration closure in case if you want to weave and jars/aars and use InstantRun. And won't fail with InstantRun no jars/aars weaving. Wanna go this way. Will such workaround be applicable, guys?

renaudcerrato commented 7 years ago

We are not making any use of InstantRun (which is highly instable anyway), so that's not a problem for us.

I thought that the TransformApi would allow plugin developers to not have to work around Android plugin updates! What a mess! Your AspectJ plugin is the only viable one around.

We'll try and let you know. @saulmm?

Archinamon commented 7 years ago

I've released 2.4.3 version with workaround for includeJar and includeAllJars. Now if you wanna use inpath weaving you should apply another plugin: com.archinamon.aspectj-ext. Without ext word will be loaded "simple" mode configuration and inpath parameters will be ignored. Also InstantRun should switched off in ext mode. Plugin will detect it and fails :)

This won't affect includeAspectsFromJar parameter and any others. Simple config com.archinamon.aspectj perfectly friendly with InstantRun and jRebel, but not with includeJar sometimes, so I've disabled in completely in "simple" mode.

Archinamon commented 7 years ago

That seems a great day... with 3 hotfixes already! 😄 The latest stable is 2.4.3 with blocker fix of two-step compilation flow.

renaudcerrato commented 7 years ago

Really appreciated! Give us a few hours, and I'd get back to you

saulmm commented 7 years ago

Hey, great news! It worked, using buildToolsVersion "25.0.2" along "com.android.tools.build:gradle:2.3.0" & v2.4.3 of the aspects library.

renaudcerrato commented 7 years ago

Thanks @Archinamon, I'll close that issue!