[
https://issues.apache.org/jira/browse/MJAR-300?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17816455#comment-17816455
]
Michael Osipov edited comment on MJAR-300 at 2/11/24 11:01 PM:
---------------------------------------------------------------
I believe that there is a misunderstanding from your end. [~hboutemy] and me
are intentionally writing UTC time into local time in the ZIP file to have a
consistent value. {{jar(1)}}, {{zip(1)}}, {{bsdtar(1)}} think that this is
local time which it is not.
Compare New York and Moscow:
{noformat}
osipovmi@deblndw011x:/tmp/MJAR-300 (main %=)
$ DATE=$(TZ=America/New_York date -Iseconds) ; echo $DATE ; JAVA_VERSION=11
TZ=America/New_York mvn -q -Dproject.build.outputTimestamp=$DATE clean package
; TZ=America/New_York jar tvf target/jartest-0.1-SNAPSHOT.jar
2024-02-11T16:05:54-05:00
0 Sun Feb 11 21:05:54 EST 2024 META-INF/
703 Sun Feb 11 21:05:54 EST 2024 META-INF/MANIFEST.MF
0 Sun Feb 11 21:05:54 EST 2024 META-INF/maven/
0 Sun Feb 11 21:05:54 EST 2024 META-INF/maven/jartest/
0 Sun Feb 11 21:05:54 EST 2024 META-INF/maven/jartest/jartest/
5 Sun Feb 11 21:05:54 EST 2024 testfile.txt
575 Sun Feb 11 21:05:54 EST 2024 META-INF/maven/jartest/jartest/pom.xml
56 Sun Feb 11 21:05:54 EST 2024
META-INF/maven/jartest/jartest/pom.properties
osipovmi@deblndw011x:/tmp/MJAR-300 (main %=)
$ DATE=$(TZ=Europe/Moscow date -Iseconds) ; echo $DATE ; JAVA_VERSION=11
TZ=Europe/Moscow mvn -q -Dproject.build.outputTimestamp=$DATE clean package ;
TZ=Europe/Moscow jar tvf target/jartest-0.1-SNAPSHOT.jar
2024-02-12T00:06:41+03:00
0 Sun Feb 11 21:06:40 MSK 2024 META-INF/
703 Sun Feb 11 21:06:40 MSK 2024 META-INF/MANIFEST.MF
0 Sun Feb 11 21:06:40 MSK 2024 META-INF/maven/
0 Sun Feb 11 21:06:40 MSK 2024 META-INF/maven/jartest/
0 Sun Feb 11 21:06:40 MSK 2024 META-INF/maven/jartest/jartest/
5 Sun Feb 11 21:06:40 MSK 2024 testfile.txt
575 Sun Feb 11 21:06:40 MSK 2024 META-INF/maven/jartest/jartest/pom.xml
56 Sun Feb 11 21:06:40 MSK 2024
META-INF/maven/jartest/jartest/pom.properties
{noformat}
You can ignore the three-letter RFC timezone name. It has no meaning in this
context. Here, stil lthe same value:
{noformat}
osipovmi@deblndw011x:/tmp/MJAR-300 (main %=)
$ tar -zvtf target/jartest-0.1-SNAPSHOT.jar
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/
-rw-r--r-- 0 0 0 703 11 Feb. 21:06 META-INF/MANIFEST.MF
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/maven/
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/maven/jartest/
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/maven/jartest/jartest/
-rw-r--r-- 0 0 0 5 11 Feb. 21:06 testfile.txt
-rw-r--r-- 0 0 0 575 11 Feb. 21:06
META-INF/maven/jartest/jartest/pom.xml
-rw-r--r-- 0 0 0 56 11 Feb. 21:06
META-INF/maven/jartest/jartest/pom.properties
osipovmi@deblndw011x:/tmp/MJAR-300 (main %=)
$ TZ=America/New_York tar -zvtf target/jartest-0.1-SNAPSHOT.jar
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/
-rw-r--r-- 0 0 0 703 11 Feb. 21:06 META-INF/MANIFEST.MF
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/maven/
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/maven/jartest/
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/maven/jartest/jartest/
-rw-r--r-- 0 0 0 5 11 Feb. 21:06 testfile.txt
-rw-r--r-- 0 0 0 575 11 Feb. 21:06
META-INF/maven/jartest/jartest/pom.xml
-rw-r--r-- 0 0 0 56 11 Feb. 21:06
META-INF/maven/jartest/jartest/pom.properties
osipovmi@deblndw011x:/tmp/MJAR-300 (main %=)
$ TZ=Europe/Moscow tar -zvtf target/jartest-0.1-SNAPSHOT.jar
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/
-rw-r--r-- 0 0 0 703 11 Feb. 21:06 META-INF/MANIFEST.MF
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/maven/
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/maven/jartest/
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/maven/jartest/jartest/
-rw-r--r-- 0 0 0 5 11 Feb. 21:06 testfile.txt
-rw-r--r-- 0 0 0 575 11 Feb. 21:06
META-INF/maven/jartest/jartest/pom.xml
-rw-r--r-- 0 0 0 56 11 Feb. 21:06
META-INF/maven/jartest/jartest/pom.properties
osipovmi@deblndw011x:/tmp/MJAR-300 (main %=)
$ TZ=Asia/Tokyo tar -zvtf target/jartest-0.1-SNAPSHOT.jar
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/
-rw-r--r-- 0 0 0 703 11 Feb. 21:06 META-INF/MANIFEST.MF
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/maven/
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/maven/jartest/
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/maven/jartest/jartest/
-rw-r--r-- 0 0 0 5 11 Feb. 21:06 testfile.txt
-rw-r--r-- 0 0 0 575 11 Feb. 21:06
META-INF/maven/jartest/jartest/pom.xml
-rw-r--r-- 0 0 0 56 11 Feb. 21:06
META-INF/maven/jartest/jartest/pom.properties
{noformat}
{{jar(1)}} is fooling you here.
was (Author: michael-o):
I believe that there is a misunderstanding from your end. [~hboutemy] and me
are intentionally writing UTC time into local time in the ZIP file to have a
consistent value. {{jar(1)}}, {{zip(1)}}, {{bsdtar(1)}} think that this is
local time which it is not.
Compare New York and Moscow:
{noformat}
osipovmi@deblndw011x:/tmp/MJAR-300 (main %=)
$ DATE=$(TZ=America/New_York date -Iseconds) ; echo $DATE ; JAVA_VERSION=11
TZ=America/New_York mvn -q -Dproject.build.outputTimestamp=$DATE clean package
; TZ=America/New_York jar tvf target/jartest-0.1-SNAPSHOT.jar
2024-02-11T16:05:54-05:00
0 Sun Feb 11 21:05:54 EST 2024 META-INF/
703 Sun Feb 11 21:05:54 EST 2024 META-INF/MANIFEST.MF
0 Sun Feb 11 21:05:54 EST 2024 META-INF/maven/
0 Sun Feb 11 21:05:54 EST 2024 META-INF/maven/jartest/
0 Sun Feb 11 21:05:54 EST 2024 META-INF/maven/jartest/jartest/
5 Sun Feb 11 21:05:54 EST 2024 testfile.txt
575 Sun Feb 11 21:05:54 EST 2024 META-INF/maven/jartest/jartest/pom.xml
56 Sun Feb 11 21:05:54 EST 2024
META-INF/maven/jartest/jartest/pom.properties
osipovmi@deblndw011x:/tmp/MJAR-300 (main %=)
$ DATE=$(TZ=Europe/Moscow date -Iseconds) ; echo $DATE ; JAVA_VERSION=11
TZ=Europe/Moscow mvn -q -Dproject.build.outputTimestamp=$DATE clean package ;
TZ=Europe/Moscow jar tvf target/jartest-0.1-SNAPSHOT.jar
2024-02-12T00:06:41+03:00
0 Sun Feb 11 21:06:40 MSK 2024 META-INF/
703 Sun Feb 11 21:06:40 MSK 2024 META-INF/MANIFEST.MF
0 Sun Feb 11 21:06:40 MSK 2024 META-INF/maven/
0 Sun Feb 11 21:06:40 MSK 2024 META-INF/maven/jartest/
0 Sun Feb 11 21:06:40 MSK 2024 META-INF/maven/jartest/jartest/
5 Sun Feb 11 21:06:40 MSK 2024 testfile.txt
575 Sun Feb 11 21:06:40 MSK 2024 META-INF/maven/jartest/jartest/pom.xml
56 Sun Feb 11 21:06:40 MSK 2024
META-INF/maven/jartest/jartest/pom.properties
{noformat}
You can ignore the three-letter RFC timezone name. It has no meaning in this
context. Here, stil lthe same value:
{noformat}
osipovmi@deblndw011x:/tmp/MJAR-300 (main %=)
$ tar -zvtf target/jartest-0.1-SNAPSHOT.jar
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/
-rw-r--r-- 0 0 0 703 11 Feb. 21:06 META-INF/MANIFEST.MF
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/maven/
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/maven/jartest/
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/maven/jartest/jartest/
-rw-r--r-- 0 0 0 5 11 Feb. 21:06 testfile.txt
-rw-r--r-- 0 0 0 575 11 Feb. 21:06
META-INF/maven/jartest/jartest/pom.xml
-rw-r--r-- 0 0 0 56 11 Feb. 21:06
META-INF/maven/jartest/jartest/pom.properties
osipovmi@deblndw011x:/tmp/MJAR-300 (main %=)
$ TZ=America/New_York tar -zvtf target/jartest-0.1-SNAPSHOT.jar
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/
-rw-r--r-- 0 0 0 703 11 Feb. 21:06 META-INF/MANIFEST.MF
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/maven/
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/maven/jartest/
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/maven/jartest/jartest/
-rw-r--r-- 0 0 0 5 11 Feb. 21:06 testfile.txt
-rw-r--r-- 0 0 0 575 11 Feb. 21:06
META-INF/maven/jartest/jartest/pom.xml
-rw-r--r-- 0 0 0 56 11 Feb. 21:06
META-INF/maven/jartest/jartest/pom.properties
osipovmi@deblndw011x:/tmp/MJAR-300 (main %=)
$ TZ=Europe/Moscow tar -zvtf target/jartest-0.1-SNAPSHOT.jar
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/
-rw-r--r-- 0 0 0 703 11 Feb. 21:06 META-INF/MANIFEST.MF
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/maven/
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/maven/jartest/
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/maven/jartest/jartest/
-rw-r--r-- 0 0 0 5 11 Feb. 21:06 testfile.txt
-rw-r--r-- 0 0 0 575 11 Feb. 21:06
META-INF/maven/jartest/jartest/pom.xml
-rw-r--r-- 0 0 0 56 11 Feb. 21:06
META-INF/maven/jartest/jartest/pom.properties
osipovmi@deblndw011x:/tmp/MJAR-300 (main %=)
$ TZ=Asia/Tokyo tar -zvtf target/jartest-0.1-SNAPSHOT.jar
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/
-rw-r--r-- 0 0 0 703 11 Feb. 21:06 META-INF/MANIFEST.MF
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/maven/
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/maven/jartest/
drwxr-xr-x 0 0 0 0 11 Feb. 21:06 META-INF/maven/jartest/jartest/
-rw-r--r-- 0 0 0 5 11 Feb. 21:06 testfile.txt
-rw-r--r-- 0 0 0 575 11 Feb. 21:06
META-INF/maven/jartest/jartest/pom.xml
-rw-r--r-- 0 0 0 56 11 Feb. 21:06
META-INF/maven/jartest/jartest/pom.properties
{noformat}
> maven jar plugin does not interpret build outputTimestamp correctly
> -------------------------------------------------------------------
>
> Key: MJAR-300
> URL: https://issues.apache.org/jira/browse/MJAR-300
> Project: Maven JAR Plugin
> Issue Type: Bug
> Affects Versions: 3.3.0
> Reporter: Henning Schmiedehausen
> Priority: Major
>
> consider a minimal project that packages a jar:
> % DATE=$(date -Iseconds) ; echo $DATE ; mvn -q clean package ; jar tvf
> target/jartest-0.1-SNAPSHOT.jar
> 2024-02-10T21:44:53-08:00
> 0 Sat Feb 10 21:44:54 PST 2024 META-INF/
> 568 Sat Feb 10 21:44:54 PST 2024 META-INF/MANIFEST.MF
> 0 Sat Feb 10 21:44:54 PST 2024 META-INF/maven/
> 0 Sat Feb 10 21:44:54 PST 2024 META-INF/maven/jartest/
> 0 Sat Feb 10 21:44:54 PST 2024 META-INF/maven/jartest/jartest/
> 5 Sat Feb 10 21:44:54 PST 2024 testfile.txt
> 575 Sat Feb 10 21:39:50 PST 2024 META-INF/maven/jartest/jartest/pom.xml
> 56 Sat Feb 10 21:44:54 PST 2024
> META-INF/maven/jartest/jartest/pom.properties
> Note how the timestamp returned by the date command and the timestamps of the
> entries in the jar are basically the same (around 21:44:53 - 21:44:54 on Feb
> 10th, 2024)
> Now use that date as the project build timestamp:
> DATE=$(date -Iseconds) ; echo $DATE ; mvn -q
> -Dproject.build.outputTimestamp=$DATE clean package ; jar tvf
> target/jartest-0.1-SNAPSHOT.jar
> 2024-02-10T21:46:30-08:00
> 0 Sun Feb 11 05:46:30 PST 2024 META-INF/
> 568 Sun Feb 11 05:46:30 PST 2024 META-INF/MANIFEST.MF
> 0 Sun Feb 11 05:46:30 PST 2024 META-INF/maven/
> 0 Sun Feb 11 05:46:30 PST 2024 META-INF/maven/jartest/
> 0 Sun Feb 11 05:46:30 PST 2024 META-INF/maven/jartest/jartest/
> 5 Sun Feb 11 05:46:30 PST 2024 testfile.txt
> 575 Sun Feb 11 05:46:30 PST 2024 META-INF/maven/jartest/jartest/pom.xml
> 56 Sun Feb 11 05:46:30 PST 2024
> META-INF/maven/jartest/jartest/pom.properties
>
> The timestamp and the entries in the jar differ by eight hours (the offset of
> my local timezone).
> When forcing UTC:
> DATE=$(TZ=UTC date -Iseconds) ; echo $DATE ; mvn -q
> -Dproject.build.outputTimestamp=$DATE clean package ; jar tvf
> target/jartest-0.1-SNAPSHOT.jar
> 2024-02-11T05:48:22+00:00
> 0 Sun Feb 11 05:48:22 PST 2024 META-INF/
> 568 Sun Feb 11 05:48:22 PST 2024 META-INF/MANIFEST.MF
> 0 Sun Feb 11 05:48:22 PST 2024 META-INF/maven/
> 0 Sun Feb 11 05:48:22 PST 2024 META-INF/maven/jartest/
> 0 Sun Feb 11 05:48:22 PST 2024 META-INF/maven/jartest/jartest/
> 5 Sun Feb 11 05:48:22 PST 2024 testfile.txt
> 575 Sun Feb 11 05:48:22 PST 2024 META-INF/maven/jartest/jartest/pom.xml
> 56 Sun Feb 11 05:48:22 PST 2024
> META-INF/maven/jartest/jartest/pom.properties
> The timestamp is "correct" but I passed it in as UTC but the jar plugin
> considers it "local time" and silently attaches PST as timezone. This is
> where the eight hours discrepancy come from.
> This seems to be specific to the outputTimestamp parsing of the jar plugin.
>
>
>
>
>
>
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)