From 490b6afb909fca46887fd11d473f7b38656b29c9 Mon Sep 17 00:00:00 2001 From: Tibor Blenessy Date: Mon, 25 Sep 2023 14:14:19 +0200 Subject: [PATCH] PACKMP-19 Fix `Plugin-BuildDate` timestamp format --- .../org/sonarsource/pluginpackaging/SonarPluginMojo.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/sonarsource/pluginpackaging/SonarPluginMojo.java b/src/main/java/org/sonarsource/pluginpackaging/SonarPluginMojo.java index 2c7551f..47311bd 100644 --- a/src/main/java/org/sonarsource/pluginpackaging/SonarPluginMojo.java +++ b/src/main/java/org/sonarsource/pluginpackaging/SonarPluginMojo.java @@ -24,6 +24,8 @@ import java.io.File; import java.io.IOException; import java.time.Instant; +import java.time.ZoneId; +import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.util.ArrayList; @@ -63,6 +65,8 @@ @Mojo(name = "sonar-plugin", defaultPhase = LifecyclePhase.PACKAGE, requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true) public class SonarPluginMojo extends AbstractSonarMojo { + private static final DateTimeFormatter DATETIME_PATTERN = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ") + .withZone(ZoneId.from(ZoneOffset.UTC)); private static final String LIB_DIR = "META-INF/lib/"; private static final String[] DEFAULT_EXCLUDES = new String[]{"**/package.html"}; private static final String[] DEFAULT_INCLUDES = new String[]{"**/**"}; @@ -159,7 +163,7 @@ public File createArchive() { addManifestProperty(PluginManifestProperty.ORGANIZATION_URL, getPluginOrganizationUrl()); addManifestProperty(PluginManifestProperty.TERMS_CONDITIONS_URL, getPluginTermsConditionsUrl()); addManifestProperty(PluginManifestProperty.ISSUE_TRACKER_URL, getPluginIssueTrackerUrl()); - addManifestProperty(PluginManifestProperty.BUILD_DATE, DateTimeFormatter.ISO_INSTANT.format(getBuildDate())); + addManifestProperty(PluginManifestProperty.BUILD_DATE, DATETIME_PATTERN.format(getBuildDate())); addManifestProperty(PluginManifestProperty.SOURCES_URL, getPluginSourcesUrl()); addManifestProperty(PluginManifestProperty.DEVELOPERS, getDevelopers()); addManifestProperty(PluginManifestProperty.JRE_MIN_VERSION, getJreMinVersion());