BuiltArtifacts

interface BuiltArtifacts


Represents a Collection of BuiltArtifact produced by a org.gradle.api.Task.

Tasks in Android Gradle Plugin can produce more than one file in the output folder so any Artifact with a Artifact.kind of type com.android.build.api.artifact.ArtifactKind.DIRECTORY can actually contain several produced File. For instance, when dealing with multi-apk, there will be several manifest files or APKs produced by the Android Gradle Plugin.

Each produced file can be identified with unique metadata like the list of filters and/or version code or version name. This instance will allow producer and consumer org.gradle.api.Tasks to easily match produced files with this metadata without relying on name mangling or other custom solutions.

Simple use of this facility can look like :


abstract class MyTask @inject constructor(val objectFactory: ObjectFactory): DefaultTask() {
    @get:InputDirectory
    abstract val input: DirectoryProperty
    @get:OutputDirectory
    abstract val output: DirectoryProperty
    @get:Internal
    abstract val artifactsLoader: Property

    @TaskAction
    fun taskAction() {
         val builtArtifacts= artifactsLoader.get().load(
              objectFactory, input.get())

         TODO : TBD what will be surfaced here

         newBuiltArtifacts.save(output.get()))
    }
}

This BuiltArtifacts will abstract access to these produced files and provided some metadata associated with each file to be able to identify filters, version code or version name.

Summary

Nested types

BuiltArtifacts.Companion
BuiltArtifacts.TransformParams

Specialized version of Gradle's WorkParameters so we can retrieve the output file generated when transforming an instance of BuiltArtifacts into a new one.

Public functions

Unit
save(out: Directory?)

Saves the metadata associated with this instance into a folder.

Public properties

String

Returns the application ID for these BuiltArtifact instances.

Artifact<*>

Identifies the Artifact for this Collection of BuiltArtifact, all BuiltArtifact are the same type of artifact.

Collection<BuiltArtifact>

Returns the Collection of BuiltArtifact.

String

Identifies the variant name for these BuiltArtifact

Public functions

save

fun save(out: Directory?): Unit

Saves the metadata associated with this instance into a folder.

Parameters
out: Directory?

the Directory that can be used to save the metadata using a standard file name.

Public properties

applicationId

val applicationIdString

Returns the application ID for these BuiltArtifact instances.

Returns
String

the application ID.

artifactType

val artifactTypeArtifact<*>

Identifies the Artifact for this Collection of BuiltArtifact, all BuiltArtifact are the same type of artifact.

Returns
Artifact<*>

the Artifact for all the BuiltArtifact instances.

elements

val elementsCollection<BuiltArtifact>

Returns the Collection of BuiltArtifact.

variantName

val variantNameString

Identifies the variant name for these BuiltArtifact