Skip to content

Commit 2118e44

Browse files
committed
feat: add ...timestamp.iso placeholder
1 parent 9d78b19 commit 2118e44

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ e.g `${dirty:+SNAPSHOT}` resolves to `-SNAPSHOT` instead of `-DIRTY`
221221
- `${commit.timestamp.minute}` commit minute of hour e.g. '59'
222222
- `${commit.timestamp.second}` commit second of minute e.g. '30'
223223
- `${commit.timestamp.datetime}` commit timestamp formatted as `yyyyMMdd.HHmmss`e.g. '20190616.161442'
224+
- `${commit.timestamp.iso}` commit timestamp formatted as `yyyy-MM-ddTHH:mm:ssZ`e.g. '2019-06-16T16:14:42Z'
224225
<br><br>
225226

226227
- `${build.timestamp}` maven-build-timestamp (epoch seconds) e.g. '1560694278'
@@ -232,6 +233,7 @@ e.g `${dirty:+SNAPSHOT}` resolves to `-SNAPSHOT` instead of `-DIRTY`
232233
- `${build.timestamp.minute}` maven-build-timestamp minute of hour e.g. '59'
233234
- `${build.timestamp.second}` maven-build-timestamp second of minute e.g. '30'
234235
- `${build.timestamp.datetime}` maven-build-timestamp formatted as `yyyyMMdd.HHmmss`e.g. '20190616.161442'
236+
- `${build.timestamp.iso}` commit timestamp formatted as `yyyy-MM-ddTHH:mm:ssZ`e.g. '2019-06-16T16:14:42Z'
235237
<br><br>
236238

237239
- `${describe}` Will resolve to `git describe` output

src/main/java/me/qoomon/maven/gitversioning/GitVersioningModelProcessor.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,9 @@ private Map<String, Supplier<String>> generateGlobalFormatPlaceholderMap(GitSitu
900900
placeholderMap.put("commit.timestamp.minute", Lazy.by(() -> leftPad(String.valueOf(headCommitDateTime.get().getMinute()), 2, "0")));
901901
placeholderMap.put("commit.timestamp.second", Lazy.by(() -> leftPad(String.valueOf(headCommitDateTime.get().getSecond()), 2, "0")));
902902
placeholderMap.put("commit.timestamp.datetime", Lazy.by(() -> headCommitDateTime.get().toEpochSecond() > 0
903-
? headCommitDateTime.get().format(DateTimeFormatter.ofPattern("yyyyMMdd.HHmmss")) : "00000000.000000"));
903+
? headCommitDateTime.get().format(DateTimeFormatter.ofPattern("yyyyMMdd.HHmmss")) : "00000101.000000"));
904+
placeholderMap.put("commit.timestamp.iso", Lazy.by(() -> headCommitDateTime.get().toEpochSecond() > 0
905+
? headCommitDateTime.get().format(DateTimeFormatter.ISO_INSTANT) : "0000-01-01T00:00:00Z"));
904906

905907
final Lazy<ZonedDateTime> buildCommitDateTime = Lazy.by(() -> mavenSession.getStartTime().toInstant().atZone(ZoneId.systemDefault()));
906908
placeholderMap.put("build.timestamp", Lazy.by(() -> String.valueOf(buildCommitDateTime.get().toEpochSecond())));
@@ -913,6 +915,8 @@ private Map<String, Supplier<String>> generateGlobalFormatPlaceholderMap(GitSitu
913915
placeholderMap.put("build.timestamp.second", Lazy.by(() -> leftPad(String.valueOf(buildCommitDateTime.get().getSecond()), 2, "0")));
914916
placeholderMap.put("build.timestamp.datetime", Lazy.by(() -> buildCommitDateTime.get().toEpochSecond() > 0
915917
? buildCommitDateTime.get().format(DateTimeFormatter.ofPattern("yyyyMMdd.HHmmss")) : "00000000.000000"));
918+
placeholderMap.put("build.timestamp.iso", Lazy.by(() -> buildCommitDateTime.get().toEpochSecond() > 0
919+
? headCommitDateTime.get().format(DateTimeFormatter.ISO_INSTANT) : "0000-01-01T00:00:00Z"));
916920

917921
final String refName = gitVersionDetails.getRefName();
918922
final Lazy<String> refNameSlug = Lazy.by(() -> slugify(refName));

0 commit comments

Comments
 (0)