Consider time in BuildInfo up-to-date checks and allow it to be set
Closes gh-12111 Closes gh-12266
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,8 +19,8 @@ package org.springframework.boot.loader.tools;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.time.Instant;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Properties;
|
||||
@@ -74,7 +74,10 @@ public final class BuildPropertiesWriter {
|
||||
properties.put("build.artifact", project.getArtifact());
|
||||
properties.put("build.name", project.getName());
|
||||
properties.put("build.version", project.getVersion());
|
||||
properties.put("build.time", formatDate(new Date()));
|
||||
if (project.getTime() != null) {
|
||||
properties.put("build.time",
|
||||
DateTimeFormatter.ISO_INSTANT.format(project.getTime()));
|
||||
}
|
||||
if (project.getAdditionalProperties() != null) {
|
||||
for (Map.Entry<String, String> entry : project.getAdditionalProperties()
|
||||
.entrySet()) {
|
||||
@@ -84,11 +87,6 @@ public final class BuildPropertiesWriter {
|
||||
return properties;
|
||||
}
|
||||
|
||||
private String formatDate(Date date) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
|
||||
return sdf.format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build-system agnostic details of a project.
|
||||
*/
|
||||
@@ -102,14 +100,17 @@ public final class BuildPropertiesWriter {
|
||||
|
||||
private final String version;
|
||||
|
||||
private final Instant time;
|
||||
|
||||
private final Map<String, String> additionalProperties;
|
||||
|
||||
public ProjectDetails(String group, String artifact, String version, String name,
|
||||
Map<String, String> additionalProperties) {
|
||||
Instant time, Map<String, String> additionalProperties) {
|
||||
this.group = group;
|
||||
this.artifact = artifact;
|
||||
this.name = name;
|
||||
this.version = version;
|
||||
this.time = time;
|
||||
validateAdditionalProperties(additionalProperties);
|
||||
this.additionalProperties = additionalProperties;
|
||||
}
|
||||
@@ -141,6 +142,10 @@ public final class BuildPropertiesWriter {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public Instant getTime() {
|
||||
return this.time;
|
||||
}
|
||||
|
||||
public Map<String, String> getAdditionalProperties() {
|
||||
return this.additionalProperties;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user