BuiltArtifacts

Added in 4.2.0

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

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

Constants

const Int

Current version of the metadata file.

Public functions

Unit

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

Constants

METADATA_FILE_VERSION

Added in 4.2.0
const val METADATA_FILE_VERSION = 3: Int

Current version of the metadata file.

Public functions

save

Added in 4.2.0
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

Added in 4.2.0
val applicationIdString

Returns the application ID for these BuiltArtifact instances.

Returns
String

the application ID.

artifactType

Added in 4.2.0
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

Added in 4.2.0
val elementsCollection<BuiltArtifact>

Returns the Collection of BuiltArtifact.

variantName

Added in 4.2.0
val variantNameString

Identifies the variant name for these BuiltArtifact