@@ -465,7 +465,7 @@ protected void zipFile( InputStreamSupplier in, ConcurrentJarCreator zOut, Strin
465465 if ( !skipWriting )
466466 {
467467 ZipArchiveEntry ze = new ZipArchiveEntry ( vPath );
468- setTime ( ze , lastModified );
468+ setZipEntryTime ( ze , lastModified );
469469
470470 ze .setMethod ( doCompress ? ZipArchiveEntry .DEFLATED : ZipArchiveEntry .STORED );
471471 ze .setUnixMode ( UnixStat .FILE_FLAG | mode );
@@ -528,35 +528,26 @@ protected void zipFile( final ArchiveEntry entry, ConcurrentJarCreator zOut, Str
528528 }
529529 }
530530
531- protected void setTime ( ZipArchiveEntry zipEntry , long lastModified )
531+ /**
532+ * Set the ZipEntry dostime using the date if specified otherwise the original time.
533+ *
534+ * <p>Zip archives store file modification times with a granularity of two seconds, so the times will either be
535+ * rounded up or down. If you round down, the archive will always seem out-of-date when you rerun the task, so the
536+ * default is to round up. Rounding up may lead to a different type of problems like JSPs inside a web archive that
537+ * seem to be slightly more recent than precompiled pages, rendering precompilation useless.
538+ * plexus-archiver chooses to round up.
539+ *
540+ * @param zipEntry to set the last modified time
541+ * @param lastModifiedTime to set in the zip entry only if {@link #getLastModifiedTime()} returns null
542+ */
543+ protected void setZipEntryTime ( ZipArchiveEntry zipEntry , long lastModifiedTime )
532544 {
533545 if ( getLastModifiedTime () != null )
534546 {
535- lastModified = getLastModifiedTime ().toMillis ();
547+ lastModifiedTime = getLastModifiedTime ().toMillis ();
536548 }
537549
538- // Zip archives store file modification times with a
539- // granularity of two seconds, so the times will either be rounded
540- // up or down. If you round down, the archive will always seem
541- // out-of-date when you rerun the task, so the default is to round
542- // up. Rounding up may lead to a different type of problems like
543- // JSPs inside a web archive that seem to be slightly more recent
544- // than precompiled pages, rendering precompilation useless.
545- // plexus-archiver chooses to round up.
546- zipEntry .setTime ( lastModified + 1999 );
547-
548- /* Consider adding extended file stamp support.....
549-
550- X5455_ExtendedTimestamp ts = new X5455_ExtendedTimestamp();
551- ts.setModifyJavaTime(new Date(lastModified));
552- if (zipEntry.getExtra() != null){
553- // Uh-oh. What do we do now.
554- throw new IllegalStateException("DIdnt expect to see xtradata here ?");
555-
556- } else {
557- zipEntry.setExtra(ts.getLocalFileDataData());
558- }
559- */
550+ zipEntry .setTime ( lastModifiedTime + 1999 );
560551 }
561552
562553 protected void zipDir ( PlexusIoResource dir , ConcurrentJarCreator zOut , String vPath , int mode ,
@@ -595,12 +586,12 @@ protected void zipDir( PlexusIoResource dir, ConcurrentJarCreator zOut, String v
595586
596587 if ( dir != null && dir .isExisting () )
597588 {
598- setTime ( ze , dir .getLastModified () );
589+ setZipEntryTime ( ze , dir .getLastModified () );
599590 }
600591 else
601592 {
602593 // ZIPs store time with a granularity of 2 seconds, round up
603- setTime ( ze , System .currentTimeMillis () );
594+ setZipEntryTime ( ze , System .currentTimeMillis () );
604595 }
605596 if ( !isSymlink )
606597 {
0 commit comments