# BuiltArtifacts

[View Source](https://cs.android.com/search?q=file:com/android/build/api/variant/BuiltArtifacts.kt+class:com.android.build.api.variant.BuiltArtifacts) Added in 4.2.0


```
interface BuiltArtifacts
```

<br />

*** ** * ** ***

Represents a `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-collection/index.html` of `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/BuiltArtifact` produced by a `https://docs.gradle.org/current/javadoc/org/gradle/api/Task.html`.

Tasks in Android Gradle Plugin can produce more than one file in the output folder so any `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/artifact/Artifact` with a `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/artifact/Artifact#kind()` of type `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/artifact/ArtifactKind.DIRECTORY` can actually contain several produced `https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/File.html`. 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 `https://docs.gradle.org/current/javadoc/org/gradle/api/Task.html`s 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() {
        
    :InputDirectory      abstract val input: DirectoryProperty

        
    :OutputDirectory      abstract val output: DirectoryProperty

        
    :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()))
    }
    ```

        `} `

<br />

This `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/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 |
|---|
| `interface https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/BuiltArtifacts.TransformParams : https://docs.gradle.org/current/javadoc/org/gradle/workers/WorkParameters.html, https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/Serializable.html` Specialized version of Gradle's `https://docs.gradle.org/current/javadoc/org/gradle/workers/WorkParameters.html` so we can retrieve the output file generated when transforming an instance of `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/BuiltArtifacts` into a new one. |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/BuiltArtifacts#METADATA_FILE_VERSION() = 3` Current version of the metadata file. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/BuiltArtifacts#save(org.gradle.api.file.Directory)(out: https://docs.gradle.org/current/javadoc/org/gradle/api/file/Directory.html)` Saves the metadata associated with this instance into a folder. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/BuiltArtifacts#applicationId()` Returns the application ID for these `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/BuiltArtifact` instances. |
| `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/artifact/Artifact<*>` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/BuiltArtifacts#artifactType()` Identifies the `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/artifact/Artifact` for this `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-collection/index.html` of `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/BuiltArtifact`, all `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/BuiltArtifact` are the same type of artifact. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-collection/index.html<https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/BuiltArtifact>` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/BuiltArtifacts#elements()` Returns the `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-collection/index.html` of `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/BuiltArtifact`. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/BuiltArtifacts#variantName()` Identifies the variant name for these `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/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: https://docs.gradle.org/current/javadoc/org/gradle/api/file/Directory.html` | the `https://docs.gradle.org/current/javadoc/org/gradle/api/file/Directory.html` that can be used to save the metadata using a standard file name. |

## Public properties

### applicationId

Added in 4.2.0

```
val applicationId: String
```

Returns the application ID for these `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/BuiltArtifact` instances.

| Returns |
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | the application ID. |

### artifactType

Added in 4.2.0

```
val artifactType: Artifact<*>
```

Identifies the `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/artifact/Artifact` for this `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-collection/index.html` of `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/BuiltArtifact`, all `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/BuiltArtifact` are the same type of artifact.

| Returns |
|---|---|
| `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/artifact/Artifact<*>` | the `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/artifact/Artifact` for all the `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/BuiltArtifact` instances. |

### elements

Added in 4.2.0

```
val elements: Collection<BuiltArtifact>
```

Returns the `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-collection/index.html` of `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/BuiltArtifact`.

### variantName

Added in 4.2.0

```
val variantName: String
```

Identifies the variant name for these `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/BuiltArtifact`