--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
build.gradle
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
myapp-1.2.3-20200815_220925_236.jar
Recommended Posts