api / org.gradle.api / PolymorphicDomainObjectContainer / maybeCreate

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.

Parameters

name - the name of the domain object to be created

type - the type of the domain object to be created

- the type of the domain object to be created

Exceptions

InvalidUserDataException - if 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

Return
the found or created domain object, never null.