api / org.gradle.api / PolymorphicDomainObjectContainer

PolymorphicDomainObjectContainer

@Incubating interface PolymorphicDomainObjectContainer<T : Any> : NamedDomainObjectContainer<T>

A NamedDomainObjectContainer that allows to create domain objects with different types.

Parameters

- the (base) type of domain objects in the container

Functions

containerWithType

abstract fun <U : T> containerWithType(type: Class<U>): NamedDomainObjectContainer<U>

Creates a regular container that wraps the polymorphic container presenting all elements of a specified type.

create

abstract fun <U : T> create(name: String, type: Class<U>): U

Creates a domain object with the specified name and type, and adds it to the container.

abstract fun <U : T> create(name: String, type: Class<U>, configuration: Action<in U>): U

Creates a domain object with the specified name and type, adds it to the container, and configures it with the specified action.

maybeCreate

abstract fun <U : T> maybeCreate(name: String, type: Class<U>): U

Looks for an item with the given name and type, creating and adding it to this container if it does not exist.

Inherited Functions

configure

abstract fun configure(configureClosure: Closure<Any>): NamedDomainObjectContainer<T>

Allows the container to be configured, creating missing objects as they are referenced.

TODO: example usage

create

abstract fun create(name: String): T

Creates a new item with the given name, adding it to this container.

abstract fun create(name: String, configureClosure: Closure<Any>): T

Creates a new item with the given name, adding it to this container, then configuring it with the given closure.

abstract fun create(name: String, configureAction: Action<in T>): T

Creates a new item with the given name, adding it to this container, then configuring it with the given action.

maybeCreate

abstract fun maybeCreate(name: String): T

Looks for an item with the given name, creating and adding it to this container if it does not exist.

Extension Functions

create

fun <U : Any> PolymorphicDomainObjectContainer<in U>.create(name: String, configuration: U.() -> Unit): U

Creates a domain object with the specified name and type, adds it to the container, and configures it with the specified action.

fun <U : Any> PolymorphicDomainObjectContainer<in U>.create(name: String): U

Creates a domain object with the specified name and type, and adds it to the container.

creating

fun <T : Any, U : T> PolymorphicDomainObjectContainer<T>.creating(type: KClass<U>): PolymorphicDomainObjectContainerDelegateProvider<T, U>

Provides a property delegate that creates elements of the given type.

fun <T : Any, U : T> PolymorphicDomainObjectContainer<T>.creating(type: KClass<U>, configuration: U.() -> Unit): PolymorphicDomainObjectContainerDelegateProvider<T, U>

Provides a property delegate that creates elements of the given type with the given configuration.

fun <T : Any, U : T> PolymorphicDomainObjectContainer<T>.creating(type: Class<U>, configuration: U.() -> Unit): PolymorphicDomainObjectContainerDelegateProvider<T, U>

Provides a property delegate that creates elements of the given type expressed as a java.lang.Class with the given configuration.

maybeCreate

fun <U : Any> PolymorphicDomainObjectContainer<in U>.maybeCreate(name: String): U

Creates a domain object with the specified name and type if it does not exists, and adds it to the container.

Inheritors

AuthenticationContainer

interface AuthenticationContainer : PolymorphicDomainObjectContainer<Authentication>

Container for configuring repository authentication schemes of type org.gradle.authentication.Authentication.

ExtensiblePolymorphicDomainObjectContainer

interface ExtensiblePolymorphicDomainObjectContainer<T : Any> : PolymorphicDomainObjectContainer<T>, NamedDomainObjectFactoryRegistry

A org.gradle.api.PolymorphicDomainObjectContainer that can be extended at runtime to create elements of new types.

NamedDomainObjectContainerScope

class NamedDomainObjectContainerScope<T : Any> : NamedDomainObjectContainer<T>, PolymorphicDomainObjectContainer<T>

Receiver for NamedDomainObjectContainer configuration blocks.

PlayDistributionContainer

interface PlayDistributionContainer : PolymorphicDomainObjectContainer<Distribution>

Manages a set of org.gradle.api.distribution.Distribution objects.

Repositories

interface Repositories : PolymorphicDomainObjectContainer<ArtifactRepository>

The repositories that Gradle will search for prebuilt libraries.

TaskContainer

interface TaskContainer : TaskCollection<Task>, PolymorphicDomainObjectContainer<Task>

A TaskContainer is responsible for managing a set of Task instances.

You can obtain a TaskContainer instance by calling org.gradle.api.Project#getTasks(), or using the tasks property in your build script.