[英]convert kotlin dsl gradle to groovy build.gradle
I created a springboot app in Kotlin&gradle with the initialiser but the auto-generated build.gradle file is in kotlin with the extension build.gralde.kts
(see content below):我使用初始化程序在 Kotlin&gradle 中创建了一个 springboot 应用程序,但自动生成的 build.gradle 文件位于 kotlin 中,扩展名为
build.gralde.kts
(请参阅下面的内容):
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "2.5.0"
id("io.spring.dependency-management") version "1.0.11.RELEASE"
kotlin("jvm") version "1.5.10"
kotlin("plugin.spring") version "1.5.10"
}
group = "com.example"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_1_8
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "1.8"
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
I want the project to be in Kotlin but the gradle file to be in build.gradle
as per old java applications.我希望项目位于 Kotlin 中,但 gradle 文件位于
build.gradle
中,按照旧的 Z93F725A07423FE1C8486Z4 应用程序。
Please tell me how to generate a kotlin springboot app with a normal build.gradle
file or how to covert the generated build.gradle.kts
into build.gradle
?? Please tell me how to generate a kotlin springboot app with a normal
build.gradle
file or how to covert the generated build.gradle.kts
into build.gradle
??
At the moment I dont think there is any method to generate a Kotlin SpringBoot application with a build.gradle
that is using the groovy DSL.目前,我认为没有任何方法可以使用 groovy DSL 的
build.gradle
生成 Kotlin SpringBoot 应用程序。 Your best bet will be to convert the gradle file manually, which can take a little time but is pretty easy once you understand/get the hang of it.您最好的选择是手动转换 gradle 文件,这可能需要一些时间,但一旦您理解/掌握了它就很容易了。
I'd reccomend checking out the Gradle Groovy to Kotlin Conversion guide made by the Gradle organisation and just do the opposite to all the conversions listed.我建议查看Gradle Groovy 到 Kotlin 转换指南由 Z7B5CC4FB56E173C7520F716 组织制作的转换指南。
And for a more simple example I'd also check out the example posted by the Kotlin organisation on Converting to Kotlin DSL.对于更简单的示例,我还将查看 Kotlin 组织发布的关于转换为 Kotlin DSL 的示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.