Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new AGP APIs for hooking our tasks #641

Open
romtsn opened this issue Jan 19, 2024 · 1 comment
Open

Use new AGP APIs for hooking our tasks #641

romtsn opened this issue Jan 19, 2024 · 1 comment

Comments

@romtsn
Copy link
Member

romtsn commented Jan 19, 2024

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
@markushi
Copy link
Member

markushi commented Jan 24, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

2 participants