Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle - Change the name of the jar

I would like to change the name of the jar when I do a

./gradlew clean assemble

The name of my jar is my-awsome-app-0.0.1-SNAPSHOT.jar and I want to generate my-awsome-app.jar.

I tested to do this in the build.gradle:

configurations {
   jar.archiveName = "my-awsome-app.${jar.extension}"
}

...but this is not working, the name is still the same

like image 355
psv Avatar asked Apr 19 '18 15:04

psv


People also ask

How do I set a build name in Gradle?

By default, Gradle uses the directory name as project name. You can change this by creating a settings. gradle file in the directory which specifies the project name. You can also add a description to your project via the build.

What is the Gradle build script file name?

The build script defines a project and its tasks. To try this out, create the following build script named build. gradle . You run a Gradle build using the gradle command. The gradle command looks for a file called build.


1 Answers

Since you are using Spring Boot, you should use the bootJar task instead (notice bootJar extends Jar).

Since archiveName in Jar has been deprecated, use archiveFileName:

bootJar {
   archiveFileName = 'my-awesome-app.jar'
}
like image 166
acdcjunior Avatar answered Sep 20 '22 07:09

acdcjunior