您能否帮助我找到使用Gradle 5 Kotlin DSL重命名内置 Artifact 的正确方法
我创建了一个基于Kotlin DSL的Gradle 5.5.1 Spring Boot 2项目。
执行gradle build
之后,构建的 Artifact 在$ buildDir / libs文件夹中。
如何重命名?假设我想给一个简单的名字-app.jar
plugins {
id("java")
id("idea")
id("org.springframework.boot") version "2.1.5.RELEASE"
id("io.spring.dependency-management") version "1.0.8.RELEASE"
}
group = "com.hbv"
version = "1.0.0-SNAPSHOT"
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.5.RELEASE")
}
}
the<DependencyManagementExtension>().apply {
imports {
mavenBom(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
}
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
implementation(platform("org.springframework.cloud:spring-cloud-dependencies:Greenwich.RELEASE"))
implementation("org.springframework.cloud:spring-cloud-starter-config")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-security")
testImplementation("com.h2database", "h2")
testImplementation("org.springframework.boot", "spring-boot-starter-test")
testImplementation("org.springframework.security", "spring-security-test")
}```
最佳答案
配置生成jar的the bootJar
task并成为gradle jar task并设置其 archiveFileName
property:
tasks {
bootJar {
archiveFileName.set("app.jar")
}
}
关于gradle - 在Gradle 5 Kotlin DSL中构建项目后如何重命名文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57236042/