newInstance

abstract fun <T> newInstance(type: Class<out T>, parameters: Array<Any>): T(source)

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

The type must be non-final, and can be a class, abstract class or interface.

Objects created using this method are decorated and extensible, meaning that they have DSL support mixed in and can be extended using the `extensions` property, similar to the org.gradle.api.Project object.

An @Inject annotation is required on any constructor that accepts parameters because JSR-330 semantics for dependency injection are used. In addition to those parameters provided as an argument to this method, the following services are also available for injection:

Since

4.2

Throws

On failure to create the new instance.