You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/06/13 06:26:05 UTC

[GitHub] [maven-archiver] michael-o commented on a diff in pull request #22: [MSHARED-1066] - Upgrade Plexus Archiver to 4.3.0, Improve the Reproducible Builds methods

michael-o commented on code in PR #22:
URL: https://github.com/apache/maven-archiver/pull/22#discussion_r895363820


##########
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:
   Interesting, can it be empty if it is a numeric?



-- 
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-unsubscribe@maven.apache.org

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