arturobernalg commented on code in PR #681:
URL: https://github.com/apache/maven-war-plugin/pull/681#discussion_r4667854757


##########
src/main/java/org/apache/maven/plugins/war/util/MavenBuildTimestamp.java:
##########
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.plugins.war.util;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Properties;
+import java.util.TimeZone;
+
+/**
+ * Formats the build timestamp the same way Maven core does when interpolating 
{@code ${maven.build.timestamp}}
+ * in the POM. Duplicated from {@code maven-model-builder} because that 
computation isn't reachable from a plugin
+ * (same reasoning as MRESOURCES-99 in {@code maven-resources-plugin}): the 
value substituted into the POM itself
+ * isn't exposed through the build context a plugin can obtain from Maven core.
+ *
+ * @since 3.5.2
+ */
+public class MavenBuildTimestamp {
+
+    /**
+     * ISO 8601-compliant timestamp for machine readability.
+     */
+    public static final String DEFAULT_BUILD_TIMESTAMP_FORMAT = 
"yyyy-MM-dd'T'HH:mm:ss'Z'";
+
+    /**
+     * The property used to override {@link #DEFAULT_BUILD_TIMESTAMP_FORMAT}.
+     */
+    public static final String BUILD_TIMESTAMP_FORMAT_PROPERTY = 
"maven.build.timestamp.format";
+
+    /**
+     * The default time zone, {@code Etc/UTC}.
+     */
+    public static final TimeZone DEFAULT_BUILD_TIME_ZONE = 
TimeZone.getTimeZone("Etc/UTC");
+
+    private final String formattedTimestamp;
+
+    /**
+     * Creates an instance formatting the current time with the default format.
+     */
+    public MavenBuildTimestamp() {
+        this(new Date());
+    }
+
+    /**
+     * Creates an instance formatting the given time with the default format.
+     *
+     * @param time the time to format
+     */
+    public MavenBuildTimestamp(final Date time) {
+        this(time, DEFAULT_BUILD_TIMESTAMP_FORMAT);
+    }
+
+    /**
+     * Creates an instance formatting the given time, taking the format from 
{@link #BUILD_TIMESTAMP_FORMAT_PROPERTY}
+     * when present in {@code properties}, or the default format otherwise.
+     *
+     * @param time the time to format
+     * @param properties properties that may carry {@link 
#BUILD_TIMESTAMP_FORMAT_PROPERTY}, may be {@code null}
+     */
+    public MavenBuildTimestamp(final Date time, final Properties properties) {

Review Comment:
   Agreed, same cleanup as above — the whole class (all 4 constructors) is gone 
in ff192a3, replaced with one private method that takes just the session start 
time and project properties the mojo actually has.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to