Ibotta / gradle-aspectj-pipeline-plugin

A Gradle plugin for Android projects which performs AspectJ weaving using Android's bytcode manipulation pipeline.
Apache License 2.0
75 stars 15 forks source link

[AT-2430] Attempt to work around AGP 7.0.2 ExtractAnnotations task issue #13

Closed eschlenz closed 2 years ago

eschlenz commented 2 years ago

Several of us at Ibotta have attempted to upgrade AGP to version 7.0.2, but have run into build failures as a result. We've all come to the conclusion that the core issue seems to be caused by our AOP weaving plugin.

I too attempted this upgrade and decided to investigate a little further to see if I could find a fix, or at least, a work around.

I was noticing that, just before the build failed, there would be a line of Gradle log output indicating that "/Users//Documents/Ibotta-Android/ibotta-app/build/tmp/kotlin-classes/debug" did not exist. The task that was failing was called "extractAnnotations".

This directory not existing, is not surprising. Our AOP logic moves the Kotlin/Java compile output directories in order to allow AOP weaving to occur. The Gradle tasks responsible for compilation are pointed to new directories. And, in general, this is fine. Downstream tasks that depend on the output directories from these compile tasks should be asking the tasks for their output directory. This seems to be the "proper" way to create tasks that depend on on others.

However, this "extractAnnotations" seems to strictly require the tmp/kotlin-classes/debug, almost as if it's hardcoded somewhere. The task fails because this directory simply doesn't exist.

As a workaround, I decided to make sure this directory at least exists. This seems to get us past the build failure. However, the "extractAnnotations" task likely also needs to know where to expect the compiles classes to actually exist. So we are also manipulating its classpath to ensure this is the case.


If you would like to test this before we release it, you'll have to do the following.

  1. Ensure the project that uses this plugin is using version 7.0.2 of the Android Tools Gradle Plugin.
  2. Clone this branch and change the BUILD_NUMBER in Dependencies.kt to something like ".0-YOURNAME".
  3. Update the project that uses this plugin to point to the version that corresponds to the change you made in step 2. (example: 1.2.0.0-SCHLENZ)
  4. Run ./publishLocal.sh from the root of this branch.
  5. Build the project that uses this plugin.