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

Henning Schmiedehausen commented on MJAR-300:
---------------------------------------------

This is a major (borderline blocking) bug for me as I have code that repackages 
jars. Without output timestamps, my repackaged jars look like this:

 jar tvf plugin/target/it/test-antlr/target/test-antlr-1.0.under-test.jar  | 
grep META-INF
     0 Sat Feb 10 21:31:20 PST 2024 META-INF/
     0 Sat Feb 10 21:31:20 PST 2024 META-INF/inlined/
     0 Sat Feb 10 21:31:20 PST 2024 META-INF/inlined/org.antlr/
     0 Sat Feb 10 21:31:20 PST 2024 META-INF/inlined/org.antlr/antlr4-runtime/
     0 Sat Feb 10 21:31:20 PST 2024 META-INF/maven/
     0 Sat Feb 10 21:31:20 PST 2024 META-INF/maven/org.antlr/
     0 Sat Feb 10 21:31:20 PST 2024 META-INF/maven/org.antlr/antlr4-runtime/
     0 Sat Feb 10 21:31:20 PST 2024 
META-INF/maven/org.basepom.maven.inline-maven-plugin/
     0 Sat Feb 10 21:31:20 PST 2024 
META-INF/maven/org.basepom.maven.inline-maven-plugin/test-antlr/
    81 Sat Feb 10 21:31:20 PST 2024 META-INF/MANIFEST.MF
  2607 Sat Feb 10 21:31:12 PST 2024 
META-INF/maven/org.basepom.maven.inline-maven-plugin/test-antlr/pom.xml
    91 Sat Feb 10 21:31:20 PST 2024 
META-INF/maven/org.basepom.maven.inline-maven-plugin/test-antlr/pom.properties

 

The last three lines of the jar come from the original jar, the first block is 
generated by the repackager.

With an output timestamp , this happens:

jar tvf 
plugin/target/it/test-antlr-reproducible/target/test-antlr-reproducible-1.0.under-test.jar
 | grep META-INF
     0 Sat Feb 10 15:37:52 PST 2024 META-INF/
     0 Sat Feb 10 15:37:52 PST 2024 META-INF/inlined/
     0 Sat Feb 10 15:37:52 PST 2024 META-INF/inlined/org.antlr/
     0 Sat Feb 10 15:37:52 PST 2024 META-INF/inlined/org.antlr/antlr4-runtime/
     0 Sat Feb 10 15:37:52 PST 2024 META-INF/maven/
     0 Sat Feb 10 15:37:52 PST 2024 META-INF/maven/org.antlr/
     0 Sat Feb 10 15:37:52 PST 2024 META-INF/maven/org.antlr/antlr4-runtime/
     0 Sat Feb 10 15:37:52 PST 2024 
META-INF/maven/org.basepom.maven.inline-maven-plugin/
     0 Sat Feb 10 15:37:52 PST 2024 
META-INF/maven/org.basepom.maven.inline-maven-plugin/test-antlr-reproducible/
    81 Sat Feb 10 23:37:52 PST 2024 META-INF/MANIFEST.MF
  2717 Sat Feb 10 23:37:52 PST 2024 
META-INF/maven/org.basepom.maven.inline-maven-plugin/test-antlr-reproducible/pom.xml
   104 Sat Feb 10 23:37:52 PST 2024 
META-INF/maven/org.basepom.maven.inline-maven-plugin/test-antlr-reproducible/pom.properties

The first block (generated by my code) has the correct timestamp. The last 
three lines (which come from a jar that was packaged with the maven-jar-plugin 
3.3.0) do not.  The timestamp is set by a property in the pom.

 

{*}technically{*}, this is a reproducible build. But it has a wrong, 
reproducible value (in fact every jar ever packaged with the jar plugin has 
wrong timestamps). 

 

 

 

 

> 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