Added in API level 4.1

Artifacts

@Incubating interface Artifacts
com.android.build.api.artifact.Artifacts

Access to the artifacts on a Variant object.

Artifacts are temporary or final files or directories that are produced by the Android Gradle plugin during the build. Depending on its configuration, each com.android.build.api.variant.VariantBuilder produces different versions of some of the output artifacts.

An example of temporary artifacts are .class files obtained from compiling source files that will eventually get transformed further into dex files. Final artifacts are APKs and bundle files that are not transformed further.

Artifacts are uniquely defined by their Artifact type and public artifact types that can be accessed from third-party plugins or build script are defined in ArtifactType

Summary

Public methods

abstract Provider<FileTypeT>
get(type: ArtifactType<FileTypeT>)

Get the Provider of FileTypeT for the passed Artifact.

abstract Provider<List<FileTypeT>>
getAll(type: MultipleArtifactType<FileTypeT>)

Get all the Providers of FileTypeT for the passed Artifact.

abstract BuiltArtifactsLoader

Provides an implementation of BuiltArtifactsLoader that can be used to load built artifacts metadata.

abstract TaskBasedOperation<TaskT>
use(taskProvider: TaskProvider<TaskT>)

Access Task based operations.

Public methods

get

abstract fun <FileTypeT : FileSystemLocation> get(type: ArtifactType<FileTypeT>): Provider<FileTypeT>

Get the Provider of FileTypeT for the passed Artifact.

Parameters
type: ArtifactType<FileTypeT> Type of the single artifact.

getAll

abstract fun <FileTypeT : FileSystemLocation> getAll(type: MultipleArtifactType<FileTypeT>): Provider<List<FileTypeT>>

Get all the Providers of FileTypeT for the passed Artifact.

Parameters
type: MultipleArtifactType<FileTypeT> Type of the multiple artifact.

getBuiltArtifactsLoader

abstract fun getBuiltArtifactsLoader(): BuiltArtifactsLoader

Provides an implementation of BuiltArtifactsLoader that can be used to load built artifacts metadata.

Return
A thread safe implementation of BuiltArtifactsLoader that can be reused.

use

abstract fun <TaskT : Task> use(taskProvider: TaskProvider<TaskT>): TaskBasedOperation<TaskT>

Access Task based operations.

Parameters
taskProvider: TaskProvider<TaskT> The TaskProvider for the TaskT that will be producing and/or consuming artifact types.
Return
A TaskBasedOperation object using the passed TaskProvider for all its operations.