ApkOutputProviders

Added in 8.8.0

@Incubating
interface ApkOutputProviders


Provides APIs to obtain ordered collection of APK batches, each intended for local installation, facilitating staged installations.

As an example , let's take a Gradle org.gradle.api.Task that needs all the Apks for local deployment:

abstract class FetchApkTask: DefaultTask() {
@get:Internal
abstract val apkOutput: Property<com.android.build.api.variant.ApkOutput>

@TaskAction
fun execute() {
def apkInstallGroups = apkOutput.apkInstallGroups
for(installGroup: installGroups) {
installOnDevice(installGroup.apks)
}
}
}

val taskProvider: TaskProvider<FetchApkTask> =
tasks.register("installAppApks", FetchApkTask::class.java)

androidComponents {
onVariants(selector().withName("debug")) { variant ->
val appVariant = variant as? ApplicationVariant
appVariant?.let {
it.outputProviders.provideApkOutputToTask(
taskProvider,
FetchApkTask::getOutput, '
DeviceSpec("testDevice", 33, "", emptyList(), true)
)
}
}
}

Summary

Public functions

Unit
@Incubating
<TaskT : Task> provideApkOutputToTask(
    taskProvider: TaskProvider<TaskT>,
    taskInput: (TaskT) -> Property<ApkOutput>,
    deviceSpec: DeviceSpec
)

Add Variant's Apk Output for a specific device specification to a Task.

Public functions

provideApkOutputToTask

Added in 8.8.0
@Incubating
fun <TaskT : Task> provideApkOutputToTask(
    taskProvider: TaskProvider<TaskT>,
    taskInput: (TaskT) -> Property<ApkOutput>,
    deviceSpec: DeviceSpec
): Unit

Add Variant's Apk Output for a specific device specification to a Task. The Apk Output includes an ordered collection of batches of Apks to install on a device that matches the device specification available at the configuration time.

Parameters
taskProvider: TaskProvider<TaskT>

the TaskProvider returned by Gradle's Task manager when registering the Task of type TaskT.

taskInput: (TaskT) -> Property<ApkOutput>

The method reference the TaskT will use to retrieve the current artifact

deviceSpec: DeviceSpec

the device specification