'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):
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.
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??
Solution 1:[1]
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. 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.
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.
And for a more simple example I'd also check out the example posted by the Kotlin organisation on Converting to Kotlin DSL.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Matthew D'Agostino |
