You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2019/10/15 16:11:00 UTC
[maven-archiver] branch MSHARED-837 updated: Apply proper extended
ISO 8601 format
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch MSHARED-837
in repository https://gitbox.apache.org/repos/asf/maven-archiver.git
The following commit(s) were added to refs/heads/MSHARED-837 by this push:
new 455ab3f Apply proper extended ISO 8601 format
455ab3f is described below
commit 455ab3f9bc03e11245add15295c5500051b41b7a
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Tue Oct 15 18:10:52 2019 +0200
Apply proper extended ISO 8601 format
---
.../org/apache/maven/archiver/MavenArchiver.java | 10 +++---
.../apache/maven/archiver/MavenArchiverTest.java | 42 ++++++++++++++++++++--
2 files changed, 44 insertions(+), 8 deletions(-)
diff --git a/src/main/java/org/apache/maven/archiver/MavenArchiver.java b/src/main/java/org/apache/maven/archiver/MavenArchiver.java
index 82cd3a9..4a12c6d 100644
--- a/src/main/java/org/apache/maven/archiver/MavenArchiver.java
+++ b/src/main/java/org/apache/maven/archiver/MavenArchiver.java
@@ -728,7 +728,7 @@ public class MavenArchiver
/**
* Define a value for "Created By" entry.
- *
+ *
* @param description description of the plugin, like "Maven Source Plugin"
* @param groupId groupId where to get version in pom.properties
* @param artifactId artifactId where to get version in pom.properties
@@ -753,7 +753,7 @@ public class MavenArchiver
/**
* Add "Build-Jdk-Spec" entry as part of default manifest entries (true by default).
* For plugins whose output is not impacted by JDK release (like maven-source-plugin), adding
- * Jdk spec adds unnecessary requirement on JDK version used at build to get reproducible result.
+ * Jdk spec adds unnecessary requirement on JDK version used at build to get reproducible result.
*
* @since 3.4.1
*/
@@ -763,8 +763,8 @@ public class MavenArchiver
}
/**
- * Parse output timestamp configured for Reproducible Builds' archive entries, formatted as ISO-8601
- * <code>yyyy-MM-dd'T'HH:mm:ssX</code>.
+ * Parse output timestamp configured for Reproducible Builds' archive entries, formatted as ISO 8601
+ * <code>yyyy-MM-dd'T'HH:mm:ssXXX</code>.
*
* @param outputTimestamp the value of <code>${project.build.outputTimestamp}</code> (may be <code>null</code>)
* @return the parsed timestamp, may be <code>null</code> if <code>null</code> input or input contains only 1
@@ -780,7 +780,7 @@ public class MavenArchiver
return null;
}
- DateFormat df = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ssX" );
+ DateFormat df = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ssXXX" );
try
{
return df.parse( outputTimestamp );
diff --git a/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java b/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java
index 609383a..e33d164 100644
--- a/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java
+++ b/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java
@@ -1508,7 +1508,7 @@ public class MavenArchiverTest
public void testParseOutputTimestamp()
{
MavenArchiver archiver = new MavenArchiver();
-
+
assertNull( archiver.parseOutputTimestamp( null ) );
assertNull( archiver.parseOutputTimestamp( "" ) );
assertNull( archiver.parseOutputTimestamp( "." ) );
@@ -1518,7 +1518,43 @@ public class MavenArchiverTest
assertEquals( 1570300662000L, archiver.parseOutputTimestamp( "2019-10-05T18:37:42Z" ).getTime() );
assertEquals( 1570300662000L, archiver.parseOutputTimestamp( "2019-10-05T20:37:42+02:00" ).getTime() );
assertEquals( 1570300662000L, archiver.parseOutputTimestamp( "2019-10-05T16:37:42-02:00" ).getTime() );
- assertEquals( 1570300662000L, archiver.parseOutputTimestamp( "2019-10-05T20:37:42+0200" ).getTime() );
- assertEquals( 1570300662000L, archiver.parseOutputTimestamp( "2019-10-05T16:37:42-0200" ).getTime() );
+
+ // These must result in IAE becaue we expect extended ISO format only, hence the XXX for tz offset
+ try
+ {
+ archiver.parseOutputTimestamp( "2019-10-05T20:37:42+0200" );
+ fail();
+ }
+ catch ( IllegalArgumentException e )
+ {
+ }
+ try
+ {
+ archiver.parseOutputTimestamp( "2019-10-05T20:37:42-0200" );
+ fail();
+ }
+ catch ( IllegalArgumentException e )
+ {
+ }
+
+ // These unfortunately fail altough the input is valid according to ISO 8601
+ // SDF does not allow strict telescoping parsing w/o permitting invalid input as depicted above.
+ // One has to use the new Java Time API for this.
+ try
+ {
+ archiver.parseOutputTimestamp( "2019-10-05T20:37:42+02" );
+ fail();
+ }
+ catch ( IllegalArgumentException e )
+ {
+ }
+ try
+ {
+ archiver.parseOutputTimestamp( "2019-10-05T20:37:42-02" );
+ fail();
+ }
+ catch ( IllegalArgumentException e )
+ {
+ }
}
}