[ https://issues.apache.org/jira/browse/MSHARED-1066?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17555648#comment-17555648 ]
ASF GitHub Bot commented on MSHARED-1066: ----------------------------------------- jorsol commented on code in PR #22: URL: https://github.com/apache/maven-archiver/pull/22#discussion_r900196538 ########## 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: And in fact this is documented in the method: > <code>null</code> will return <code>false</code>. An empty String will return <code>true</code>. That class was probably copied from the old [commons-lang 2.x](https://javadoc.io/static/commons-lang/commons-lang/2.6/org/apache/commons/lang/StringUtils.html#isNumeric(java.lang.String)), since on [commons-lang3](https://javadoc.io/static/org.apache.commons/commons-lang3/3.12.0/org/apache/commons/lang3/StringUtils.html#isNumeric-java.lang.CharSequence-) this was fixed. but anyway, the point is that the code is "correct" by checking that the string is not empty. > Upgrade Plexus Archiver to 4.3.0 > -------------------------------- > > Key: MSHARED-1066 > URL: https://issues.apache.org/jira/browse/MSHARED-1066 > Project: Maven Shared Components > Issue Type: Dependency upgrade > Components: maven-archiver > Affects Versions: maven-archiver-3.5.2 > Reporter: Jorge Solórzano > Priority: Major > Fix For: maven-archiver-3.6.0 > > > Maven Archiver 3.6.0 should update to Plexus Archiver 4.3.0 (once it's > released), it contains fixes to reproducible modular jars and also target > Java 8. -- This message was sent by Atlassian Jira (v8.20.7#820007)