How to generate/change jar file name using gradle command line

I need to generate jar file name by appending hash value in build/libs folder. I have to pass some argument to gradle command in command line to generate jar file name. as per my requirement.

For instance: gradle clean build -Djar.archiveName=Testfile-12634.jar (it is not working)
as a result, it should generate jar file name like "Testfile-12634.jar under build/libs folder

Currently jar file is generating like “Testfile.jar” , i want to append hash value (-12634) to that jar file but through gradle command only.

Any one please suggest? Thank you in advance.

Any one please suggest

I need to generate jar file name by appending hash value in build/libs folder. I have to pass some argument to do that as per my requirement.

For instance: gradle clean build -Djar.archiveName=Testfile-12634.jar (it is not working)

Currently jar file is generating like “Testfile.jar” , i want to append hash value (-12634) to that jar file but through gradle command only.

Any one please suggest? Thank you in advance.

The default behavior appends the version number to end of the JAR file name.

gradle clean build -Pversion=12634

would give you a JAR file named Testfile-12634.jar in a project called Testfile.

1 Like

Thanks so much. The given solution is working fine.