Skip to content

Commit 358a5bd

Browse files
committed
Switch to latest Maven APIs to handle build output timestamp.
1 parent 8fb45bb commit 358a5bd

4 files changed

Lines changed: 16 additions & 19 deletions

File tree

changes.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 https://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd">
2424
<body>
2525

26+
<release version="2.19.6" date="not released">
27+
<action type="update" dev="sseifert">
28+
Switch to latest Maven APIs to handle build output timestamp.
29+
</action>
30+
</release>
31+
2632
<release version="2.19.4" date="2023-03-27">
2733
<action type="update" dev="sseifert">
2834
Update to SnakeYAML 2.0.

tooling/conga-aem-maven-plugin/src/main/java/io/wcm/devops/conga/plugins/aem/maven/BuildOutputTimestamp.java

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
package io.wcm.devops.conga.plugins.aem.maven;
2121

2222
import java.nio.file.attribute.FileTime;
23-
import java.util.Date;
23+
import java.time.Instant;
24+
import java.util.Optional;
2425

2526
import org.apache.maven.archiver.MavenArchiver;
2627
import org.jetbrains.annotations.Nullable;
@@ -30,40 +31,31 @@
3031
*/
3132
public class BuildOutputTimestamp {
3233

33-
private final Date date;
34+
private final Optional<Instant> instant;
3435

3536
/**
3637
* @param outputTimestamp Configured output timestamp
3738
*/
3839
public BuildOutputTimestamp(@Nullable String outputTimestamp) {
39-
MavenArchiver mavenArchiver = new MavenArchiver();
40-
this.date = mavenArchiver.parseOutputTimestamp(outputTimestamp);
40+
this.instant = MavenArchiver.parseBuildOutputTimestamp(outputTimestamp);
4141
}
4242

4343
/**
4444
* @return true if a valid timestamp is configured
4545
*/
4646
public boolean isValid() {
47-
return date != null;
48-
}
49-
50-
/**
51-
* @return Date or null if not a valid date
52-
*/
53-
@Nullable
54-
public Date toDate() {
55-
return date;
47+
return instant.isPresent();
5648
}
5749

5850
/**
5951
* @return FileTime or null if not a valid date
6052
*/
6153
@Nullable
6254
public FileTime toFileTime() {
63-
if (date != null) {
64-
return FileTime.fromMillis(date.toInstant().getEpochSecond());
65-
}
66-
return null;
55+
return instant
56+
.map(Instant::toEpochMilli)
57+
.map(FileTime::fromMillis)
58+
.orElse(null);
6759
}
6860

6961
}

tooling/conga-aem-maven-plugin/src/main/java/io/wcm/devops/conga/plugins/aem/maven/CloudManagerDispatcherConfigMojo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private void buildDispatcherConfig(File environmentDir, File nodeDir) throws Moj
9797

9898
BuildOutputTimestamp buildOutputTimestamp = new BuildOutputTimestamp(outputTimestamp);
9999
if (buildOutputTimestamp.isValid()) {
100-
zipArchiver.configureReproducible(buildOutputTimestamp.toDate());
100+
zipArchiver.configureReproducibleBuild(buildOutputTimestamp.toFileTime());
101101
}
102102

103103
zipArchiver.createArchive();

tooling/conga-aem-maven-plugin/src/main/java/io/wcm/devops/conga/plugins/aem/maven/model/ModelParser.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ private Map<String, Object> getModelData() {
143143
return parseYaml(modelFile);
144144
}
145145

146-
@SuppressWarnings("unchecked")
147146
private Map<String, Object> parseYaml(File modelFile) {
148147
try {
149148
try (InputStream is = new FileInputStream(modelFile);

0 commit comments

Comments
 (0)