Spring Boot 2 - Change Jar Name

后端 未结 8 1732
耶瑟儿~
耶瑟儿~ 2021-02-06 23:29

I am using Spring Boot 2 in my Gradle project to do a build to jar in Jenkins, and I would like to change the name of that jar file.

By default, Spring Boot 2 used the G

8条回答
  •  孤街浪徒
    2021-02-07 00:31

    archiveFileName is the new hotness. Everything else is deprecated.

    bootJar {
       archiveFileName = "${archiveBaseName.get()}.${archiveExtension.get()}"
    }
    

    or the Kotlin DSL equivalent:

    tasks.getByName("bootJar") {
       this.archiveFileName.set("${archiveBaseName.get()}.${archiveExtension.get()}")
    }
    

    See:

    • https://docs.gradle.org/current/dsl/org.gradle.api.tasks.bundling.Jar.html#org.gradle.api.tasks.bundling.Jar:archiveName

    • https://docs.gradle.org/current/userguide/lazy_configuration.html

提交回复
热议问题