Maven packing timestamp problem


When Maven is packaged, the timestamp attribute can be generated to assemble the package name.


Turn on the filtering function for the resource file, and the POM variable in the resource file will be automatically replaced during the packaging process. You can get the version number by accessing the properties resource file in Java code.


However, there is a problem with this timestamp attribute, the generated time${ }Time zone cannot be modified because it is UTC time. Find a way to solve this problem with plug-ins on the Internet.


Properties generated by the plug-in${ build.time }It is already the local time zone.

However, in idea, build projects, build artifacts${ project.version }It was not replaced.

After groping for a while, we found that idea build projects does not call Maven life cycle, resulting in plugin not being executed. Although Maven’s own variables can be replaced, custom variables are not.

Using the Maven install package of the tool button, the variables in the resource can be replaced normally.

There is also a method to bind the build of idea with Maven goal:

Figure 1 binding Maven goal

The above is the whole content of this article, I hope to help you in your study, and I hope you can support developeppaer more.