# ScopedArtifactsOperation

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


```
interface ScopedArtifactsOperation<T : Task>
```

<br />

*** ** * ** ***

Defines all possible operations on a `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/artifact/ScopedArtifact` artifact type.

Depending on the scope, inputs may contain a mix of `https://docs.gradle.org/current/javadoc/org/gradle/api/file/FileCollection.html`, `https://docs.gradle.org/current/javadoc/org/gradle/api/file/RegularFile.html` or `https://docs.gradle.org/current/javadoc/org/gradle/api/file/Directory.html` so all `https://docs.gradle.org/current/javadoc/org/gradle/api/Task.html` consuming the current value of the artifact must provide two input fields that will contain the list of `https://docs.gradle.org/current/javadoc/org/gradle/api/file/RegularFile.html` and `https://docs.gradle.org/current/javadoc/org/gradle/api/file/Directory.html`.

## Summary

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `<ArtifactT : https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/artifact/ScopedArtifact & https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/artifact/Artifact.Appendable> https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/ScopedArtifactsOperation#toAppend(com.android.build.api.artifact.ScopedArtifact,kotlin.Function1)( to: ArtifactT, with: (T) -> https://docs.gradle.org/current/javadoc/org/gradle/api/provider/Property.html<https://docs.gradle.org/current/javadoc/org/gradle/api/file/FileSystemLocation.html> )` Append a new `https://docs.gradle.org/current/javadoc/org/gradle/api/file/FileSystemLocation.html` (basically, either a `https://docs.gradle.org/current/javadoc/org/gradle/api/file/Directory.html` or a `https://docs.gradle.org/current/javadoc/org/gradle/api/file/RegularFile.html`) to the artifact type referenced by `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/ScopedArtifactsOperation#toAppend(com.android.build.api.artifact.ScopedArtifact,kotlin.Function1)` |
| `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/ScopedArtifactsOperation#toGet(com.android.build.api.artifact.ScopedArtifact,kotlin.Function1,kotlin.Function1)( type: https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/artifact/ScopedArtifact, inputJars: (T) -> https://docs.gradle.org/current/javadoc/org/gradle/api/provider/ListProperty.html<https://docs.gradle.org/current/javadoc/org/gradle/api/file/RegularFile.html>, inputDirectories: (T) -> https://docs.gradle.org/current/javadoc/org/gradle/api/provider/ListProperty.html<https://docs.gradle.org/current/javadoc/org/gradle/api/file/Directory.html> )` Set the final version of the `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/ScopedArtifactsOperation#toGet(com.android.build.api.artifact.ScopedArtifact,kotlin.Function1,kotlin.Function1)` artifact to the input fields of the `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/ScopedArtifactsOperation`. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `<ArtifactT : https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/artifact/ScopedArtifact & https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/artifact/Artifact.Replaceable> https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/ScopedArtifactsOperation#toReplace(com.android.build.api.artifact.ScopedArtifact,kotlin.Function1)( type: ArtifactT, into: (T) -> https://docs.gradle.org/current/javadoc/org/gradle/api/file/RegularFileProperty.html )` Replace the current version of the `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/ScopedArtifactsOperation#toReplace(com.android.build.api.artifact.ScopedArtifact,kotlin.Function1)` artifact with a new version. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `<ArtifactT : https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/artifact/ScopedArtifact & https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/artifact/Artifact.Transformable> https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/ScopedArtifactsOperation#toTransform(com.android.build.api.artifact.ScopedArtifact,kotlin.Function1,kotlin.Function1,kotlin.Function1)( type: ArtifactT, inputJars: (T) -> https://docs.gradle.org/current/javadoc/org/gradle/api/provider/ListProperty.html<https://docs.gradle.org/current/javadoc/org/gradle/api/file/RegularFile.html>, inputDirectories: (T) -> https://docs.gradle.org/current/javadoc/org/gradle/api/provider/ListProperty.html<https://docs.gradle.org/current/javadoc/org/gradle/api/file/Directory.html>, into: (T) -> https://docs.gradle.org/current/javadoc/org/gradle/api/file/RegularFileProperty.html )` Transform the current version of the `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/ScopedArtifactsOperation#toTransform(com.android.build.api.artifact.ScopedArtifact,kotlin.Function1,kotlin.Function1,kotlin.Function1)` artifact into a new version. |

## Public functions

### toAppend

Added in 8.7.0

```
fun <ArtifactT : ScopedArtifact & Artifact.Appendable> toAppend(
    to: ArtifactT,
    with: (T) -> Property<FileSystemLocation>
): Unit
```

Append a new `https://docs.gradle.org/current/javadoc/org/gradle/api/file/FileSystemLocation.html` (basically, either a `https://docs.gradle.org/current/javadoc/org/gradle/api/file/Directory.html` or a `https://docs.gradle.org/current/javadoc/org/gradle/api/file/RegularFile.html`) to the artifact type referenced by `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/ScopedArtifactsOperation#toAppend(com.android.build.api.artifact.ScopedArtifact,kotlin.Function1)`

| Parameters |
|---|---|
| `to: ArtifactT` | the `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/artifact/ScopedArtifact` to add the `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/ScopedArtifactsOperation#toAppend(com.android.build.api.artifact.ScopedArtifact,kotlin.Function1)` to. |
| `with: (T) -> https://docs.gradle.org/current/javadoc/org/gradle/api/provider/Property.html<https://docs.gradle.org/current/javadoc/org/gradle/api/file/FileSystemLocation.html>` | lambda that returns the `https://docs.gradle.org/current/javadoc/org/gradle/api/provider/Property.html` used by the `https://docs.gradle.org/current/javadoc/org/gradle/api/Task.html` to save the appended element. The `https://docs.gradle.org/current/javadoc/org/gradle/api/provider/Property.html` value will be automatically set by the Android Gradle Plugin and its location should not be considered part of the API and can change in the future. |

### toGet

Added in 7.4.0

```
fun toGet(
    type: ScopedArtifact,
    inputJars: (T) -> ListProperty<RegularFile>,
    inputDirectories: (T) -> ListProperty<Directory>
): Unit
```

Set the final version of the `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/ScopedArtifactsOperation#toGet(com.android.build.api.artifact.ScopedArtifact,kotlin.Function1,kotlin.Function1)` artifact to the input fields of the `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/ScopedArtifactsOperation`. Those input fields should be annotated with `https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/InputFiles.html` for Gradle to property set the task dependency.

| Parameters |
|---|---|
| `type: https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/artifact/ScopedArtifact` | the `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/artifact/ScopedArtifact` to obtain the final value of. |
| `inputJars: (T) -> https://docs.gradle.org/current/javadoc/org/gradle/api/provider/ListProperty.html<https://docs.gradle.org/current/javadoc/org/gradle/api/file/RegularFile.html>` | lambda that returns a `https://docs.gradle.org/current/javadoc/org/gradle/api/provider/ListProperty.html` or `https://docs.gradle.org/current/javadoc/org/gradle/api/file/RegularFile.html` that will be used to set all incoming files for this artifact type. |
| `inputDirectories: (T) -> https://docs.gradle.org/current/javadoc/org/gradle/api/provider/ListProperty.html<https://docs.gradle.org/current/javadoc/org/gradle/api/file/Directory.html>` | lambda that returns a `https://docs.gradle.org/current/javadoc/org/gradle/api/provider/ListProperty.html` or `https://docs.gradle.org/current/javadoc/org/gradle/api/file/Directory.html` that will be used to set all incoming directories for this artifact type. |

### toReplace

```
fun <ArtifactT : ScopedArtifact & Artifact.Replaceable> toReplace(
    type: ArtifactT,
    into: (T) -> RegularFileProperty
): Unit
```

Replace the current version of the `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/ScopedArtifactsOperation#toReplace(com.android.build.api.artifact.ScopedArtifact,kotlin.Function1)` artifact with a new version.

The main difference with the `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/ScopedArtifactsOperation#toTransform(com.android.build.api.artifact.ScopedArtifact,kotlin.Function1,kotlin.Function1,kotlin.Function1)` method is that the previously set of producers of this `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/artifact/ScopedArtifact` will not be invoked.

The order in which the replace `https://docs.gradle.org/current/javadoc/org/gradle/api/Task.html`s are applied is directly set by the order of this method call. Last one wins and none of the previously set append/transform/replace registered `https://docs.gradle.org/current/javadoc/org/gradle/api/Task.html`s will be invoked since this `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/ScopedArtifactsOperation` replace the final version.

| Parameters |
|---|---|
| `type: ArtifactT` | the `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/artifact/ScopedArtifact` to replace. |
| `into: (T) -> https://docs.gradle.org/current/javadoc/org/gradle/api/file/RegularFileProperty.html` | lambda that returns the `https://docs.gradle.org/current/javadoc/org/gradle/api/provider/Property.html` used by the `https://docs.gradle.org/current/javadoc/org/gradle/api/Task.html` to save the replaced element. The `https://docs.gradle.org/current/javadoc/org/gradle/api/provider/Property.html` value will be automatically set by the Android Gradle Plugin and its location should not be considered part of the API and can change in the future. |

### toTransform

```
fun <ArtifactT : ScopedArtifact & Artifact.Transformable> toTransform(
    type: ArtifactT,
    inputJars: (T) -> ListProperty<RegularFile>,
    inputDirectories: (T) -> ListProperty<Directory>,
    into: (T) -> RegularFileProperty
): Unit
```

Transform the current version of the `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/ScopedArtifactsOperation#toTransform(com.android.build.api.artifact.ScopedArtifact,kotlin.Function1,kotlin.Function1,kotlin.Function1)` artifact into a new version. The order in which the transforms are applied is directly set by the order of this method call. First come, first served, last one provides the final version of the artifacts.

IMPORTANT: `https://docs.gradle.org/current/javadoc/org/gradle/api/Task.html` will transform many inputs into a single output. That means task must have merging logic as jars contain similar files and folders (like META-INF). Merging logic depends on transformation nature.

| Parameters |
|---|---|
| `type: ArtifactT` | the `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/artifact/ScopedArtifact` to transform. |
| `inputJars: (T) -> https://docs.gradle.org/current/javadoc/org/gradle/api/provider/ListProperty.html<https://docs.gradle.org/current/javadoc/org/gradle/api/file/RegularFile.html>` | lambda that returns a `https://docs.gradle.org/current/javadoc/org/gradle/api/provider/ListProperty.html` or `https://docs.gradle.org/current/javadoc/org/gradle/api/file/RegularFile.html` that will be used to set all incoming files for this artifact type. |
| `inputDirectories: (T) -> https://docs.gradle.org/current/javadoc/org/gradle/api/provider/ListProperty.html<https://docs.gradle.org/current/javadoc/org/gradle/api/file/Directory.html>` | lambda that returns a `https://docs.gradle.org/current/javadoc/org/gradle/api/provider/ListProperty.html` or `https://docs.gradle.org/current/javadoc/org/gradle/api/file/Directory.html` that will be used to set all incoming directories for this artifact type. |
| `into: (T) -> https://docs.gradle.org/current/javadoc/org/gradle/api/file/RegularFileProperty.html` | lambda that returns the `https://docs.gradle.org/current/javadoc/org/gradle/api/provider/Property.html` used by the `https://docs.gradle.org/current/javadoc/org/gradle/api/Task.html` to save the transformed element. The `https://docs.gradle.org/current/javadoc/org/gradle/api/provider/Property.html` value will be automatically set by the Android Gradle Plugin and its location should not be considered part of the API and can change in the future. |