[ 
https://issues.apache.org/jira/browse/MJAR-300?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17816898#comment-17816898
 ] 

Herve Boutemy commented on MJAR-300:
------------------------------------

Maven Archiver objective is done to zip content from disk, and used in a RB-way 
does the timezone trick to get stable output binary (zip entry binary output): 
perhaps what you need is to see the introduction of the trick in 
plexus-archiver for zip entries (not needed for tar, because tar is UTC based, 
not local TZ based)
= 
https://github.com/codehaus-plexus/plexus-archiver/pull/121/files#diff-fdf6dd4c4d1490cc1e2c75fb0b704f6e727d73fba728d8a16725dff8cabf503c

I found one way to perhaps show the issue with DOS-based zip format that does 
not know about TZ:
on the same .zip file, looking at content from different TZ shows different 
values:
{noformat}
$ for TZ in Asia/Kolkata Europe/Paris ; do sudo timedatectl set-timezone $TZ ; 
unzip -l plexus-utils-1.0.4.jar | grep MANIFEST ; jar tvf 
plexus-utils-1.0.4.jar | grep MANIFEST ; done
      286  2005-10-12 03:57   META-INF/MANIFEST.MF
   286 Wed Oct 12 03:57:46 IST 2005 META-INF/MANIFEST.MF
      286  2005-10-12 03:57   META-INF/MANIFEST.MF
   286 Wed Oct 12 03:57:46 CEST 2005 META-INF/MANIFEST.MF
{noformat}
jar command is better than unzip command, because it makes TZ explicit: zip 
format is unaware of timezone, then considers it is the machine default timezone

If you want to mimic Maven Archiver to have binary-stable zip entries, you'll 
need to write an equivalent of  normalizeLastModifiedDate()
= 
https://github.com/codehaus-plexus/plexus-archiver/blob/master/src/main/java/org/codehaus/plexus/archiver/zip/AbstractZipArchiver.java#L688
 currently

> 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)

Reply via email to