我在Gradle项目中使用Spring Boot 2在Jenkins中进行jar的构建,我想更改该jar文件的名称。
默认情况下,Spring Boot 2使用Gradle属性rootProject.name
,可以在/settings.gradle
文件中设置它。
但是,我想更改jar文件名,而不更改rootProject.name
。
这是bootJar
文件的springBoot
和build.gradle
部分:
bootJar {
launchScript()
}
。
springBoot {
buildInfo {
properties {
artifact = "jarName"
group = "groupName"
name = "projectName"
version = "1.0"
}
}
}
注意:读了https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/html/#integrating-with-actuator后,
artifact
没有像我期望的那样设置jar名称。 最佳答案
archiveFileName
是新的热点。其他所有东西都已弃用。
bootJar {
archiveFileName = "${archiveBaseName.get()}.${archiveExtension.get()}"
}
或等效的Kotlin DSL:
tasks.getByName<org.springframework.boot.gradle.tasks.bundling.BootJar>("bootJar") {
this.archiveFileName.set("${archiveBaseName.get()}.${archiveExtension.get()}")
}
看到:
关于spring-boot - Spring Boot 2-更改Jar名称,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53123012/