0

如何在spring boot Gradle项目中为jar附加时间戳?

./gradlew build

创建 jar app-0.0.1-SNAPSHOT.jar,如何创建带有时间戳的 jar

app-0.0.1-SNAPSHOT-2020-11-09.02-30.jar

-------- 摇篮

plugins {
    id 'org.springframework.boot' version '2.3.5.RELEASE'
    id 'io.spring.dependency-management' version '1.0.10.RELEASE'
    id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
}

test {
    useJUnitPlatform()
}
4

1 回答 1

3

怎么样

bootJar {
    archiveFileName = "app-0.0.1-SNAPSHOT-"+new Date().format('yyyy-MM-dd.HH-mm')+ ".jar"
}

使用 gradle6.6.1和 spring boot 插件版本测试2.3.4

于 2020-11-08T16:08:11.033 回答