[izpack-changes] r1743 - in izpack-src/trunk: . src src/lib/com/izforge/izpack/compiler src/lib/com/izforge/izpack/util

noreply at berlios.de noreply at berlios.de
Sat Feb 17 14:51:03 CET 2007


Author: jponge
Date: 2007-02-17 14:50:49 +0100 (Sat, 17 Feb 2007)
New Revision: 1743

Modified:
   izpack-src/trunk/Versions.txt
   izpack-src/trunk/src/build.xml
   izpack-src/trunk/src/lib/com/izforge/izpack/compiler/MultiVolumePackager.java
   izpack-src/trunk/src/lib/com/izforge/izpack/compiler/Packager.java
   izpack-src/trunk/src/lib/com/izforge/izpack/util/FileUtil.java
Log:
Modifications to keep original file dates and times in _dist directory and in the installer jar (Ari Voutilainen via Julien Ponge)


Modified: izpack-src/trunk/Versions.txt
===================================================================
--- izpack-src/trunk/Versions.txt	2007-02-17 13:47:35 UTC (rev 1742)
+++ izpack-src/trunk/Versions.txt	2007-02-17 13:50:49 UTC (rev 1743)
@@ -8,6 +8,8 @@
 - Fixed RegularExpressionValidator (Dennis Reil)
 - Added corrupt volume detection (Dennis Reil)
 - Added file and dir fields in UserInputPanel (Dennis Reil)
+- Modifications to keep original file dates and times in _dist directory and in the installer jar
+  (Ari Voutilainen via Julien Ponge)
 
 	> 3.10.1 (build 2007.xx.xx)
 	

Modified: izpack-src/trunk/src/build.xml
===================================================================
--- izpack-src/trunk/src/build.xml	2007-02-17 13:47:35 UTC (rev 1742)
+++ izpack-src/trunk/src/build.xml	2007-02-17 13:50:49 UTC (rev 1743)
@@ -160,6 +160,12 @@
   10.10.2006: (Fabrice Mirabile)   
 	  Fixed target src.tar.gz and clean.src.tar.gz
               
+  11.02.2007: (Ari Voutilainen)
+     Added 'preservelastmodified="true"' to all 'copy todir' commands to keep original file date
+     and time. This will effect in directory _dist. This won't effect to compiled files and
+     other files which are manipulated during the process.
+
+
   Mini-HowTo:
 
   To compile and package the compiler.jar jar file, type:
@@ -307,6 +313,7 @@
                 <include name="com/izforge/izpack/util/*Processor.class" />
                 <include name="com/izforge/izpack/util/VariableSubstitutor.class" />
                 <include name="com/izforge/izpack/util/JarOutputStream.class" />
+                <include name="com/izforge/izpack/util/FileUtil.class" />
                 <include name="com/izforge/izpack/ant/*.class" />
                 <include name="com/izforge/izpack/ant/langpacks/*.properties" />
                 <include name="com/izforge/izpack/event/CompilerListener.class" />
@@ -877,7 +884,7 @@
                 <exclude name="**/CVS" />
             </packageset>
         </javadoc>
-        <copy todir="${doc.dir}/izpack/javadoc">
+        <copy todir="${doc.dir}/izpack/javadoc" preservelastmodified="true">
             <fileset dir="${build.dir}/javadoc">
                 <include name="**/*" />
             </fileset>
@@ -886,7 +893,7 @@
 
     <target name="build.docu" description="Builds the customer documentation">
         <mkdir dir="${doc.dir}/izpack/xhtml" />
-        <copy todir="${doc.dir}/izpack/xhtml">
+        <copy todir="${doc.dir}/izpack/xhtml" preservelastmodified="true">
             <fileset dir="${basedir}/src/doc-ng/XHTML">
                 <include name="**/*" />
             </fileset>
@@ -920,17 +927,19 @@
         <mkdir dir="${basedir}/bin/native/izpack" />
         <!-- If unicode support of ShellLink.dll will be not used, change between  both copy blocks -->
         <!--
-		<copy todir="${basedir}/bin/native/izpack" file="${basedir}/src/native/ShellLink/Release/ShellLink.dll" verbose="true" overwrite="yes"/>
-		<copy todir="${basedir}/bin/native/3rdparty" file="${basedir}/src/native/win/COIOSHelper/Release/COIOSHelper.dll" verbose="true" overwrite="yes"/>
+		<copy todir="${basedir}/bin/native/izpack" file="${basedir}/src/native/ShellLink/Release/ShellLink.dll" verbose="true" overwrite="yes" preservelastmodified="true"/>
+		<copy todir="${basedir}/bin/native/3rdparty" file="${basedir}/src/native/win/COIOSHelper/Release/COIOSHelper.dll" verbose="true" overwrite="yes" preservelastmodified="true"/>
 		-->
         <copy todir="${basedir}/bin/native/izpack"
               file="${basedir}/src/native/ShellLink/Release_Unicode/ShellLink.dll"
               verbose="true"
-              overwrite="yes" />
+              overwrite="yes"
+              preservelastmodified="true" />
         <copy todir="${basedir}/bin/native/3rdparty"
               file="${basedir}/src/native/win/COIOSHelper/Release_Unicode/COIOSHelper.dll"
               verbose="true"
-              overwrite="yes" />
+              overwrite="yes"
+              preservelastmodified="true" />
     </target>
 
     
@@ -939,7 +948,7 @@
          - - - - - - - - - - - - - - - - - -->
     <target name="copy.dist.files">
         <echo message="Copies the general files to the dist directory" />
-        <copy todir="${dist.dir}" includeEmptyDirs="yes">
+        <copy todir="${dist.dir}" includeEmptyDirs="yes" preservelastmodified="true">
             <fileset dir="${basedir}">
                 <include name="bin/**" />
                 <include name="lib/*.jar" />
@@ -951,13 +960,13 @@
             </fileset>
         </copy>
         <echo message="Copies the langpacks to the dist directory" />
-        <copy todir="${dist.dir}/bin" includeEmptyDirs="yes">
+        <copy todir="${dist.dir}/bin" includeEmptyDirs="yes" preservelastmodified="true">
             <fileset dir="${basedir}">
                 <include name="langpacks/**" />
             </fileset>
         </copy>
         <echo message="Copies the license images and specs to the dist directory" />
-        <copy todir="${dist.dir}" includeEmptyDirs="yes">
+        <copy todir="${dist.dir}" includeEmptyDirs="yes" preservelastmodified="true">
             <fileset dir="${dist-files.dir}">
                 <include name="useNativeLAF" />
                 <include name="*.jpg" />
@@ -972,7 +981,7 @@
             </fileset>
         </copy>
         <echo message="Copies the bin files to the dist directory" />
-        <copy todir="${dist.dir}/bin" includeEmptyDirs="yes" overwrite="yes">
+        <copy todir="${dist.dir}/bin" includeEmptyDirs="yes" overwrite="yes" preservelastmodified="true">
             <fileset dir="${dist-files.dir}">
                 <include name="compile*" />            	
                 <include name="lcp.bat" />

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/compiler/MultiVolumePackager.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/compiler/MultiVolumePackager.java	2007-02-17 13:47:35 UTC (rev 1742)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/compiler/MultiVolumePackager.java	2007-02-17 13:50:49 UTC (rev 1743)
@@ -56,6 +56,7 @@
 import com.izforge.izpack.io.FileSpanningInputStream;
 import com.izforge.izpack.io.FileSpanningOutputStream;
 import com.izforge.izpack.util.Debug;
+import com.izforge.izpack.util.FileUtil;
 
 /**
  * The packager class. The packager is used by the compiler to put files into an installer, and
@@ -558,7 +559,13 @@
         {
             String name = (String) i.next();
             InputStream in = ((URL) installerResourceURLMap.get(name)).openStream();
-            primaryJarStream.putNextEntry(new ZipEntry(name));
+
+            org.apache.tools.zip.ZipEntry newEntry = new org.apache.tools.zip.ZipEntry(name);
+            long dateTime = FileUtil.getFileDateTime((URL) installerResourceURLMap.get(name));
+            if (dateTime != -1)
+                newEntry.setTime(dateTime);
+            primaryJarStream.putNextEntry(newEntry);
+
             copyStream(in, primaryJarStream);
             primaryJarStream.closeEntry();
             in.close();
@@ -819,7 +826,15 @@
             if (currentSet.contains(currentName)) continue;
             try
             {
-                out.putNextEntry(new ZipEntry(currentName));
+                // Create new entry for zip file.
+                ZipEntry newEntry = new ZipEntry(currentName);
+                // Get input file date and time.
+                long fileTime = zentry.getTime();
+                // Make sure there is date and time set.
+                if (fileTime != -1)
+                    newEntry.setTime(fileTime); // If found set it into output file.
+                out.putNextEntry(newEntry);
+
                 copyStream(zin, out);
                 out.closeEntry();
                 zin.closeEntry();
@@ -874,7 +889,15 @@
             if (currentSet.contains(currentName)) continue;
             try
             {
-                out.putNextEntry(new ZipEntry(currentName));
+                // Create new entry for zip file.
+                ZipEntry newEntry = new ZipEntry(currentName);
+                // Get input file date and time.
+                long fileTime = zentry.getTime();
+                // Make sure there is date and time set.
+                if (fileTime != -1)
+                    newEntry.setTime(fileTime); // If found set it into output file.
+                out.putNextEntry(newEntry);
+
                 copyStream(zin, out);
                 out.closeEntry();
                 zin.closeEntry();

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/compiler/Packager.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/compiler/Packager.java	2007-02-17 13:47:35 UTC (rev 1742)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/compiler/Packager.java	2007-02-17 13:50:49 UTC (rev 1743)
@@ -56,6 +56,7 @@
 import com.izforge.izpack.Panel;
 import com.izforge.izpack.compressor.PackCompressor;
 import com.izforge.izpack.compressor.PackCompressorFactory;
+import com.izforge.izpack.util.FileUtil;
 //import com.izforge.izpack.util.JarOutputStream;
 
 /**
@@ -425,7 +426,13 @@
         {
             String name = (String) i.next();
             InputStream in = ((URL) installerResourceURLMap.get(name)).openStream();
-            primaryJarStream.putNextEntry(new org.apache.tools.zip.ZipEntry(name));
+            
+            org.apache.tools.zip.ZipEntry newEntry = new org.apache.tools.zip.ZipEntry(name);
+            long dateTime = FileUtil.getFileDateTime((URL) installerResourceURLMap.get(name));
+            if (dateTime != -1)
+                newEntry.setTime(dateTime);
+            primaryJarStream.putNextEntry(newEntry);
+
             PackagerHelper.copyStream(in, primaryJarStream);
             primaryJarStream.closeEntry();
             in.close();
@@ -669,7 +676,15 @@
                 continue;
             try
             {
-                out.putNextEntry(new org.apache.tools.zip.ZipEntry(currentName));
+                // Create new entry for zip file.
+                org.apache.tools.zip.ZipEntry newEntry = new org.apache.tools.zip.ZipEntry(currentName);
+                // Get input file date and time.
+                long fileTime = zentry.getTime();
+                // Make sure there is date and time set.
+                if (fileTime != -1)
+                    newEntry.setTime(fileTime); // If found set it into output file.
+                out.putNextEntry(newEntry);
+
                 PackagerHelper.copyStream(zin, out);
                 out.closeEntry();
                 zin.closeEntry();

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/util/FileUtil.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/util/FileUtil.java	2007-02-17 13:47:35 UTC (rev 1742)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/util/FileUtil.java	2007-02-17 13:50:49 UTC (rev 1743)
@@ -29,7 +29,9 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 
+import java.net.URL;
 
+
 /**
  * Provides general global file utility methods
  *
@@ -159,7 +161,41 @@
 
     return result;
   }
+  
+  /**
+   * Gets file date and time.
+   *
+   * @param   url     The URL of the file for which date and time will be returned.
+   * @return  Returns long value which is the date and time of the file. If any error
+   *          occures returns -1 (=no file date and time available).
+   * @author  Ari Voutilainen, ari(dot)voutilainen(at) iki(dot)fi
+   */
+  public static long getFileDateTime(URL url)
+  {
+      if (url==null)
+          return -1;
 
+      String fileName = url.getFile();
+      if (fileName.charAt(0) == '/' || fileName.charAt(0) == '\\')
+          fileName = fileName.substring(1, fileName.length());
+
+      try
+      {
+          File file = new File(fileName);
+          // File name must be a file or a directory.
+          if (!file.isDirectory() && !file.isFile())
+          {
+              return -1;
+          }
+
+          return file.lastModified();
+      }
+      catch (java.lang.Exception e)
+      {   // Trap all Exception based exceptions and return -1.
+          return -1;
+      }
+  }
+
   /** 
    * Test main
    *




More information about the izpack-changes mailing list