Skip to content
This repository has been archived by the owner on Mar 23, 2022. It is now read-only.

Add support for preserving timestamps on compression #51

Open
allthecodes opened this issue Aug 23, 2012 · 0 comments
Open

Add support for preserving timestamps on compression #51

allthecodes opened this issue Aug 23, 2012 · 0 comments

Comments

@allthecodes
Copy link

Currently there's no support to carry over the timestamp from the input file to the output file.

Below is a patch to achieve this:

diff --git a/src/main/java/net_alchim31_maven_yuicompressor/YuiCompressorMojo.java b/src/main/java/net_alchim31_maven_yuicompressor/YuiCompressorMojo.java
index d62b47a..d97e2fb 100644
--- a/src/main/java/net_alchim31_maven_yuicompressor/YuiCompressorMojo.java
+++ b/src/main/java/net_alchim31_maven_yuicompressor/YuiCompressorMojo.java
@@ -47,8 +47,17 @@ public class YuiCompressorMojo extends MojoSupport {
*
* @parameter expression="${maven.yuicompressor.nosuffix}" default-value="false"
*/
+
private boolean nosuffix;

  • /**

  • \* If maintainTimestamps is true, the timestamps found on the files will be reapplied after compression
    
  • \* 
    
  • \* @parameter expression="${maven.yuicompressor.maintainTimestamps}" default-value="true"
    
  • */
    
  • private boolean maintainTimestamps;

  • /**

    • Insert line breaks in output after the specified column number.
      *
      @@ -172,6 +181,7 @@ public class YuiCompressorMojo extends MojoSupport {
      getLog().debug("compress file :" + src.toFile()+ " to " + src.toDestFile(suffix));
      }
      File inFile = src.toFile();
  •    Long inFileTimestamp = inFile.lastModified();
     File outFile = src.toDestFile(suffix);
    
     getLog().debug("only compress if input file is younger than existing output file");
    

    @@ -212,6 +222,10 @@ public class YuiCompressorMojo extends MojoSupport {
    }
    FileUtils.forceDelete(outFile);
    FileUtils.rename(outFileTmp, outFile);

  •    if (maintainTimestamps)
    
  •    {
    
  •       outFile.setLastModified(inFileTimestamp);
    
  •    }
     File gzipped = gzipIfRequested(outFile);
     if (statistics) {
         inSizeTotal_ += inFile.length();
    
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant