# KotlinInitScript

abstract class KotlinInitScript(host: KotlinScriptHost<Gradle>) : InitScriptApi

### Deprecated

Will be removed in Gradle 10

Legacy base class for Gradle Kotlin DSL standalone Gradle scripts IDE support, aka. init scripts.

#### See also

KotlinGradleScriptTemplate

## Constructors

KotlinInitScript
Link copied to clipboard
constructor(host: KotlinScriptHost<Gradle>)

## Properties

delegate
Link copied to clipboard
open val delegate: Gradle
extra
Link copied to clipboard
val ExtensionAware.extra: ExtraPropertiesExtension

The extra properties extension in this object's extension container.

initscript
Link copied to clipboard
val initscript: ScriptHandler

The ScriptHandler for this script.

logger
Link copied to clipboard
val logger: Logger

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

logging
Link copied to clipboard
val logging: <Error class: unknown 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.

resources
Link copied to clipboard
val resources: ResourceHandler

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

## Functions

addBuildListener
Link copied to clipboard
open override fun addBuildListener(buildListener: BuildListener)
addListener
Link copied to clipboard
open override fun addListener(listener: Any)
addProjectEvaluationListener
Link copied to clipboard
open override fun addProjectEvaluationListener(listener: ProjectEvaluationListener): ProjectEvaluationListener
afterProject
Link copied to clipboard
open override fun afterProject(closure: Closure<Any>)
open override fun afterProject(action: Action<in Project>)
allprojects
Link copied to clipboard
open override fun allprojects(action: Action<in Project>)
apply
Link copied to clipboard
open override fun apply(action: Action<in ObjectConfigurationAction>)

Applies zero or more plugins or scripts.

open override fun apply(closure: Closure<Any>)
open override fun apply(options: Map<String, *>)
apply
Link copied to clipboard
inline fun <T : Plugin<Gradle>> Gradle.apply()
inline fun <T : Plugin<*>> PluginAware.apply()

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

inline fun PluginAware.apply(vararg options: Pair<String, Any>)

Kotlin extension function for org.gradle.api.plugins.PluginAware.apply.

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

Applies the given plugin or script.

applyTo
Link copied to clipboard
inline fun <T : Plugin<*>> PluginAware.applyTo(vararg targets: Any)

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

beforeProject
Link copied to clipboard
open override fun beforeProject(closure: Closure<Any>)
open override fun beforeProject(action: Action<in Project>)
beforeSettings
Link copied to clipboard
open override fun beforeSettings(closure: Closure<*>)
open override fun beforeSettings(action: Action<in Settings>)
buildFinished
Link copied to clipboard
open override fun buildFinished(closure: Closure<Any>)
open override fun buildFinished(action: Action<in BuildResult>)
configure
Link copied to clipboard
inline fun <T : Any> ExtensionAware.configure(noinline configuration: T.() -> Unit)

Executes the given configuration block against the extension of the specified type.

copy
Link copied to clipboard
fun copy(configuration: CopySpec.() -> Unit): WorkResult

Copies the specified files.

copySpec
Link copied to clipboard
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
Link copied to clipboard
fun delete(vararg paths: Any): Boolean

Deletes files and directories.

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

Deletes the specified files.

file
Link copied to clipboard
fun file(path: Any): File
fun file(path: Any, validation: PathValidation): File

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

files
Link copied to clipboard
fun files(vararg paths: Any): ConfigurableFileCollection
fun files(paths: Any, configuration: ConfigurableFileCollection.() -> Unit): ConfigurableFileCollection

Creates a ConfigurableFileCollection containing the given files.

fileTree
Link copied to clipboard
fun fileTree(baseDir: Any): ConfigurableFileTree
fun fileTree(baseDir: Any, configuration: ConfigurableFileTree.() -> Unit): ConfigurableFileTree

Creates a new ConfigurableFileTree using the given base directory.

getBuildPath
Link copied to clipboard
open override fun getBuildPath(): String
getExtensions
Link copied to clipboard
open override fun getExtensions(): ExtensionContainer
getGradle
Link copied to clipboard
open override fun getGradle(): Gradle
getGradleHomeDir
Link copied to clipboard
open override fun getGradleHomeDir(): File?
getGradleUserHomeDir
Link copied to clipboard
open override fun getGradleUserHomeDir(): File
getGradleVersion
Link copied to clipboard
open override fun getGradleVersion(): String
getIncludedBuilds
Link copied to clipboard
open override fun getIncludedBuilds(): MutableCollection<IncludedBuild>
getLifecycle
Link copied to clipboard
open override fun getLifecycle(): GradleLifecycle
getParent
Link copied to clipboard
open override fun getParent(): Gradle?
getPluginManager
Link copied to clipboard
open override fun getPluginManager(): PluginManager
getPlugins
Link copied to clipboard
open override fun getPlugins(): PluginContainer
getRootProject
Link copied to clipboard
open override fun getRootProject(): Project
getSharedServices
Link copied to clipboard
open override fun getSharedServices(): BuildServiceRegistry
getStartParameter
Link copied to clipboard
open override fun getStartParameter(): StartParameter
getTaskGraph
Link copied to clipboard
open override fun getTaskGraph(): TaskExecutionGraph
includedBuild
Link copied to clipboard
open override fun includedBuild(name: String): IncludedBuild
initscript
Link copied to clipboard
open fun initscript(block: ScriptHandlerScope.() -> Unit)

Configures the classpath of the init script.

mkdir
Link copied to clipboard
fun mkdir(path: Any): File

Creates a directory and returns a file pointing to it.

projectsEvaluated
Link copied to clipboard
open override fun projectsEvaluated(closure: Closure<Any>)
open override fun projectsEvaluated(action: Action<in Gradle>)
projectsLoaded
Link copied to clipboard
open override fun projectsLoaded(closure: Closure<Any>)
open override fun projectsLoaded(action: Action<in Gradle>)
relativePath
Link copied to clipboard
fun relativePath(path: Any): String

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

removeListener
Link copied to clipboard
open override fun removeListener(listener: Any)
removeProjectEvaluationListener
Link copied to clipboard
open override fun removeProjectEvaluationListener(listener: ProjectEvaluationListener)
rootProject
Link copied to clipboard
open override fun rootProject(action: Action<in Project>)
settingsEvaluated
Link copied to clipboard
open override fun settingsEvaluated(closure: Closure<Any>)
open override fun settingsEvaluated(action: Action<in Settings>)
tarTree
Link copied to clipboard
fun tarTree(tarPath: Any): FileTree

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

the
Link copied to clipboard
inline fun <T : Any> ExtensionAware.the(): T

Returns the extension of the specified type.

fun <T : Any> ExtensionAware.the(extensionType: KClass<T>): T

Returns the extension of the specified extensionType.

uri
Link copied to clipboard
fun uri(path: Any): URI

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

useLogger
Link copied to clipboard
open override fun useLogger(logger: Any)
zipTree
Link copied to clipboard
fun zipTree(zipPath: Any): FileTree

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