Spring Boot 2 - Change Jar Name

Since bootJar tasks extends Jar you can use archiveName to set name the directly:

bootJar {
   archiveName = 'whatever'
}

Have a look here.


archiveFileName is the new hotness. Everything else is deprecated.

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

or the Kotlin DSL equivalent:

tasks.getByName<org.springframework.boot.gradle.tasks.bundling.BootJar>("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