api / org.gradle.language / BinaryCollection

BinaryCollection

@Incubating interface BinaryCollection<T : SoftwareComponent>

A collection of binaries that are created and configured as they are required.

Each element in this collection passes through several states. The element is created and becomes 'known'. The element is passed to any actions registered using #whenElementKnown(Action). The element is then configured using any actions registered using #configureEach(Action) and becomes 'finalized'. The element is passed to any actions registered using #whenElementFinalized(Action). Elements are created and configured only when required.

Parameters

- type of the elements in this container.

Since
4.5

Functions

configureEach

abstract fun configureEach(action: Action<in T>): Unit

Registers an action to execute to configure each element in the collection. The action is only executed for those elements that are required. Fails if any element has already been finalized.

abstract fun <S : Any> configureEach(type: Class<S>, action: Action<in S>): Unit

Registers an action to execute to configure each element of the given type in the collection. The action is only executed for those elements that are required. Fails if any matching element has already been finalized.

get

abstract fun <S : Any> get(type: Class<S>, spec: Spec<in S>): BinaryProvider<S>

Returns a BinaryProvider that contains the single binary matching the specified type and specification. The binary will be in the finalized state. The provider can be used to apply configuration to the element before it is finalized.

Querying the return value will fail when there is not exactly one matching binary.

abstract fun get(spec: Spec<in T>): BinaryProvider<T>

Returns a Provider that contains the single binary matching the given specification. The binary will be in the finalized state. The provider can be used to apply configuration to the element before it is finalized.

Querying the return value will fail when there is not exactly one matching binary.

abstract fun get(): MutableSet<T>

Returns the set of binaries from this collection. Elements are in a finalized state.

getByName

abstract fun getByName(name: String): BinaryProvider<T>

Returns a BinaryProvider that contains the single binary with the given name. The binary will be in the finalized state. The provider can be used to apply configuration to the element before it is finalized.

Querying the return value will fail when there is not exactly one matching binary.

whenElementFinalized

abstract fun whenElementFinalized(action: Action<in T>): Unit

Registers an action to execute when an element is finalized. The action is only executed for those elements that are required. Fails if any element has already been finalized.

abstract fun <S : Any> whenElementFinalized(type: Class<S>, action: Action<in S>): Unit

Registers an action to execute when an element of the given type is finalized. The action is only executed for those elements that are required. Fails if any matching element has already been finalized.

whenElementKnown

abstract fun whenElementKnown(action: Action<in T>): Unit

Registers an action to execute when an element becomes known. The action is only executed for those elements that are required. Fails if any element has already been finalized.

abstract fun <S : Any> whenElementKnown(type: Class<S>, action: Action<in S>): Unit

Registers an action to execute when an element of the given type becomes known. The action is only executed for those elements that are required. Fails if any matching element has already been finalized.