# ObjectFactory

@ServiceScope(value = [Global::class, BuildTree::class, Project::class])
interface ObjectFactory(source)

A factory for creating various kinds of model objects.

An instance of the factory can be injected into a task, plugin or other object by annotating a public constructor or property getter method with `javax.inject.Inject`. It is also available via getObjects.

#### Since

4.0

## Functions

directoryProperty
Link copied to clipboard
abstract fun directoryProperty(): DirectoryProperty
Creates a new DirectoryProperty that uses the project directory to resolve relative paths, if required.
domainObjectContainer
Link copied to clipboard
abstract fun <T> domainObjectContainer(elementType: Class<T>): NamedDomainObjectContainer<T>
abstract fun <T> domainObjectContainer(elementType: Class<T>, factory: NamedDomainObjectFactory<T>): NamedDomainObjectContainer<T>
Creates a new NamedDomainObjectContainer for managing named objects of the specified type.
domainObjectContainer
Link copied to clipboard
inline fun <T : Any> ObjectFactory. domainObjectContainer(elementType: KClass<T>): NamedDomainObjectContainer<T>
inline fun <T : Any> ObjectFactory. domainObjectContainer(elementType: KClass<T>, factory: NamedDomainObjectFactory<T>): NamedDomainObjectContainer<T>

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.model.ObjectFactory.domainObjectContainer.

domainObjectSet
Link copied to clipboard
abstract fun <T> domainObjectSet(elementType: Class<T>): DomainObjectSet<T>
Creates a new DomainObjectSet for managing objects of the specified type.
domainObjectSet
Link copied to clipboard
inline fun <T : Any> ObjectFactory. domainObjectSet(elementType: KClass<T>): DomainObjectSet<T>

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.model.ObjectFactory.domainObjectSet.

fileCollection
Link copied to clipboard
abstract fun fileCollection(): ConfigurableFileCollection
Creates a new ConfigurableFileCollection.
fileProperty
Link copied to clipboard
abstract fun fileProperty(): RegularFileProperty
Creates a new RegularFileProperty that uses the project directory to resolve relative paths, if required.
fileTree
Link copied to clipboard
abstract fun fileTree(): ConfigurableFileTree
Creates a new ConfigurableFileTree.
listProperty
Link copied to clipboard
abstract fun <T> listProperty(elementType: Class<T>): ListProperty<T>
Creates a ListProperty implementation to hold a List of the given element type `T`.
listProperty
Link copied to clipboard
inline fun <T : Any> ObjectFactory. listProperty(): ListProperty<T>

Creates a ListProperty that holds values of the given type T.

inline fun <T : Any> ObjectFactory. listProperty(elementType: KClass<T>): ListProperty<T>

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.model.ObjectFactory.listProperty.

mapProperty
Link copied to clipboard
abstract fun <K, V> mapProperty(keyType: Class<K>, valueType: Class<V>): MapProperty<K, V>
Creates a MapProperty implementation to hold a Map of the given key type `K` and value type `V`.
mapProperty
Link copied to clipboard
inline fun <K : Any, V : Any> ObjectFactory. mapProperty(): MapProperty<K, V>

Creates a MapProperty that holds values of the given key type K and value type V.

inline fun <K : Any, V : Any> ObjectFactory. mapProperty(keyType: KClass<K>, valueType: KClass<V>): MapProperty<K, V>

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.model.ObjectFactory.mapProperty.

named
Link copied to clipboard
abstract fun <T : Named?> named(type: Class<T>, name: String): T
Creates a simple immutable Named object of the given type and name.
named
Link copied to clipboard
inline fun <T : Named> ObjectFactory. named(name: String): T

Creates a simple immutable Named object of the given type and name.

inline fun <T : Named> ObjectFactory. named(type: KClass<T>, name: String): T

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.model.ObjectFactory.named.

namedDomainObjectList
Link copied to clipboard
abstract fun <T> namedDomainObjectList(elementType: Class<T>): NamedDomainObjectList<T>
Creates a new NamedDomainObjectList for managing named objects of the specified type.
namedDomainObjectList
Link copied to clipboard
inline fun <T : Any> ObjectFactory. namedDomainObjectList(elementType: KClass<T>): NamedDomainObjectList<T>

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.model.ObjectFactory.namedDomainObjectList.

namedDomainObjectSet
Link copied to clipboard
abstract fun <T> namedDomainObjectSet(elementType: Class<T>): NamedDomainObjectSet<T>
Creates a new NamedDomainObjectSet for managing named objects of the specified type.
namedDomainObjectSet
Link copied to clipboard
inline fun <T : Any> ObjectFactory. namedDomainObjectSet(elementType: KClass<T>): NamedDomainObjectSet<T>

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.model.ObjectFactory.namedDomainObjectSet.

newInstance
Link copied to clipboard
abstract fun <T> newInstance(type: Class<out T>, parameters: Array<Any>): T
Create a new instance of T, using `parameters` as the construction parameters.
newInstance
Link copied to clipboard
inline fun <T : Any> ObjectFactory. newInstance(vararg parameters: Any): T

Create a new instance of `T`, using parameters as the construction parameters.

inline fun <T : Any> ObjectFactory. newInstance(type: KClass<out T>, vararg parameters: Any): T

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.model.ObjectFactory.newInstance.

polymorphicDomainObjectContainer
Link copied to clipboard
abstract fun <T> polymorphicDomainObjectContainer(elementType: Class<T>): ExtensiblePolymorphicDomainObjectContainer<T>
Creates a new ExtensiblePolymorphicDomainObjectContainer for managing named objects of the specified type.
polymorphicDomainObjectContainer
Link copied to clipboard
inline fun <T : Any> ObjectFactory. polymorphicDomainObjectContainer(elementType: KClass<T>): ExtensiblePolymorphicDomainObjectContainer<T>

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.model.ObjectFactory.polymorphicDomainObjectContainer.

property
Link copied to clipboard
abstract fun <T> property(valueType: Class<T>): Property<T>
Creates a Property implementation to hold values of the given type.
property
Link copied to clipboard
inline fun <T : Any> ObjectFactory. property(): Property<T>

Creates a Property that holds values of the given type T.

inline fun <T : Any> ObjectFactory. property(valueType: KClass<T>): Property<T>

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.model.ObjectFactory.property.

setProperty
Link copied to clipboard
abstract fun <T> setProperty(elementType: Class<T>): SetProperty<T>
Creates a SetProperty implementation to hold a Set of the given element type `T`.
setProperty
Link copied to clipboard
inline fun <T : Any> ObjectFactory. setProperty(): SetProperty<T>

Creates a SetProperty that holds values of the given type T.

inline fun <T : Any> ObjectFactory. setProperty(elementType: KClass<T>): SetProperty<T>

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.model.ObjectFactory.setProperty.

sourceDirectorySet
Link copied to clipboard
abstract fun sourceDirectorySet(name: String, displayName: String): SourceDirectorySet
Creates a SourceDirectorySet.