api / org.gradle.kotlin.dsl / InitScriptApi

InitScriptApi

abstract class InitScriptApi : Gradle

Standard implementation of the API exposed to all types of Gradle scripts, precompiled and otherwise.

Constructors

<init>

InitScriptApi(target: Gradle)

Standard implementation of the API exposed to all types of Gradle scripts, precompiled and otherwise.

Properties

logger

val logger: Logger

Logger for init scripts. You can use this in your init script to write log messages.

logging

val logging: <ERROR CLASS>

The LoggingManager which can be used to receive logging and to control the standard output/error capture for this script. By default, System.out is redirected to the Gradle logging system at the QUIET log level, and System.err is redirected at the ERROR log level.

operations

abstract val operations: <ERROR CLASS>

resources

val resources: ResourceHandler

Provides access to resource-specific utility methods, for example factory methods that create various resources.

Functions

copy

fun copy(configuration: CopySpec.() -> Unit): WorkResult

Copies the specified files.

copySpec

fun copySpec(): CopySpec
fun copySpec(configuration: CopySpec.() -> Unit): CopySpec

Creates a {@link CopySpec} which can later be used to copy files or create an archive.

delete

fun delete(vararg paths: Any): Boolean

Deletes files and directories.

fun delete(configuration: DeleteSpec.() -> Unit): WorkResult

Deletes the specified files.

exec

fun exec(configuration: ExecSpec.() -> Unit): ExecResult

Executes an external command.

file

fun file(path: Any): File
fun file(path: Any, validation: PathValidation): File

Resolves a file path relative to this script's target base directory.

fileTree

fun fileTree(baseDir: Any): ConfigurableFileTree
fun fileTree(baseDir: Any, configuration: ConfigurableFileTree.() -> Unit): ConfigurableFileTree

Creates a new ConfigurableFileTree using the given base directory.

files

fun files(vararg paths: Any): ConfigurableFileCollection
fun files(paths: Any, configuration: ConfigurableFileCollection.() -> Unit): ConfigurableFileCollection

Creates a ConfigurableFileCollection containing the given files.

initscript

open fun initscript(block: ScriptHandlerScope.() -> Unit): Unit

Configures the classpath of the init script.

javaexec

fun javaexec(configuration: JavaExecSpec.() -> Unit): ExecResult

Executes an external Java process.

mkdir

fun mkdir(path: Any): File

Creates a directory and returns a file pointing to it.

relativePath

fun relativePath(path: Any): String

Returns the relative path from this script's target base directory to the given path.

tarTree

fun tarTree(tarPath: Any): FileTree

Creates a new FileTree which contains the contents of the given TAR file.

uri

fun uri(path: Any): URI

Resolves a file path to a URI, relative to this script's target base directory.

zipTree

fun zipTree(zipPath: Any): FileTree

Creates a new FileTree which contains the contents of the given ZIP file.

Extension Functions

apply

fun PluginAware.apply(from: Any? = null, plugin: String? = null, to: Any? = null): Unit

Applies the given plugin or script.

fun <T : Plugin<*>> PluginAware.apply(to: Any): Unit

Applies the plugin of the given type T to the specified object. Does nothing if the plugin has already been applied.

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.

Inheritors

KotlinInitScript

abstract class KotlinInitScript : InitScriptApi

Base class for Kotlin init scripts.