In Maven 3.2.2+, the maven.build.timestamp
has been redefined to show the time in UTC, as per MNG-5452.
Is there any way to specify that I want the timezone info in my local timezone and not in UTC? I briefly browsed the maven sources, but do not see anyway to specify that I want the TZ to be local TZ and not UTC based.
There's no solution but to workaround. Do you happened to use maven buildnumber-maven-plugin plugin? If so, you can use it to generate revision for you and build timestamp. This timestamp will be with based on your local java time zone configuration.
Edit: Nevertheless question is about
timestamp
, as Dean Schulze pointed out, only firstexecution
will break${buildNumber}
. To fix that you'll have to add anotherexecution
to your configuration that will createbuildRevision
. Updated example, below. For ex.:`Than you can use
${buildDateTime}
where you want to inject your timestamp variable. Another execution with the same goal will store you revision as well.What I did but might not apply to other people though, is that I export an environment variable in bash like
and then consume it in the pom.xml when building my project.
I think there is no pure Maven solution but you can use an Ant task.
Following the instructions given in the Maven plugin developers cookbook, you can generate a
filter.properties
file with the<tstamp>
ant task. In this element, you can customize your timestamp with the same date/time pattern as the SimpleDateFormat class and also use the Timezone class. You can then use${build.time}
, by default it will use your local timezone.1)Use the maven-antrun-plugin
2)Activate filtering
As already mentioned, in the current versions of Maven (at least up to version 3.3.+), the
maven.build.timestamp
property does not allow for timezone overrides.However, if you are okay with utilizing a different property name for your purposes, the build-helper-maven-plugin allows you to configure custom timestamps for a variety of purposes. Here is an example to configure the current timestamp in EST during a build.
Then you can utilize the
${build.time}
property instead of${maven.build.timestamp}
where you need a timestamp of the build in your preferred timezone.