jorsol commented on code in PR #22:
URL: https://github.com/apache/maven-archiver/pull/22#discussion_r895467830


##########
src/main/java/org/apache/maven/archiver/MavenArchiver.java:
##########
@@ -812,28 +814,70 @@ public void setBuildJdkSpecDefaultEntry( boolean 
buildJdkSpecDefaultEntry )
      * @return the parsed timestamp, may be <code>null</code> if 
<code>null</code> input or input contains only 1
      *         character
      * @since 3.5.0
-     * @throws java.lang.IllegalArgumentException if the outputTimestamp is 
neither ISO 8601 nor an integer
+     * @throws IllegalArgumentException if the outputTimestamp is neither ISO 
8601 nor an integer
+     * @deprecated Use {@link #parseBuildOutputTimestamp(String)} instead.
      */
+    @Deprecated
     public Date parseOutputTimestamp( String outputTimestamp )
     {
+        return parseBuildOutputTimestamp( outputTimestamp ).map( Date::from 
).orElse( null );
+    }
+
+    /**
+     * Configure Reproducible Builds archive creation if a timestamp is 
provided.
+     *
+     * @param outputTimestamp the value of {@code 
${project.build.outputTimestamp}} (may be {@code null})
+     * @return the parsed timestamp as {@link java.util.Date}
+     * @since 3.5.0
+     * @see #parseOutputTimestamp
+     * @deprecated Use {@link #configureReproducibleBuild(String)} instead.
+     */
+    @Deprecated
+    public Date configureReproducible( String outputTimestamp )
+    {
+        configureReproducibleBuild( outputTimestamp );
+        return parseOutputTimestamp( outputTimestamp );
+    }
+
+    /**
+     * Parse output timestamp configured for Reproducible Builds' archive 
entries.
+     *
+     * <p>Either as {@link java.time.format.DateTimeFormatter#ISO_INSTANT} or 
as a number representing seconds since the
+     * epoch (like <a 
href="https://reproducible-builds.org/docs/source-date-epoch/";>SOURCE_DATE_EPOCH</a>).
+     *
+     * @param outputTimestamp the value of {@code 
${project.build.outputTimestamp}} (may be {@code null})
+     * @return the parsed timestamp as an {@code Optional<Instant>}, {@code 
empty} if input is {@code null} or input
+     *         contains only 1 character (not a number)
+     * @since 3.6.0
+     * @throws IllegalArgumentException if the outputTimestamp is neither ISO 
8601 nor an integer
+     */
+    public static Optional<Instant> parseBuildOutputTimestamp( String 
outputTimestamp )
+    {
+        // Fail-fast on nulls
+        if ( outputTimestamp == null )
+        {
+            return Optional.empty();
+        }
+
+        // Number representing seconds since the epoch
         if ( StringUtils.isNumeric( outputTimestamp ) && 
StringUtils.isNotEmpty( outputTimestamp ) )

Review Comment:
   Yeah, that shocked me as well, but that utility method doesn't handle empty 
values and return true for an empty value.



-- 
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: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to