NodeJsToolchainManagementDsl

DSL for selecting and configuring the NodeJsToolchainService used by the whole build, exposed as toolchainManagement { nodeJs { ... } } in settings.gradle.kts by the org.jetbrains.kotlin.ecosystem plugin.

At most one of toolchainService or disable may be called - the NodeJsToolchainService is registered as a shared org.gradle.api.services.BuildService right away, under the same name every Kotlin Gradle Plugin project looks up when it registers the toolchain service for itself, so calling this more than once would silently keep only the first registration.

kotlin {
toolchainManagement {
nodeJs {
toolchainService(MyNodeJsToolchainService::class) { //specify a service class is optional, DefaultNodeJsToolchainService will be used by default
}
toolchainService(DefaultNodeJsToolchainService::class) {
downloadBaseUrl("custom-url") //official node js website will be used by default
installationDir("custom location") //default <user.home>/.kotlin/toolchains/nodejs location will be used by default
}
toolchainService(PreInstalledNodeJsToolchainService::class) {
nodeJsExecutable("path_to_node_js_executable") //"node" will be used by default
}
}
}
}

Note: This interface is not intended for implementation by build script or plugin authors.

Functions

Link copied to clipboard
open fun disable()

Disables Node.js provisioning for the whole build - tasks that need a Node.js executable will fail.

Link copied to clipboard

Configures the built-in, download-based DefaultNodeJsToolchainService.

abstract fun <P : NodeJsToolchainService.Parameters, T : NodeJsToolchainService<P>> toolchainService(serviceClass: KClass<T>, configure: P.() -> Unit)

Selects serviceClass as the NodeJsToolchainService used by the whole build, and configures its parameters.

open fun <P : NodeJsToolchainService.Parameters, T : NodeJsToolchainService<P>> toolchainService(serviceClass: KClass<T>, configure: Action<P>)

Action based version of toolchainService above.