api / org.gradle.kotlin.dsl / GroovyBuilderScope

GroovyBuilderScope

interface GroovyBuilderScope : GroovyObject

Provides a dynamic dispatching DSL with Groovy semantics for better integration with plugins that rely on Groovy builders such as the core maven plugin.

It supports Groovy keyword arguments and arbitrary nesting, for instance, the following Groovy code:

repository(url: "scp://repos.mycompany.com/releases") {
  authentication(userName: "me", password: "myPassword")
}

Can be mechanically translated to the following Kotlin with the aid of withGroovyBuilder:

withGroovyBuilder {
  "repository"("url" to "scp://repos.mycompany.com/releases") {
    "authentication"("userName" to "me", "password" to "myPassword")
  }
}

See Also

withGroovyBuilder

Properties

delegate

abstract val delegate: Any

Functions

invoke

abstract operator fun String.invoke(vararg arguments: Any?): Any?
open operator fun String.invoke(): Any?
open operator fun <T> String.invoke(vararg arguments: Any?, builder: GroovyBuilderScope.() -> T): Any?
open operator fun <T> String.invoke(builder: GroovyBuilderScope.() -> T): Any?
open operator fun <T> String.invoke(vararg keywordArguments: Pair<String, Any?>, builder: GroovyBuilderScope.() -> T): Any?
open operator fun String.invoke(vararg keywordArguments: Pair<String, Any?>): Any?

Companion Object Functions

of

fun of(value: Any): GroovyBuilderScope

Extension Functions

closureOf

fun <T> Any.closureOf(action: T.() -> Unit): Closure<Any?>

Adapts a Kotlin function to a single argument Groovy Closure.

delegateClosureOf

fun <T> Any.delegateClosureOf(action: T.() -> Unit): Closure<Unit>

Adapts a Kotlin function to a Groovy Closure that operates on the configured Closure delegate.

withConvention

fun <ConventionType : Any, ReturnType> Any.withConvention(conventionType: KClass<ConventionType>, function: ConventionType.() -> ReturnType): ReturnType

Evaluates the given function against the convention plugin of the given conventionType.

withGroovyBuilder

fun <T> Any.withGroovyBuilder(builder: GroovyBuilderScope.() -> T): T

Executes the given builder against this object's GroovyBuilderScope.