Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parsing of reproducible builds 'project.build.outputTimestamp' cannot handle default dateFormat #674

Closed
Interessierter opened this issue Nov 30, 2023 · 17 comments
Labels
Milestone

Comments

@Interessierter
Copy link

Interessierter commented Nov 30, 2023

Describe the bug (required)

in https://maven.apache.org/guides/mini/guide-reproducible-builds.html it is mentioned that you could do <project.build.outputTimestamp>${git.commit.time}</project.build.outputTimestamp> and this is IMHO indeed a neat idea.

If you do so, however, you'll get

[ERROR] Failed to execute goal io.github.git-commit-id:git-commit-id-maven-plugin:6.0.0:revision (get-the-git-infos) on project mautstation: Invalid 'project.build.outputTimestamp' value '2023-11-30T09:17:06+0100': Unparseable date: "2023-11-30T09:17:06+0100" -> [Help 1]

This is because the defaullt dateFormat is yyyy-MM-dd'T'HH:mm:ssZ but parseOutputTimestamp only tries to parse the format yyyy-MM-dd'T'HH:mm:ssXXX

It can be work-arounded by specifying the configuration <dateFormat>yyyy-MM-dd'T'HH:mm:ssXXX</dateFormat> but this shouldnt be neccessary.

Tell us about your plugin configuration (required)

		<plugin>
			<groupId>io.github.git-commit-id</groupId>
			<artifactId>git-commit-id-maven-plugin</artifactId>
			<version>6.0.0</version>
			<executions>
				<execution>
					<id>get-the-git-infos</id>
					<goals>
						<goal>revision</goal>
					</goals>
				</execution>
			</executions>
			<configuration>
				<generateGitPropertiesFile>true</generateGitPropertiesFile>
			</configuration>
		</plugin>

Tell us about the Plugin version used (required)

6.0.0

Tell us about the Maven version used (required)

mvn --version
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: C:\Users\chris\AppData\Local\Programs\IntelliJ IDEA Ultimate\plugins\maven\lib\maven3
Java version: 17.0.2, vendor: Oracle Corporation, runtime: C:\java\openjdk-17.0.2
Default locale: de_DE, platform encoding: UTF-8
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Steps to Reproduce (required)

just configure the property <project.build.outputTimestamp>${git.commit.time}</project.build.outputTimestamp> in the POM

Are there any stacktraces or any error messages? (required)

Caused by: pl.project13.core.GitCommitIdExecutionException: Invalid 'project.build.outputTimestamp' value '2023-11-30T09:17:06+0100'
    at pl.project13.maven.git.GitCommitIdMojo.parseOutputTimestamp (GitCommitIdMojo.java:1511)
    at pl.project13.maven.git.GitCommitIdMojo$2.getReproducibleBuildOutputTimestamp (GitCommitIdMojo.java:1336)
    at pl.project13.core.GitCommitIdPlugin.loadBuildData (GitCommitIdPlugin.java:335)
    at pl.project13.core.GitCommitIdPlugin.runPlugin (GitCommitIdPlugin.java:295)
    at pl.project13.maven.git.GitCommitIdMojo.execute (GitCommitIdMojo.java:1453)

Is there a (public) project where this issue can be reproduced? (optional)

No response

Your Environment (optional)

No response

Context (optional)

No response

@Interessierter
Copy link
Author

I could do an MR but I am unsure how to proceed.... IMHO the parseOutputTimestamp method should use the configured dateFormat for parsing but maybe there were reasons to use a hardcoded format? A relatively safe option would be to leave the existing two attempts as is and do a 3rd attempt with the configured dateFormat - WDYT?

@TheSnoozer
Copy link
Collaborator

Mhh this is a weird one.

The page https://maven.apache.org/guides/mini/guide-reproducible-builds.html mentions the following should be supported:

   <properties>
     <project.build.outputTimestamp>2023-01-01T00:00:00Z</project.build.outputTimestamp>
   </properties>

Which aligns with https://maven.apache.org/ref/3.3.1/maven-model-builder/ that states that the maven.build.timestamp that will also be outputted as yyyy-MM-dd'T'HH:mm:ss'Z'. The format can apparently be overwritten by maven.build.timestamp.format.

When clicking on the somewhat hidden link in (Enable Reproducible Builds mode for plugins, by adding project.build.outputTimestamp property to the project's pom.xml) mentioned in https://maven.apache.org/guides/mini/guide-reproducible-builds.html one comes across the following:

 * Timestamp for reproducible output archive entries, either formatted as ISO 8601
 * <code>yyyy-MM-dd'T'HH:mm:ssXXX</code> or as an int representing seconds since the epoch (like
 * <a href="https://reproducible-builds.org/docs/source-date-epoch/">SOURCE_DATE_EPOCH</a>).

a For Maven 2.x and 3.x, the value can be defined as an equivalent property:

<project>
  ...
  <properties>
    <project.build.outputTimestamp>2019-10-02T08:04:00Z</project.build.outputTimestamp>
    ...
  </properties>
  ...
</project>

So I guess here is one source of this secret XXX-Format.

When now checking the code of the plugin:

/**
* Parse output timestamp configured for Reproducible Builds' archive entries
* (https://maven.apache.org/guides/mini/guide-reproducible-builds.html).
* The value from <code>${project.build.outputTimestamp}</code> is either formatted as ISO 8601
* <code>yyyy-MM-dd'T'HH:mm:ssXXX</code> or as an int representing seconds since the epoch (like
* <a href="https://reproducible-builds.org/docs/source-date-epoch/">SOURCE_DATE_EPOCH</a>.
*
* Inspired by https://github.com/apache/maven-archiver/blob/a3103d99396cd8d3440b907ef932a33563225265/src/main/java/org/apache/maven/archiver/MavenArchiver.java#L765
*
* @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
* character
*/

I see in the commentary that this was inspired by https://github.com/apache/maven-archiver/blob/a3103d99396cd8d3440b907ef932a33563225265/src/main/java/org/apache/maven/archiver/MavenArchiver.java#L765.

Here we have again the same/similar pattern of yyyy-MM-dd'T'HH:mm:ssXXX

A more recent version got rid of this hard-coded string:
https://github.com/apache/maven-archiver/blob/cc2f6a219f6563f450b0c00e8ccd651520b67406/src/main/java/org/apache/maven/archiver/MavenArchiver.java#L755

So I would suggest to use a similar parsing mechanism and drop the pattern with yyyy-MM-dd'T'HH:mm:ssXXX. Thus the entire parsing should IMHO look like:

return Date.from(OffsetDateTime.parse(outputTimestamp)
                    .withOffsetSameInstant(ZoneOffset.UTC)
                    .truncatedTo(ChronoUnit.SECONDS)
                    .toInstant());

Of course I think it also makes sense to update the comments to mention an yyyy-MM-dd'T'HH:mm:ssXXX format to refer just to ISO 8601. For example:

* <code>yyyy-MM-dd'T'HH:mm:ssXXX</code> or as an int representing seconds since the epoch (like
.

Does this make sense?
Could you create a PR and add relevant tests?
Thanks :-)

@Interessierter
Copy link
Author

I finally got some time to look into this again. Unfortunately your suggestion does not work as (also new to me) the new java date parsers are not able to parse the RFC 822 format?!

Caused by: java.time.format.DateTimeParseException: Text '2024-02-09T16:48:52+0100' could not be parsed, unparsed text found at index 22
    at java.time.format.DateTimeFormatter.parseResolved0 (DateTimeFormatter.java:2055)
    at java.time.format.DateTimeFormatter.parse (DateTimeFormatter.java:1954)
    at java.time.OffsetDateTime.parse (OffsetDateTime.java:404)
    at java.time.OffsetDateTime.parse (OffsetDateTime.java:389)
    at pl.project13.maven.git.GitCommitIdMojo.parseOutputTimestamp (GitCommitIdMojo.java:1467)
    at pl.project13.maven.git.GitCommitIdMojo$2.getReproducibleBuildOutputTimestamp (GitCommitIdMojo.java:1290)
    at pl.project13.core.GitCommitIdPlugin.loadBuildData (GitCommitIdPlugin.java:335)
    at pl.project13.core.GitCommitIdPlugin.runPlugin (GitCommitIdPlugin.java:295)
    at pl.project13.maven.git.GitCommitIdMojo.execute (GitCommitIdMojo.java:1409)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
...

I then went ahead and modified the last lines of https://github.com/git-commit-id/git-commit-id-maven-plugin/blob/master/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java#L1464

to be the following (i.e. just re-try parsing it using the format the timestamp is created with from git);

    DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
    try {
      return df.parse(outputTimestamp);
    } catch (ParseException pe) {
      getLog().debug("Invalid 'project.build.outputTimestamp' value '" + outputTimestamp + "', re-trying " +
              "with default format '" + dateFormat + "'", pe);
    }

    df = new SimpleDateFormat(dateFormat);
    try {
      return df.parse(outputTimestamp);
    } catch (ParseException pe) {
      throw new GitCommitIdExecutionException(
              "Invalid 'project.build.outputTimestamp' value '" + outputTimestamp + "'", pe);
    }

this worked for this plugin, unfortunately then later on in my project the spring-boot-maven-plugin fails because it also cannot handle the RFC822 timestamp https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildInfoMojo.java#L157 ;(

Caused by: java.time.format.DateTimeParseException: Text '2024-02-09T16:48:52+0100' could not be parsed at index 19
    at java.time.format.DateTimeFormatter.parseResolved0 (DateTimeFormatter.java:2052)
    at java.time.format.DateTimeFormatter.parse (DateTimeFormatter.java:1954)
    at java.time.Instant.parse (Instant.java:397)
    at org.springframework.boot.maven.BuildInfoMojo.getBuildTime (BuildInfoMojo.java:157)
...

I thought that maybe using the format yyyy-MM-dd'T'HH:mm:ssXXX as default for the commit timestamp would be most useful way to continue and changed https://github.com/git-commit-id/git-commit-id-maven-plugin/blob/master/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java#L513 but to my surprise this did not work, I still got the error from the Spring Boot plugin above, only setting it explicitly in the git plugins configuration did work, is it possible that this default value isn't used but there is another default value in the project that is actually using the values (git-commit-id-plugin-core-6.0.0-rc.6.jar)?

Ultimately I am unsure how to proceed and will stick with the workaround I am currently configured (explicitly configuring a working format in the plugins configurion in pom.xml)

@TheSnoozer
Copy link
Collaborator

The time must be formatted as ISO 8601. Can you check if the code in https://github.com/git-commit-id/git-commit-id-maven-plugin/pull/699/files would cover your case?

@Interessierter
Copy link
Author

Interessierter commented Feb 13, 2024

Thank you very much for your response!

Unfortunately it does not, as (maybe this was not clear enough in my ramblings above) the plugin itself generates an invalid dateformat for further maven processing (as seen here: https://github.com/git-commit-id/git-commit-id-maven-plugin/blob/master/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java#L513). I cobbled together a quick reproducer project:

git-plugin-timestamp-problem-demo.zip

  1. unzip it to some dir
  2. run git init in that dir
  3. add all the files to the empty repository, i.e. git add . in that dir
  4. commit it, i.e. git commit -m "initial commit" in that dir
  5. run mvn clean package to see the build fail

This is caused because I set the project.build.outputTimestamp to the plugins value (line 18 in pom.xml) - which is the heart of the reproducible build feature. If I explicitly set the output format to ISO8601 (commented out line 54 in the pom.xml) all is well. An like I said: just changing line 513 in GitCommitIdMojo is not enough, the plugin still generates an "invalid" format, it has to be set explicitly in the configuration.

@TheSnoozer
Copy link
Collaborator

Thanks for the additional explanations and the reproducer! Sorry maybe it was just me being slow in understanding what you really mean, but I think I got it now.
Essentially you would like to pass in any time-formatted values that are produced by the plugin like <project.build.outputTimestamp>${git.commit.time}</project.build.outputTimestamp>.

For that to happen (without any extra <dateFormat>yyyy-MM-dd'T'HH:mm:ssXXX</dateFormat>) the default value of the dateFormat would need to be changed (see https://github.com/git-commit-id/git-commit-id-maven-plugin/blob/master/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java#L513).

Likely this would mean it's a breaking change, since as a plugin developer I don't know what weird features the plugin users rely on...

@Interessierter
Copy link
Author

no worries :) As I said in my original message, doing <project.build.outputTimestamp>${git.commit.time}</project.build.outputTimestamp> is explicitly mentioned on Mavens reproducible build page (last item in FAQ) as this enables truly automatic reproducible builds but then this clashes with the "historic" dateformat of this plugin, which could not be consumed by the plugin itself (until your changes from #699 are applied) but also cause problems in other Maven plugins (like the not-so-seldomly-used spring-boot-maven-plugin`` and maybe others) because they too expect ISO8601 instead of RFC822 format.

So IMHO yes, you should do a breaking change as the "new" default is more sensible - this could clearly be advertised in the release notes and so on ("default format changed, if you need the old format add <dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat> as configuration").

Also, like I said above, I did exactly this locally (i.e. changed line 513 in GitCommitIdMojo to be @Parameter(defaultValue = "yyyy-MM-dd'T'HH:mm:ssXXX")) and installed SNAPSHOT version locally and used that and it had no effect, the timestamp was still in RFC822 format so there addtionally may be a bug somewhere (unfortunately I have no knowledge on how to debug a maven plugin and the "real work" is done in the other project (git-commit-id-plugin-core-6.0.0-rc.6) which I did not checkout)

@TheSnoozer
Copy link
Collaborator

No worries, just to make sure I don't overlook something I ran a quick test and setting the @Parameter(defaultValue = "yyyy-MM-dd'T'HH:mm:ssXXX"). It indeed does the trick, so maybe you still had/have a dateFormat encoded in your pom.xml (remember the plugin just suggests a default, everything can be overwritten by the user).

I have tested #699 with the demo profile that is encoded in the pom:

# First install the plugin so we can use unreleased changes
mvn clean install -Dmaven.test.skip=true
# Run it with demo profile encoded in pom
mvn clean package -Pdemo -Dmaven.test.skip=true

With a configuration of:

<!-- <dateFormat>yyyy-MM-dd'T'HH:mm:ssXXX</dateFormat> -->
<dateFormatTimeZone>GMT-08:00</dateFormatTimeZone>

this produces a 2024-02-14T10:06:03-08:00 which is a valid ISO 8601 representation.

@Interessierter
Copy link
Author

It does not work on my machine :( I see that your changes should be good in theory but there's something wrong with it, I did the following, where is the mistake (could you try it on your environment):

  1. I deleted the plugin from my maven repository (i.e. wiped out the whole %USERPROFILE%\.m2\repository\io\github\git-commit-id\git-commit-id-maven-plugin\ directory)
  2. I pulled the 674 branch from the repo locally, checked that it contained your changes
  3. I mvn clean installed the plugin, checked that it does appear again in the maven repo
  4. I ran the reproducer I sent you earlier, it failes, this time in the maven-jar-plugin:
[INFO] --- maven-jar-plugin:3.3.0:jar (default-jar) @ demo ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.420 s
[INFO] Finished at: 2024-02-15T14:01:26+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:3.3.0:jar (default-jar) on project demo: Execution default-jar of goal org.apache.maven.plugins:maven-jar-plugin:3.3.0:jar failed: Invalid project.build.outputTimestamp value '2024-02-15T13:54:59+0100': Text '2024-02-15T13:54:59+0100' could not be parsed, unparsed text found at index 22 -> [Help 1]

I can see it in the plugins output that the wrong value is generated:

...
[INFO] --- git-commit-id-maven-plugin:7.0.1-SNAPSHOT:revision (default) @ demo ---
[INFO] dotGitDirectory 'C:\git\stuff\git-plugin-timestamp-problem-demo\.git'
[INFO] Collected git.build.user.name with value cXXXXXX mXXXXXXX
[INFO] Collected git.build.user.email with value cXXXXXX.mXXXXXXX@example.com
[INFO] Collected git.branch with value master
[INFO] Collected git.commit.id.describe with value 3c5db83
[INFO] Collected git.commit.id.describe-short with value 3c5db83
[INFO] Collected git.commit.id with value 3c5db8321936ee5ca766b584e67cd002ca4b76a4
[INFO] Collected git.commit.id.abbrev with value 3c5db83
[INFO] Collected git.dirty with value false
[INFO] Collected git.commit.user.name with value cXXXXXX mXXXXXXX
[INFO] Collected git.commit.user.email with value cXXXXXX.mXXXXXXX@example.com
[INFO] Collected git.commit.message.full with value initial commit
[INFO] Collected git.commit.message.short with value initial commit
[INFO] Collected git.commit.time with value 2024-02-15T13:54:59+0100
[INFO] Collected git.commit.author.time with value 2024-02-15T13:54:59+0100
[INFO] Collected git.commit.committer.time with value 2024-02-15T13:54:59+0100
[INFO] Collected git.remote.origin.url with value null
[INFO] Collected git.tags with value 
[INFO] Collected git.closest.tag.name with value 
[INFO] Collected git.closest.tag.commit.count with value 
[INFO] Collected git.total.commit.count with value 1
[INFO] Collected git.local.branch.ahead with value NO_REMOTE
...

What am I missing/doing wrong?? Again thank you for your investigations and effort, I really appreciate it 👍

@TheSnoozer
Copy link
Collaborator

Mhhh.
The following sounds interesting in your error log:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:3.3.0:jar (default-jar) on project demo: Execution default-jar of goal org.apache.maven.plugins:maven-jar-plugin:3.3.0:jar failed: Invalid project.build.outputTimestamp value '2024-02-15T13:54:59+0100': Text '2024-02-15T13:54:59+0100' could not be parsed, unparsed text found at index 22 -> [Help 1]

That for me sounds like org.apache.maven.plugins:maven-jar-plugin can not deal with the Text '2024-02-15T13:54:59+0100'. However that test/date is conform with ISO8601.

The support for reproducible builds (ISO8601) should have been added to the maven-jar-plugin in version 3.2.X (via https://issues.apache.org/jira/browse/MJAR-263) and you are using the latest available version (3.3.0).

The documentation of the maven-jar-plugin (https://github.com/apache/maven-jar-plugin/blob/63f9c982d49f046519088490d7a8af5a7cd647fb/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java#L144) even claims it can process '2019-10-05T20:37:42+06:00'.

Maybe I'm going insane, but i think it would be worth to try your setup entirely WITHOUT the git-commit-id plugin.
So Instead of <project.build.outputTimestamp>${git.commit.time}</project.build.outputTimestamp> try the hard-coded <project.build.outputTimestamp>2024-02-15T13:54:59+0100</project.build.outputTimestamp>.

I'll try to troubleshoot this further with your reproducer too...

@TheSnoozer
Copy link
Collaborator

I have stripped down your demo project to a really minimal thing.
Got rid of the plugin, got rid of spring-boot (just to rule out any funky things) and hard-coded <project.build.outputTimestamp>2024-02-15T13:54:59+0100</project.build.outputTimestamp> (because why not we are experimenting).

Project:
git-plugin-timestamp-problem-demo_minimal.zip

$ mvn clean package
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.388 s
[INFO] Finished at: 2024-02-15T19:50:45+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:3.3.0:jar (default-jar) on project demo: Execution default-jar of goal org.apache.maven.plugins:maven-jar-plugin:3.3.0:jar failed: Invalid project.build.outputTimestamp value '2024-02-15T13:54:59+0100': Text '2024-02-15T13:54:59+0100' could not be parsed, unparsed text found at index 22 -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

Congratulation, you found an issue in the maven-jar-plugin! :-)

@TheSnoozer
Copy link
Collaborator

TheSnoozer commented Feb 15, 2024

Ohhhhhh we produce the time as 2024-02-15T13:54:59+0100, however with a extra colon in the TZ like 2024-02-15T13:54:59+01:00 it works.

Created https://issues.apache.org/jira/browse/MJAR-301.

@TheSnoozer
Copy link
Collaborator

Could you perhaps also experiment why your java version reports the time as 2024-02-15T13:54:59+0100 (without the :)?
The plugin should run roughtly the following:

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

public class Main {
  public static void main(String[] args) {
    String dateFormat = "yyyy-MM-dd'T'HH:mm:ssXXX";
    String dateFormatTimeZone = "GMT-01:00"; // can be null

    SimpleDateFormat smf = new SimpleDateFormat(dateFormat);
    if (dateFormatTimeZone != null) {
      smf.setTimeZone(TimeZone.getTimeZone(dateFormatTimeZone));
    }
    System.out.println(smf.format(new Date()));
  }
}

As per https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html#iso8601timezone the XXX should report as Sign TwoDigitHours : Minutes

Notes to myself:
https://github.com/FasterXML/ jackson-modules-java8 /issues/ 38
https://copyprogramming.com/howto/java-time-datetimeformatter-pattern-for-timezone-offset

@michael-o
Copy link

Read my answer in the JIRA issue. Straight away: 2024-02-15T13:54:59+0100 is invalid input because it does not comply with the extended date time offset format. Git devs fucked up back then and then they could not fix it anymore and were forced to introduce strict ISO 8601.

@Interessierter
Copy link
Author

Interessierter commented Feb 16, 2024

thanks for your feedback, let' recapitulate (I am in Germany so I use my timezone as an example):

  • 2024-02-15T13:54:59+0100 is RFC822-format which is produced by the SimpleDateFormat (SDF) format string yyyy-MM-dd'T'HH:mm:ssZ
  • 2024-02-15T13:54:59+01:00 is ISO8601-format which is produced by the SDF format string yyyy-MM-dd'T'HH:mm:ssXXX (there is an additional colon seperating the minutes from the hours

I would not have used the same words as @michael-o but yeah, using RFC822-format as default output format from the git-commit-id-plugin was probably not a good choice and should be changed in the next release to ISO8601 (see also my reasoning above and I am under the impression that you agree to that)

I still have the issue that, when used, the updated plugin does not work as expected, I am really lost at this as I have no knowledge how maven is doing things:

  1. just to check whats going on, I added the following line to the pl.project13.maven.git.GitCommitIdMojo#execute() method, just above the GitCommitIdPlugin.runPlugin invocation (its line 1415 locally):
      System.out.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX the plugin is used and the dateformat is: " + dateFormat);
  1. when I run the demo profile (thanks for the info, that was helpful 😀), i.e. mvn clean package -Pdemo -DskipTests I see that the output is
...
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX the plugin is used and the dateformat is: yyyy-MM-dd'T'HH:mm:ssXXX
...
[INFO] Using cached git.commit.time with value 2024-02-14T19:24:25+01:00
...

that is exactly like I would expect it to be and how it should be

  1. However, if I run the updated plugin in my reproducer-project from above (with no changes, I.e. there is no <dateFormat> configuration in the POM and I have the <project.build.outputTimestamp>${git.commit.time}</project.build.outputTimestamp> property set, the output is the following
...
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX the plugin is used and the dateformat is: yyyy-MM-dd'T'HH:mm:ssZ
...
[INFO] Collected git.commit.time with value 2024-02-15T13:54:59+0100
...

WTF is going on?! Where is he getting the wrong dateformat again from?? It must be set somewhere by some black Maven magic that I do know nothing of ;( I tried to debug it setting field watchpoint on pl.project13.maven.git.GitCommitIdMojo#dateFormat then running the demo profile in the plugin itself but it wasnt invoked. Do you have any idea??

@TheSnoozer
Copy link
Collaborator

Thanks everyone for your input.

First of all, I agree the plugin should change to ISO8601-formatted dates.

When running with mvn -X I see the following:

[DEBUG] Goal:          io.github.git-commit-id:git-commit-id-maven-plugin:7.0.1-SNAPSHOT:revision (default)
[DEBUG] Style:         Regular
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <abbrevLength default-value="7"/>
  <commitIdGenerationMode default-value="flat"/>
  <dateFormat default-value="yyyy-MM-dd&apos;T&apos;HH:mm:ssXXX">yyyy-MM-dd&apos;T&apos;HH:mm:ssZ</dateFormat>

My theory or the black maven magic that makes your date formatted like a 0100 comes I believe from your parent pom:
https://github.com/spring-projects/spring-boot/blob/4fd0e29cc8719bda72e0e67c2392fd48e7b4009d/spring-boot-project/spring-boot-starters/spring-boot-starter-parent/build.gradle#L151

I guess this should be changed to yyyy-MM-dd'T'HH:mm:ssXXX

mhalbritter pushed a commit to spring-projects/spring-boot that referenced this issue Feb 28, 2024
Old formmat: yyyy-MM-dd'T'HH:mm:ssZ, RFC 822
New format:  yyyy-MM-dd'T'HH:mm:ssXXX ISO 8601

Related to git-commit-id/git-commit-id-maven-plugin#674.

This change is required to make the times produced by the
git-commit-id-maven-plugin usable for Maven's reproducible builds,
see https://maven.apache.org/guides/mini/guide-reproducible-builds.html.

Timestamp for reproducible output archive entries must either formatted
as ISO 8601 or as an int representing seconds since the epoch.

Example usage might be

   <properties>
     <project.build.outputTimestamp>${git.commit.time}</project.build.outputTimestamp>
   </properties>

See gh-39606
TheSnoozer added a commit that referenced this issue Feb 28, 2024
#674: change timeformat from RFC822 to ISO 8601 to support maven's reproducible build feature
@TheSnoozer TheSnoozer added this to the 7.0.1 milestone Feb 28, 2024
@TheSnoozer
Copy link
Collaborator

Thanks again for the report and your patience with me.

The sprint boot has updated the default format to yyyy-MM-dd'T'HH:mm:ssXXX (see here).
I also just merged the changes in the plugin to update to the same format.

So thanks again, I'm going ahead and close the ticket now :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants