api / org.gradle.kotlin.dsl / org.gradle.api.PolymorphicDomainObjectContainer / maybeCreate

maybeCreate

inline fun <reified 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.

Parameters

name - the name of the domain object to be created

Exceptions

InvalidUserDataException - if a domain object with the specified name already exists or the container does not support creating a domain object with the specified type

ClassCastException - if a domain object with the specified name exists with a different type

Parameters

Return
the created domain object