说明
默认使用 https://start.spring.io/ 创建项目时,默认使用的是gradle.ks
脚本,个人不太喜欢这个脚本,只能将脚本转换回以前的样子。
这个算是一个记事本帖子
build.gradle
buildscript {
ext {
springBootVersion = "2.3.1.RELEASE"
springBootPlugin = "1.3.72"
springBootJava = "1.8"
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$springBootPlugin")
classpath("org.jetbrains.kotlin:kotlin-allopen:$springBootPlugin")
}
}
apply plugin: 'kotlin'
apply plugin: 'kotlin-spring'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'com.tendering'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = springBootJava
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "org.jetbrains.kotlin:kotlin-reflect"
}
compileKotlin {
kotlinOptions {
freeCompilerArgs = ['-Xjsr305=strict']
jvmTarget = springBootJava
}
}
compileTestKotlin {
kotlinOptions {
freeCompilerArgs = ['-Xjsr305=strict']
jvmTarget = springBootJava
}
}
test {
useJUnitPlatform()
}
task copyDependencies(type: Copy) {
from configurations.compileClasspath
into "$buildDir\\libs\\build\\dependencies"
}
bootJar {
excludes = ["*.jar"]
dependsOn copyDependencies
manifest {
attributes "Manifest-Version": 1.0, 'Class-Path': configurations.compileClasspath.files.collect { "build/dependencies/$it.name" }.join(' ')
}
}
springBoot {
buildInfo()
}