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 8880a06be8fc07ad023fd16732fcf4520af516e5 Author: Alex Harui <[email protected]> AuthorDate: Tue May 14 11:56:02 2019 -0700 try setting file dates on swc entries --- .../org/apache/royale/compiler/clients/ASDOC.java | 1 + .../org/apache/royale/compiler/clients/COMPC.java | 1 + .../java/org/apache/royale/swc/io/SWCWriter.java | 34 ++++++++++++++++++---- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/compiler/src/main/java/org/apache/royale/compiler/clients/ASDOC.java b/compiler/src/main/java/org/apache/royale/compiler/clients/ASDOC.java index 07d66f5..24a3b71 100644 --- a/compiler/src/main/java/org/apache/royale/compiler/clients/ASDOC.java +++ b/compiler/src/main/java/org/apache/royale/compiler/clients/ASDOC.java @@ -188,6 +188,7 @@ public class ASDOC extends MXMLC implements FlexTool { final ISWCWriter swcWriter = new SWCWriter(outputOptionValue, useCompression, targetSettings.isDebugEnabled(), targetSettings.isTelemetryEnabled(), + targetSettings.getSWFMetadataDate(), targetSettings.getSWFMetadataDateFormat(), SizeReportWritingSWFWriter.getSWFWriterFactory(targetSettings.getSizeReport())); swcWriter.write(swc); final File outputFile = new File(outputOptionValue); diff --git a/compiler/src/main/java/org/apache/royale/compiler/clients/COMPC.java b/compiler/src/main/java/org/apache/royale/compiler/clients/COMPC.java index ef06ba7..c8c320b 100644 --- a/compiler/src/main/java/org/apache/royale/compiler/clients/COMPC.java +++ b/compiler/src/main/java/org/apache/royale/compiler/clients/COMPC.java @@ -200,6 +200,7 @@ public class COMPC extends MXMLC implements FlexTool System.out.println("output swc as file"); final ISWCWriter swcWriter = new SWCWriter(outputOptionValue, useCompression, targetSettings.isDebugEnabled(), targetSettings.isTelemetryEnabled(), + targetSettings.getSWFMetadataDate(), targetSettings.getSWFMetadataDateFormat(), SizeReportWritingSWFWriter.getSWFWriterFactory(targetSettings.getSizeReport())); if ((CompilerDiagnosticsConstants.diagnostics & CompilerDiagnosticsConstants.COMPC_PHASES) == CompilerDiagnosticsConstants.COMPC_PHASES) System.out.println("attempting to write swc"); diff --git a/compiler/src/main/java/org/apache/royale/swc/io/SWCWriter.java b/compiler/src/main/java/org/apache/royale/swc/io/SWCWriter.java index 55ceff8..9509891 100644 --- a/compiler/src/main/java/org/apache/royale/swc/io/SWCWriter.java +++ b/compiler/src/main/java/org/apache/royale/swc/io/SWCWriter.java @@ -28,6 +28,8 @@ import java.io.InputStream; import java.io.OutputStreamWriter; import java.io.Writer; import java.security.DigestOutputStream; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.zip.Deflater; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; @@ -54,9 +56,9 @@ public class SWCWriter extends SWCWriterBase * * @param filename path to write the file to. */ - public SWCWriter(final String filename) throws FileNotFoundException + public SWCWriter(final String filename, String swcDate, String swcDateFormat) throws FileNotFoundException { - this(filename, true, true, false, SizeReportWritingSWFWriter.getSWFWriterFactory(null)); + this(filename, true, true, false, swcDate, swcDateFormat, SizeReportWritingSWFWriter.getSWFWriterFactory(null)); } /** @@ -71,6 +73,7 @@ public class SWCWriter extends SWCWriterBase boolean compressLibrarySWF, boolean enableDebug, boolean enableTelemetry, + String metadataDate, String metadataFormat, ISWFWriterFactory swfWriterFactory) throws FileNotFoundException { super(compressLibrarySWF, enableDebug, enableTelemetry, swfWriterFactory); @@ -80,6 +83,19 @@ public class SWCWriter extends SWCWriterBase File outputDirectory = new File(outputFile.getAbsoluteFile().getParent()); outputDirectory.mkdirs(); + if (metadataDate != null) + { + 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(); + } + } + zipOutputStream = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(filename))); zipOutputStream.setLevel(Deflater.NO_COMPRESSION); } @@ -88,11 +104,15 @@ public class SWCWriter extends SWCWriterBase * Target SWC output stream. */ private final ZipOutputStream zipOutputStream; + + private long fileDate = System.currentTimeMillis(); @Override void writeCatalog(final ISWC swc) throws IOException { - zipOutputStream.putNextEntry(new ZipEntry(CATALOG_XML)); + ZipEntry ze = new ZipEntry(CATALOG_XML); + ze.setTime(fileDate); + zipOutputStream.putNextEntry(ze); final Writer catalogXMLWriter = new OutputStreamWriter(zipOutputStream); writeCatalogXML(swc, catalogXMLWriter); catalogXMLWriter.flush(); @@ -107,7 +127,9 @@ public class SWCWriter extends SWCWriterBase assert swf != null : "Expect SWF model"; assert path != null : "Expect SWF path"; - zipOutputStream.putNextEntry(new ZipEntry(path)); + ZipEntry ze = new ZipEntry(path); + ze.setTime(fileDate); + zipOutputStream.putNextEntry(ze); final DigestOutputStream digestStream = getDigestOutputStream(library, zipOutputStream); @@ -125,7 +147,9 @@ public class SWCWriter extends SWCWriterBase @Override void writeFile(final ISWCFileEntry fileEntry) throws IOException { - zipOutputStream.putNextEntry(new ZipEntry(fileEntry.getPath())); + ZipEntry ze = new ZipEntry(fileEntry.getPath()); + ze.setTime(fileDate); + zipOutputStream.putNextEntry(ze); final InputStream fileInputStream = fileEntry.createInputStream(); IOUtils.copy(fileInputStream, zipOutputStream); fileInputStream.close();
