gnodet commented on code in PR #599:
URL: https://github.com/apache/maven-jar-plugin/pull/599#discussion_r4084108917
##########
src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java:
##########
@@ -50,6 +50,12 @@
* @author Martin Desruisseaux
*/
public abstract class AbstractJarMojo implements
org.apache.maven.api.plugin.Mojo {
+ /**
+ * Minimum timestamp accepted by the {@code jar} tool (ZIP format
constraint: entries must be ≥ 1980-01-01).
+ * Timestamps before this value are automatically clamped to this minimum
with a warning.
+ */
+ static final Instant DATE_MIN = Instant.parse("1980-01-01T00:00:02Z");
Review Comment:
Fixed in 768760b. The JDK `jar` tool uses MS-DOS time internally, which has
2-second granularity; the earliest representable DOS time maps to
1980-01-01T00:00:02Z, not T00:00:00Z. Added a Javadoc comment on `EPOCH_MIN`
explaining this.
##########
src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java:
##########
@@ -50,6 +50,12 @@
* @author Martin Desruisseaux
*/
public abstract class AbstractJarMojo implements
org.apache.maven.api.plugin.Mojo {
+ /**
+ * Minimum timestamp accepted by the {@code jar} tool (ZIP format
constraint: entries must be ≥ 1980-01-01).
+ * Timestamps before this value are automatically clamped to this minimum
with a warning.
+ */
+ static final Instant DATE_MIN = Instant.parse("1980-01-01T00:00:02Z");
+
Review Comment:
Fixed in 768760b. Replaced `DATE_MIN` (Instant) with `static final long
EPOCH_MIN = 315532802L`, which avoids the cost of parsing an Instant when
timestamps are valid. Also added `epochMinMatchesParsedInstant()` test
verifying `EPOCH_MIN == Instant.parse("1980-01-01T00:00:02Z").getEpochSecond()`.
##########
src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java:
##########
@@ -254,6 +260,14 @@ protected ToolProvider getJarTool() throws MojoException {
* Returns the output timestamp or, as a fallback, the {@code
SOURCE_DATE_EPOCH} environment variable.
* If the timestamp is expressed in seconds, it is converted to ISO 8601
format. Otherwise it is returned as-is.
*
+ * <p>When the timestamp is given as a number of seconds and resolves to a
date before {@code DATE_MIN}
Review Comment:
Fixed in 768760b. The `DATE_MIN` field (and its Javadoc mentioning clamping
behavior) has been replaced by `EPOCH_MIN` (long) with a Javadoc comment
focused on what the constant represents, without describing internal behavior
in terms users would see.
--
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]