Reputation: 649
How can add maven build time to jar file name using Spring Boot Maven plugin?
I want to achieve something like: jar_name-build_time.jar
Upvotes: 2
Views: 2619
Reputation: 649
By default, Spring Boot Maven Plugin builds jar file with name ${project.build.finalName}. This can be configured with non-required property finalName.
Maven build time can be used as ${maven.build.timestamp}
So, putting all things together, all you need to do is append build time to default jar name:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.6.RELEASE</version>
<configuration>
<mainClass>com.marand.thinkmed.meds.config.boot.MedsConfigApplication</mainClass>
<finalName>${project.build.finalName}-${maven.build.timestamp}</finalName>
</configuration>
</plugin>
Also, make sure to change timestamp format so it doesn't violate file naming strategies:
<properties>
<maven.build.timestamp.format>yyyy-MM-dd-HH-mm</maven.build.timestamp.format>
</properties>
Upvotes: 3