You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ah...@apache.org on 2019/05/26 00:36:44 UTC

[royale-compiler] 01/02: can't clip timezone off file timestamps

This is an automated email from the ASF dual-hosted git repository.

aharui pushed a commit to branch release_practice
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit 1272a1ad9483607ff34f71deaee2b7ca261c6b69
Author: Alex Harui <ah...@apache.org>
AuthorDate: Sat May 25 17:36:11 2019 -0700

    can't clip timezone off file timestamps
---
 .../apache/royale/compiler/clients/COMPJSC.java    | 30 ++++++++++++---
 .../royale/compiler/clients/COMPJSCRoyale.java     | 44 ++++++++++++++++++----
 2 files changed, 62 insertions(+), 12 deletions(-)

diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSC.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSC.java
index 75e10fd..9791e09 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSC.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSC.java
@@ -475,10 +475,20 @@ public class COMPJSC extends MXMLJSC
                                     false).getPath();
 	                        System.out.println("Writing file: " + outputClassFile);     	
 	                        long fileDate = System.currentTimeMillis();
+	                        long zipFileDate = fileDate;
 	                    	String metadataDate = targetSettings.getSWFMetadataDate();
 	                    	if (metadataDate != null)
 	                    	{
 	                    		String metadataFormat = targetSettings.getSWFMetadataDateFormat();
+	                    		try {
+	                    			SimpleDateFormat sdf = new SimpleDateFormat(metadataFormat);
+	                    			fileDate = sdf.parse(metadataDate).getTime();
+	                    		} catch (ParseException e) {
+	                				// TODO Auto-generated catch block
+	                				e.printStackTrace();
+	                			} catch (IllegalArgumentException e1) {
+	                				e1.printStackTrace();
+	                			}
 	                    		// strip off timezone.  Zip format doesn't store timezone
 	                    		// and the goal is to have the same date and time regardless
 	                    		// of which timezone the build machine is using.
@@ -488,7 +498,7 @@ public class COMPJSC extends MXMLJSC
 	                    		metadataFormat = metadataFormat.substring(0, c);
 	                    		try {
 	                    			SimpleDateFormat sdf = new SimpleDateFormat(metadataFormat);
-	                    			fileDate = sdf.parse(metadataDate).getTime();
+	                    			zipFileDate = sdf.parse(metadataDate).getTime();
 	                    		} catch (ParseException e) {
 	                				// TODO Auto-generated catch block
 	                				e.printStackTrace();
@@ -497,7 +507,7 @@ public class COMPJSC extends MXMLJSC
 	                			}
 	                    	}
 	                    	ZipEntry ze = new ZipEntry(outputClassFile);
-	                    	ze.setTime(fileDate);
+	                    	ze.setTime(zipFileDate);
 	                        zipOutputStream.putNextEntry(ze);
 	                        temp.writeTo(zipOutputStream);
                             zipOutputStream.flush();
@@ -511,7 +521,7 @@ public class COMPJSC extends MXMLJSC
                                     false).getPath();
                                 System.out.println("Writing file: " + sourceMapFile);
                                 ze = new ZipEntry(sourceMapFile);
-    	                    	ze.setTime(fileDate);
+    	                    	ze.setTime(zipFileDate);
                                 zipOutputStream.putNextEntry(ze);
                                 sourceMapTemp.writeTo(zipOutputStream);
                                 zipOutputStream.flush();
@@ -526,10 +536,20 @@ public class COMPJSC extends MXMLJSC
                 {
                 	zipFile.close();
                     long fileDate = System.currentTimeMillis();
+                    long zipFileDate = fileDate;
                 	String metadataDate = targetSettings.getSWFMetadataDate();
                 	if (metadataDate != null)
                 	{
                 		String metadataFormat = targetSettings.getSWFMetadataDateFormat();
+                		try {
+                			SimpleDateFormat sdf = new SimpleDateFormat(metadataFormat);
+                			fileDate = sdf.parse(metadataDate).getTime();
+                		} catch (ParseException e) {
+            				// TODO Auto-generated catch block
+            				e.printStackTrace();
+            			} catch (IllegalArgumentException e1) {
+            				e1.printStackTrace();
+            			}
                 		// strip off timezone.  Zip format doesn't store timezone
                 		// and the goal is to have the same date and time regardless
                 		// of which timezone the build machine is using.
@@ -539,7 +559,7 @@ public class COMPJSC extends MXMLJSC
                 		metadataFormat = metadataFormat.substring(0, c);
                 		try {
                 			SimpleDateFormat sdf = new SimpleDateFormat(metadataFormat);
-                			fileDate = sdf.parse(metadataDate).getTime();
+                			zipFileDate = sdf.parse(metadataDate).getTime();
                 		} catch (ParseException e) {
             				// TODO Auto-generated catch block
             				e.printStackTrace();
@@ -552,7 +572,7 @@ public class COMPJSC extends MXMLJSC
                 		"    <files>\n" + fileList.toString() + "    </files>" + 
                 		catalog.substring(libraryIndex + 13);
                 	ZipEntry ze = new ZipEntry(SWCReader.CATALOG_XML);
-                	ze.setTime(fileDate);
+                	ze.setTime(zipFileDate);
                     zipOutputStream.putNextEntry(ze);
                 	zipOutputStream.write(catalog.getBytes());
                     zipOutputStream.flush();
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCRoyale.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCRoyale.java
index 3d991f1..4c15b42 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCRoyale.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCRoyale.java
@@ -210,10 +210,20 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
                         	InputStream input = zipFile.getInputStream(entry);
                         	ZipEntry ze = new ZipEntry(entry.getName());
 	                        long fileDate = System.currentTimeMillis();
+	                        long zipFileDate = fileDate;
 	                    	String metadataDate = targetSettings.getSWFMetadataDate();
 	                    	if (metadataDate != null)
 	                    	{
 	                    		String metadataFormat = targetSettings.getSWFMetadataDateFormat();
+	                    		try {
+	                    			SimpleDateFormat sdf = new SimpleDateFormat(metadataFormat);
+	                    			fileDate = sdf.parse(metadataDate).getTime();
+	                    		} catch (ParseException e) {
+	                				// TODO Auto-generated catch block
+	                				e.printStackTrace();
+	                			} catch (IllegalArgumentException e1) {
+	                				e1.printStackTrace();
+	                			}
 	                    		// strip off timezone.  Zip format doesn't store timezone
 	                    		// and the goal is to have the same date and time regardless
 	                    		// of which timezone the build machine is using.
@@ -223,7 +233,7 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
 	                    		metadataFormat = metadataFormat.substring(0, c);
 	                    		try {
 	                    			SimpleDateFormat sdf = new SimpleDateFormat(metadataFormat);
-	                    			fileDate = sdf.parse(metadataDate).getTime();
+	                    			zipFileDate = sdf.parse(metadataDate).getTime();
 	                    		} catch (ParseException e) {
 	                				// TODO Auto-generated catch block
 	                				e.printStackTrace();
@@ -231,7 +241,7 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
 	                				e1.printStackTrace();
 	                			}
 	                    	}
-	                    	ze.setTime(fileDate);
+	                    	ze.setTime(zipFileDate);
                         	zipOutputStream.putNextEntry(ze);
                         	IOUtils.copy(input, zipOutputStream);
                             zipOutputStream.flush();
@@ -361,10 +371,20 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
                                     false).getPath();
 	                        System.out.println("Writing file: " + outputClassFile);     	
 	                        long fileDate = System.currentTimeMillis();
+	                        long zipFileDate = fileDate;
 	                    	String metadataDate = targetSettings.getSWFMetadataDate();
 	                    	if (metadataDate != null)
 	                    	{
 	                    		String metadataFormat = targetSettings.getSWFMetadataDateFormat();
+	                    		try {
+	                    			SimpleDateFormat sdf = new SimpleDateFormat(metadataFormat);
+	                    			fileDate = sdf.parse(metadataDate).getTime();
+	                    		} catch (ParseException e) {
+	                				// TODO Auto-generated catch block
+	                				e.printStackTrace();
+	                			} catch (IllegalArgumentException e1) {
+	                				e1.printStackTrace();
+	                			}
 	                    		// strip off timezone.  Zip format doesn't store timezone
 	                    		// and the goal is to have the same date and time regardless
 	                    		// of which timezone the build machine is using.
@@ -374,7 +394,7 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
 	                    		metadataFormat = metadataFormat.substring(0, c);
 	                    		try {
 	                    			SimpleDateFormat sdf = new SimpleDateFormat(metadataFormat);
-	                    			fileDate = sdf.parse(metadataDate).getTime();
+	                    			zipFileDate = sdf.parse(metadataDate).getTime();
 	                    		} catch (ParseException e) {
 	                				// TODO Auto-generated catch block
 	                				e.printStackTrace();
@@ -383,7 +403,7 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
 	                			}
 	                    	}
 	                    	ZipEntry ze = new ZipEntry(outputClassFile);
-	                    	ze.setTime(fileDate);
+	                    	ze.setTime(zipFileDate);
 	                        zipOutputStream.putNextEntry(ze);
 	                        temp.writeTo(zipOutputStream);
                             zipOutputStream.flush();
@@ -397,7 +417,7 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
                                     false).getPath();
                                 System.out.println("Writing file: " + sourceMapFile);  
                                 ze = new ZipEntry(sourceMapFile);
-    	                    	ze.setTime(fileDate);
+    	                    	ze.setTime(zipFileDate);
                                 zipOutputStream.putNextEntry(ze);
                                 sourceMapTemp.writeTo(zipOutputStream);
                                 zipOutputStream.flush();
@@ -420,10 +440,20 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
                 {
                 	zipFile.close();
                     long fileDate = System.currentTimeMillis();
+                    long zipFileDate = fileDate;
                 	String metadataDate = targetSettings.getSWFMetadataDate();
                 	if (metadataDate != null)
                 	{
                 		String metadataFormat = targetSettings.getSWFMetadataDateFormat();
+                		try {
+                			SimpleDateFormat sdf = new SimpleDateFormat(metadataFormat);
+                			fileDate = sdf.parse(metadataDate).getTime();
+                		} catch (ParseException e) {
+            				// TODO Auto-generated catch block
+            				e.printStackTrace();
+            			} catch (IllegalArgumentException e1) {
+            				e1.printStackTrace();
+            			}
                 		// strip off timezone.  Zip format doesn't store timezone
                 		// and the goal is to have the same date and time regardless
                 		// of which timezone the build machine is using.
@@ -433,7 +463,7 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
                 		metadataFormat = metadataFormat.substring(0, c);
                 		try {
                 			SimpleDateFormat sdf = new SimpleDateFormat(metadataFormat);
-                			fileDate = sdf.parse(metadataDate).getTime();
+                			zipFileDate = sdf.parse(metadataDate).getTime();
                 		} catch (ParseException e) {
             				// TODO Auto-generated catch block
             				e.printStackTrace();
@@ -446,7 +476,7 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
                 		"    <files>\n" + fileList.toString() + "    </files>" + 
                 		catalog.substring(libraryIndex + 13);
                 	ZipEntry ze = new ZipEntry(SWCReader.CATALOG_XML);
-                	ze.setTime(fileDate);
+                	ze.setTime(zipFileDate);
                     zipOutputStream.putNextEntry(ze);
                 	zipOutputStream.write(catalog.getBytes());
                     zipOutputStream.flush();