Skip to content

Commit ae09253

Browse files
author
TheSnoozer
committed
#674: breaking: change dateFormat from RFC 822 time to ISO 8601
1 parent 5eecbc8 commit ae09253

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@
397397
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
398398
<generateGitPropertiesFile>true</generateGitPropertiesFile>
399399
<generateGitPropertiesFilename>target/testing.properties</generateGitPropertiesFilename>
400-
<dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
400+
<dateFormat>yyyy-MM-dd'T'HH:mm:ssXXX</dateFormat>
401401
<dateFormatTimeZone>GMT-08:00</dateFormatTimeZone>
402402
<useNativeGit>false</useNativeGit>
403403
<abbrevLength>7</abbrevLength>

src/main/java/pl/project13/maven/git/GitCommitIdMojo.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -498,20 +498,28 @@ public class GitCommitIdMojo extends AbstractMojo {
498498
* represents dates or times exported by this plugin (e.g. {@code git.commit.time}, {@code
499499
* git.build.time}). It should be a valid {@link SimpleDateFormat} string.
500500
*
501-
* <p>The current dateFormat is set to match maven's default {@code yyyy-MM-dd'T'HH:mm:ssZ}.
502-
* Please note that in previous versions (2.2.0 - 2.2.2) the default dateFormat was set to: {@code
503-
* dd.MM.yyyy '@' HH:mm:ss z}. However the {@code RFC 822 time zone} seems to give a more reliable
504-
* option in parsing the date and it's being used in maven as default.
501+
* <p>The current dateFormat will be formatted as ISO 8601
502+
* {@code yyyy-MM-dd'T'HH:mm:ssXXX} and therefore can be used as input to maven's
503+
* <a href="https://maven.apache.org/guides/mini/guide-reproducible-builds.html">
504+
* reproducible build</a> feature.
505+
*
506+
* Please note that in previous versions
507+
* (2.2.2 - 7.0.1) the default format was set to {@code yyyy-MM-dd'T'HH:mm:ssZ}
508+
* which produces a {@code RFC 822 time zone}. While such format gives reliable
509+
* options in parsing the date, it does not comply with the requirements of
510+
* the reproducible build feature.
511+
* (2.2.0 - 2.2.2) the default dateFormat was set to: {@code
512+
* dd.MM.yyyy '@' HH:mm:ss z}.
505513
*
506514
* <p>Example:
507515
*
508516
* <pre>{@code
509-
* <dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
517+
* <dateFormat>yyyy-MM-dd'T'HH:mm:ssXXX</dateFormat>
510518
* }</pre>
511519
*
512520
* @since 2.2.0
513521
*/
514-
@Parameter(defaultValue = "yyyy-MM-dd'T'HH:mm:ssZ")
522+
@Parameter(defaultValue = "yyyy-MM-dd'T'HH:mm:ssXXX")
515523
String dateFormat;
516524

517525
/**

src/test/java/pl/project13/maven/git/NativeAndJGitProviderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public class NativeAndJGitProviderTest extends GitIntegrationTest {
5656
"git.local.branch.behind",
5757
};
5858

59-
private static final String DEFAULT_FORMAT_STRING = "yyyy-MM-dd'T'HH:mm:ssZ";
60-
private static final String ISO8601_FORMAT_STRING = "yyyy-MM-dd'T'HH:mm:ssZZ";
59+
private static final String DEFAULT_FORMAT_STRING = "yyyy-MM-dd'T'HH:mm:ssXXX";
60+
private static final String ISO8601_FORMAT_STRING = "yyyy-MM-dd'T'HH:mm:ssXXX";
6161

6262
@Test
6363
public void testCompareBasic() throws Exception {

0 commit comments

Comments
 (0)