在 gradle 的 kotlin 构建脚本中,我们不需要在构建脚本build.gradle.ktsplugins
中显式导入类repositories
或函数。dependencies
plugins {
val kotlinVersion = "1.3.10"
val springBootVersion = "2.1.0.RELEASE"
val detektVersion = "1.0.0-RC10"
id("org.springframework.boot") version springBootVersion
id("org.jetbrains.kotlin.jvm") version kotlinVersion
id("org.jetbrains.kotlin.plugin.spring") version kotlinVersion
id("io.spring.dependency-management") version "1.0.6.RELEASE"
id("io.gitlab.arturbosch.detekt") version detektVersion
}
repositories {
mavenLocal()
mavenCentral()
maven(url = uri("https://dl.bintray.com/s1m0nw1/KtsRunner"))
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-script-runtime")
implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable")
implementation("org.jetbrains.kotlin:kotlin-script-util")
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("cn.pilipa:pilipa-spring-boot-starter-logging:2.0.10")
implementation("de.swirtz:ktsRunner:0.0.5")
testImplementation("org.springframework.boot:spring-boot-starter-test"){
exclude(module = "junit")
}
testImplementation("io.projectreactor:reactor-test")
testImplementation("org.springframework.cloud:spring-cloud-stream-test-support")
testImplementation("org.junit.jupiter:junit-jupiter-api")
testRuntime("org.junit.jupiter:junit-jupiter-engine")
testCompile("io.kotlintest:kotlintest-runner-junit5:${kotlinTestVersion}")
testCompile("io.kotlintest:kotlintest-extensions-spring:${kotlinTestVersion}")
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:${detektVersion}")
}
如何在自定义 kotlin-dsl 脚本中实现此类似功能以在 kotlin-dsl 脚本中隐式导入类?