getsentry / sentry-android-gradle-plugin

Gradle plugin for Sentry Android. Upload proguard, debug files, and more.

Home Page:https://docs.sentry.io/platforms/android/gradle/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use new AGP APIs for hooking our tasks

romtsn opened this issue · comments

Description

At the moment we are relying on older AGP APIs from the internal package, e.g. here to retrieve an assembleTaskProvider:

// internal APIs are a bit dirty, but our plugin would need a lot of rework to make proper
// dependencies via artifacts API.
override val assembleProvider: TaskProvider<out Task>?
get() = (variant as? VariantImpl<*>)?.taskContainer?.assembleTask

We should rather use newer APIs to properly hook with the classes compilation, for example this one: https://github.com/android/gradle-recipes/blob/agp-8.2/getScopedArtifacts/README.md

variant.artifacts
    .forScope(ScopedArtifacts.Scope.PROJECT)
    .use(collectSourcesTaskProvider)
    .toGet(
        ScopedArtifact.CLASSES,
        CollectSourcesTask::projectJars,
        CollectSourcesTask::sourceDirs,
    )

Related tasks:

  • assemble
  • bundle
  • install

Let's ensure we can make this work across different versions of AGP (e.g. 7.0, 7.4, 8.x).
The upcoming project isolation feature could have an effect on overall build speed, we should investigate that.