[JAVA] Add a time stamp to the JAR file name in Gradle


--When creating a JAR file with Gradle, add a time stamp to the file name --Operation check environment: Gradle 6.6 + Groovy 2.5.12


Add the date and time string to project.version in the build.gradle file.

plugins {
  id 'java'

project.version = '1.2.3' + '_' + getTimestamp()

def getTimestamp() {
  //date_Hours, minutes, and seconds_millisecond
  return new Date().format('yyyyMMdd_HHmmss_SSS')

Create a JAR file with the jar and build tasks.

$ gradle build

You can see that the jar is generated in build / libs with the following file name.

$ ls build/libs

Reference material

Recommended Posts

Add a time stamp to the JAR file name in Gradle
How to add jar file in ScalaIDE
How to debug the generated jar file in Eclipse
Create a jar file that can be executed in Gradle
Set up Gradle multi-project in IntelliJ to build JAR file
How to add the same Indexes in a nested array
Add Extended Attributes to the file
How to create a jar file or war file using the jar command
[Gradle] The story that the class file did not exist in the jar file
How to make a jar file with no dependencies in Maven
How to create a new Gradle + Java + Jar project in Intellij 2016.03
Fix the file name of war to the one set in Maven
[Xcode] How to add a README.md file
Create a jar file with the command
The story of forgetting to close a file in Java and failing
Add the pre-built jar library to Android and call it in the framework
I checked the package name referenced by the class contained in the JAR file
How to reference a column when overriding the column name method in ActiveRecord
Set the time of LocalDateTime to a specific time
How to add sound in the app (swift)
Rename the package name of the existing jar file
How to add a classpath in Spring Boot
Double-click to open the jar file on Windows
Add a project in any folder with Gradle
Add classpath: to the path specified in spring.datasource.schema
Add jar file obtained from Maven to IntelliJ
What to do if the changes are not reflected in the jar manifest file
Add files to jar files
How to set the display time to Japan time in Rails
[Java] How to extract the file name from the path
How to save a file with the specified extension under the directory specified in Java to the list
Add an external jar file in your IntelliJ project.
[Java] Get the file in the jar regardless of the environment
How to convert a file to a byte array in Java
Sample code to assign a value in a property file to a field of the expected type
Create a Java Servlet and JSP WAR file to deploy to Apache Tomcat 9 in Gradle
I want to add a delete function to the comment function
When I switched to IntelliJ, I got a lot of differences in the encoding of the properties file.
How to read a library from a JAR file with VS Code << How to not use Maven / Gradle >>
What you need to do to open a file from the menu in the document-Based App macOS app
How to get the class name / method name running in Java
How to correctly check the local HTML file in the browser
How to set chrony when the time shifts in CentOS7
How to create a placeholder part to use in the IN clause
Create a method to return the tax rate in Java
I want to give a class name to the select attribute
I want to create a Parquet file even in Ruby
Add a shadow to the Swift Button (and also the circle)
Contributed to Gradle and was named in the release notes
How to change the contents of the jar file without decompressing
Generate a single executable jar with dependent libraries in Gradle 4.9
How to change the file name with Xcode (Refactor Rename)
What is a jar file?
4 Add println to the interpreter
It doesn't respond to the description in .js of the packs file
I tried to illuminate the Christmas tree in a life game
Try to make a cross-platform application with JRuby (jar file generation)
Get the public URL of a private Flickr file in Java
How to store the information entered in textarea in a variable in the method
[Java] Returns a Japanese name file in filename of HTTP header
[chown] How to change the owner of a file or directory