Skip to content

Commit

Permalink
feat: add ...timestamp.iso placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
qoomon committed Oct 24, 2024
1 parent 9d78b19 commit 7721aa1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ e.g `${dirty:+SNAPSHOT}` resolves to `-SNAPSHOT` instead of `-DIRTY`
- `${commit.timestamp.minute}` commit minute of hour e.g. '59'
- `${commit.timestamp.second}` commit second of minute e.g. '30'
- `${commit.timestamp.datetime}` commit timestamp formatted as `yyyyMMdd.HHmmss`e.g. '20190616.161442'
- `${commit.timestamp.iso}` commit timestamp formatted as `yyyy-MM-ddTHH:mm:ssZ`e.g. '2019-06-16T16:14:42Z'
<br><br>

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

- `${describe}` Will resolve to `git describe` output
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<groupId>me.qoomon</groupId>
<artifactId>maven-git-versioning-extension</artifactId>
<version>9.9.0</version>
<version>9.10.0</version>
<packaging>maven-plugin</packaging>

<name>Maven Git Versioning Extension</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,9 @@ private Map<String, Supplier<String>> generateGlobalFormatPlaceholderMap(GitSitu
placeholderMap.put("commit.timestamp.minute", Lazy.by(() -> leftPad(String.valueOf(headCommitDateTime.get().getMinute()), 2, "0")));
placeholderMap.put("commit.timestamp.second", Lazy.by(() -> leftPad(String.valueOf(headCommitDateTime.get().getSecond()), 2, "0")));
placeholderMap.put("commit.timestamp.datetime", Lazy.by(() -> headCommitDateTime.get().toEpochSecond() > 0
? headCommitDateTime.get().format(DateTimeFormatter.ofPattern("yyyyMMdd.HHmmss")) : "00000000.000000"));
? headCommitDateTime.get().format(DateTimeFormatter.ofPattern("yyyyMMdd.HHmmss")) : "00000101.000000"));
placeholderMap.put("commit.timestamp.iso", Lazy.by(() -> headCommitDateTime.get().toEpochSecond() > 0
? headCommitDateTime.get().format(DateTimeFormatter.ISO_INSTANT) : "0000-01-01T00:00:00Z"));

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

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

0 comments on commit 7721aa1

Please sign in to comment.