Spring Boot 2 - Change Jar Name

后端 未结 8 1758
耶瑟儿~
耶瑟儿~ 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:32

    For Gradle 6

    bootJar {
        archiveBaseName = 'freeway-server'
        archiveVersion = '1.0.0'
        archiveFileName = 'freeway-server.jar'
    }
    

    For get:-

    System.out.print(bootJar.getArchiveBaseName().get())
    System.out.print(bootJar.getArchiveVersion().get())
    System.out.print(bootJar.getArchiveFileName().get())
    
    0 讨论(0)
  • 2021-02-07 00:32

    Most people simply want to not have the version in the jar name, not change the name completely.

    tasks.withType<org.springframework.boot.gradle.tasks.bundling.BootJar> {
        archiveVersion.set("")
    }
    

    will do it using Kotlin DSL. The final name is given by tasks.bootJar.get().archiveFileName.get().

    0 讨论(0)
提交回复
热议问题