From ae09253cbb9574e2f00ff8cd726319ac201b3e9b Mon Sep 17 00:00:00 2001 From: TheSnoozer Date: Wed, 14 Feb 2024 19:04:37 +0100 Subject: [PATCH] https://github.com/git-commit-id/git-commit-id-maven-plugin/issues/674: breaking: change dateFormat from RFC 822 time to ISO 8601 --- pom.xml | 2 +- .../project13/maven/git/GitCommitIdMojo.java | 20 +++++++++++++------ .../maven/git/NativeAndJGitProviderTest.java | 4 ++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 961f5c0e..424d9538 100644 --- a/pom.xml +++ b/pom.xml @@ -397,7 +397,7 @@ ${project.basedir}/.git true target/testing.properties - yyyy-MM-dd'T'HH:mm:ssZ + yyyy-MM-dd'T'HH:mm:ssXXX GMT-08:00 false 7 diff --git a/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java b/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java index 134df72b..ee8a7f56 100644 --- a/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java +++ b/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java @@ -498,20 +498,28 @@ public class GitCommitIdMojo extends AbstractMojo { * represents dates or times exported by this plugin (e.g. {@code git.commit.time}, {@code * git.build.time}). It should be a valid {@link SimpleDateFormat} string. * - *

The current dateFormat is set to match maven's default {@code yyyy-MM-dd'T'HH:mm:ssZ}. - * Please note that in previous versions (2.2.0 - 2.2.2) the default dateFormat was set to: {@code - * dd.MM.yyyy '@' HH:mm:ss z}. However the {@code RFC 822 time zone} seems to give a more reliable - * option in parsing the date and it's being used in maven as default. + *

The current dateFormat will be formatted as ISO 8601 + * {@code yyyy-MM-dd'T'HH:mm:ssXXX} and therefore can be used as input to maven's + * + * reproducible build feature. + * + * Please note that in previous versions + * (2.2.2 - 7.0.1) the default format was set to {@code yyyy-MM-dd'T'HH:mm:ssZ} + * which produces a {@code RFC 822 time zone}. While such format gives reliable + * options in parsing the date, it does not comply with the requirements of + * the reproducible build feature. + * (2.2.0 - 2.2.2) the default dateFormat was set to: {@code + * dd.MM.yyyy '@' HH:mm:ss z}. * *

Example: * *

{@code
-   * yyyy-MM-dd'T'HH:mm:ssZ
+   * yyyy-MM-dd'T'HH:mm:ssXXX
    * }
* * @since 2.2.0 */ - @Parameter(defaultValue = "yyyy-MM-dd'T'HH:mm:ssZ") + @Parameter(defaultValue = "yyyy-MM-dd'T'HH:mm:ssXXX") String dateFormat; /** diff --git a/src/test/java/pl/project13/maven/git/NativeAndJGitProviderTest.java b/src/test/java/pl/project13/maven/git/NativeAndJGitProviderTest.java index f0ec603b..215c5439 100644 --- a/src/test/java/pl/project13/maven/git/NativeAndJGitProviderTest.java +++ b/src/test/java/pl/project13/maven/git/NativeAndJGitProviderTest.java @@ -56,8 +56,8 @@ public class NativeAndJGitProviderTest extends GitIntegrationTest { "git.local.branch.behind", }; - private static final String DEFAULT_FORMAT_STRING = "yyyy-MM-dd'T'HH:mm:ssZ"; - private static final String ISO8601_FORMAT_STRING = "yyyy-MM-dd'T'HH:mm:ssZZ"; + private static final String DEFAULT_FORMAT_STRING = "yyyy-MM-dd'T'HH:mm:ssXXX"; + private static final String ISO8601_FORMAT_STRING = "yyyy-MM-dd'T'HH:mm:ssXXX"; @Test public void testCompareBasic() throws Exception {