sentry-android-gradle-plugin icon indicating copy to clipboard operation
sentry-android-gradle-plugin copied to clipboard

Use new AGP APIs for hooking our tasks

Open romtsn opened this issue 1 year ago • 1 comments

Description

At the moment we are relying on older AGP APIs from the internal package, e.g. here to retrieve an assembleTaskProvider: https://github.com/getsentry/sentry-android-gradle-plugin/blob/6865616328829c33fbde83295bda915e7a3849c9/plugin-build/src/agp74/kotlin/io/sentry/android/gradle/AGP74Compat.kt#L37-L40

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

romtsn avatar Jan 19 '24 12:01 romtsn

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.

markushi avatar Jan 24 '24 14:01 markushi