您能帮我找到一种正确的方式来重命名Gradle 5 Kotlin DSL构建的工件吗?
我创建了一个基于Kotlin DSL的Gradle 5.5.1 Spring Boot 2项目。
执行gradle build之后,构建的工件位于$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")
}```发布于 2019-07-28 05:30:24
配置生成jar的the bootJar task,它是一个gradle jar task,并设置其archiveFileName property
tasks {
bootJar {
archiveFileName.set("app.jar")
}
}发布于 2021-10-16 06:24:17
在jar任务中定义archiveBaseName
tasks.withType<Jar> {
archiveBaseName.set("app")
manifest {
attributes["Main-Class"] = application.mainClass
attributes["Implementation-Version"] = archiveVersion
attributes["Implementation-Title"] = "Test for App"
}
}https://stackoverflow.com/questions/57236042
复制相似问题