ScopedArtifactsOperation

Added in 7.4.1

interface ScopedArtifactsOperation<T : Task>


Defines all possible operations on a ScopedArtifact artifact type.

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

Summary

Public functions

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

Append a new FileSystemLocation (basically, either a Directory or a RegularFile) to the artifact type referenced by to

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

Set the final version of the type artifact to the input fields of the Task.

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

Replace the current version of the type artifact with a new version.

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

Transform the current version of the type artifact into a new version.

Public functions

toAppend

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

Append a new FileSystemLocation (basically, either a Directory or a RegularFile) to the artifact type referenced by to

Parameters
to: ArtifactT

the ScopedArtifact to add the with to.

with: (T) -> Property<FileSystemLocation>

lambda that returns the Property used by the Task to save the appended element. The Property 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.1
fun toGet(
    type: ScopedArtifact,
    inputJars: (T) -> ListProperty<RegularFile>,
    inputDirectories: (T) -> ListProperty<Directory>
): Unit

Set the final version of the type artifact to the input fields of the Task. Those input fields should be annotated with org.gradle.api.tasks.InputFiles for Gradle to property set the task dependency.

Parameters
type: ScopedArtifact

the ScopedArtifact to obtain the final value of.

inputJars: (T) -> ListProperty<RegularFile>

lambda that returns a ListProperty or RegularFile that will be used to set all incoming files for this artifact type.

inputDirectories: (T) -> ListProperty<Directory>

lambda that returns a ListProperty or Directory 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 type artifact with a new version.

The main difference with the toTransform method is that the previously set of producers of this ScopedArtifact will not be invoked.

The order in which the replace Tasks 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 Tasks will be invoked since this Task replace the final version.

Parameters
type: ArtifactT

the ScopedArtifact to replace.

into: (T) -> RegularFileProperty

lambda that returns the Property used by the Task to save the replaced element. The Property 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 type 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: Task 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 ScopedArtifact to transform.

inputJars: (T) -> ListProperty<RegularFile>

lambda that returns a ListProperty or RegularFile that will be used to set all incoming files for this artifact type.

inputDirectories: (T) -> ListProperty<Directory>

lambda that returns a ListProperty or Directory that will be used to set all incoming directories for this artifact type.

into: (T) -> RegularFileProperty

lambda that returns the Property used by the Task to save the transformed element. The Property 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.