This is an automated email from the ASF dual-hosted git repository. joshtynjala pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
The following commit(s) were added to refs/heads/develop by this push: new 8e67663 compiler-jx: minor refactor to call a function for each compilation unit instead of putting everything directly in the loop 8e67663 is described below commit 8e67663b109a09fe8bd47ee5528e055a67bd392a Author: Josh Tynjala <joshtynj...@apache.org> AuthorDate: Tue Jan 25 10:13:16 2022 -0800 compiler-jx: minor refactor to call a function for each compilation unit instead of putting everything directly in the loop This function will eventually be used for a file system watcher that recompiles only changed compilation units --- .../royale/compiler/clients/JSConfiguration.java | 32 +++++ .../apache/royale/compiler/clients/MXMLJSC.java | 140 +++++++++++---------- .../royale/compiler/clients/MXMLJSCNative.java | 106 ++++++++-------- .../royale/compiler/clients/MXMLJSCNode.java | 106 ++++++++-------- .../royale/compiler/clients/MXMLJSCRoyale.java | 106 ++++++++-------- .../compiler/clients/MXMLJSCRoyaleCordova.java | 106 ++++++++-------- 6 files changed, 329 insertions(+), 267 deletions(-) diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/JSConfiguration.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/JSConfiguration.java index 874fdea..94f9e17 100644 --- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/JSConfiguration.java +++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/JSConfiguration.java @@ -28,6 +28,7 @@ import java.util.Map; import org.apache.royale.compiler.clients.MXMLJSC.JSTargetType; import org.apache.royale.compiler.config.Configuration; +import org.apache.royale.compiler.config.ConfigurationBuffer; import org.apache.royale.compiler.config.ConfigurationValue; import org.apache.royale.compiler.exceptions.ConfigurationException; import org.apache.royale.compiler.exceptions.ConfigurationException.CannotOpen; @@ -114,6 +115,25 @@ public class JSConfiguration extends Configuration } // + // 'watch' + // + + private boolean watch = false; + + public boolean getWatch() + { + return watch; + } + + @Config + @Mapping("watch") + public void setWatch(ConfigurationValue cv, boolean value) + throws ConfigurationException + { + watch = value; + } + + // // 'source-map' // @@ -633,4 +653,16 @@ public class JSConfiguration extends Configuration jsxFactory = value; } + @Override + public void validate(ConfigurationBuffer configurationBuffer) throws ConfigurationException + { + super.validate(configurationBuffer); + + if (getWatch() && !debug()) + { + List<ConfigurationValue> values = configurationBuffer.getVar("watch"); + throw new ConfigurationException.VariableMissingRequirement("debug=true", values.get(0).getVar(), values.get(0).getSource(), + values.get(0).getLine()); + } + } } diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSC.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSC.java index 1b86589..33cfb43 100644 --- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSC.java +++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSC.java @@ -554,73 +554,7 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, ((RoyaleJSTarget)target).collectRemoteClassMetaData(project.remoteClassAliasMap, reachableCompilationUnits); for (final ICompilationUnit cu : reachableCompilationUnits) { - ICompilationUnit.UnitType cuType = cu.getCompilationUnitType(); - - if (cuType == ICompilationUnit.UnitType.AS_UNIT - || cuType == ICompilationUnit.UnitType.MXML_UNIT) - { - final File outputClassFile = getOutputClassFile( - cu.getQualifiedNames().get(0), outputFolder); - - if (config.isVerbose()) - { - System.out.println("Compiling file: " + outputClassFile); - } - - ICompilationUnit unit = cu; - - IJSWriter writer; - if (cuType == ICompilationUnit.UnitType.AS_UNIT) - { - writer = (IJSWriter) project.getBackend().createWriter(project, - errors, unit, false); - } - else - { - writer = (IJSWriter) project.getBackend().createMXMLWriter( - project, errors, unit, false); - } - - BufferedOutputStream out = new BufferedOutputStream( - new FileOutputStream(outputClassFile)); - - BufferedOutputStream sourceMapOut = null; - File outputSourceMapFile = null; - if (project.config.getSourceMap()) - { - outputSourceMapFile = getOutputSourceMapFile( - cu.getQualifiedNames().get(0), outputFolder); - sourceMapOut = new BufferedOutputStream( - new FileOutputStream(outputSourceMapFile)); - } - - writer.writeTo(out, sourceMapOut, outputSourceMapFile); - out.flush(); - out.close(); - if (sourceMapOut != null) - { - sourceMapOut.flush(); - sourceMapOut.close(); - } - writer.close(); - long fileDate = 0; - String metadataDate = targetSettings.getSWFMetadataDate(); - if (metadataDate != null) - { - String metadataFormat = targetSettings.getSWFMetadataDateFormat(); - try { - SimpleDateFormat sdf = new SimpleDateFormat(metadataFormat); - sdf.setTimeZone(TimeZone.getTimeZone("UTC")); - fileDate = sdf.parse(metadataDate).getTime(); - } catch (ParseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalArgumentException e1) { - e1.printStackTrace(); - } - outputClassFile.setLastModified(fileDate); - } - } + writeCompilationUnit(cu, outputFolder); ClosureUtils.collectPropertyNamesToKeep(cu, project, closurePropNamesToKeep); ClosureUtils.collectSymbolNamesToExport(cu, project, closureSymbolNamesToExport); } @@ -647,6 +581,78 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, return compilationSuccess; } + protected void writeCompilationUnit(ICompilationUnit cu, File outputFolder) throws InterruptedException, IOException + { + ICompilationUnit.UnitType cuType = cu.getCompilationUnitType(); + if (cuType != ICompilationUnit.UnitType.AS_UNIT + && cuType != ICompilationUnit.UnitType.MXML_UNIT) + { + return; + } + + final File outputClassFile = getOutputClassFile( + cu.getQualifiedNames().get(0), outputFolder); + + if (config.isVerbose()) + { + System.out.println("Compiling file: " + outputClassFile); + } + + ICompilationUnit unit = cu; + + IJSWriter writer; + if (cuType == ICompilationUnit.UnitType.AS_UNIT) + { + writer = (IJSWriter) project.getBackend().createWriter(project, + problems.getProblems(), unit, false); + } + else + { + writer = (IJSWriter) project.getBackend().createMXMLWriter( + project, problems.getProblems(), unit, false); + } + + BufferedOutputStream out = new BufferedOutputStream( + new FileOutputStream(outputClassFile)); + + BufferedOutputStream sourceMapOut = null; + File outputSourceMapFile = null; + if (project.config.getSourceMap()) + { + outputSourceMapFile = getOutputSourceMapFile( + cu.getQualifiedNames().get(0), outputFolder); + sourceMapOut = new BufferedOutputStream( + new FileOutputStream(outputSourceMapFile)); + } + + writer.writeTo(out, sourceMapOut, outputSourceMapFile); + out.flush(); + out.close(); + if (sourceMapOut != null) + { + sourceMapOut.flush(); + sourceMapOut.close(); + } + writer.close(); + long fileDate = 0; + String metadataDate = targetSettings.getSWFMetadataDate(); + if (metadataDate != null) + { + String metadataFormat = targetSettings.getSWFMetadataDateFormat(); + try { + SimpleDateFormat sdf = new SimpleDateFormat(metadataFormat); + sdf.setTimeZone(TimeZone.getTimeZone("UTC")); + fileDate = sdf.parse(metadataDate).getTime(); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalArgumentException e1) { + e1.printStackTrace(); + } + outputClassFile.setLastModified(fileDate); + } + } + /** * Build target artifact. * diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCNative.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCNative.java index 1a92629..6da3da8 100644 --- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCNative.java +++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCNative.java @@ -337,56 +337,7 @@ public class MXMLJSCNative implements JSCompilerEntryPoint, ProblemQueryProvider ((RoyaleJSTarget)target).collectMixinMetaData(project.mixinClassNames, reachableCompilationUnits); for (final ICompilationUnit cu : reachableCompilationUnits) { - ICompilationUnit.UnitType cuType = cu.getCompilationUnitType(); - - if (cuType == ICompilationUnit.UnitType.AS_UNIT - || cuType == ICompilationUnit.UnitType.MXML_UNIT) - { - final File outputClassFile = getOutputClassFile( - cu.getQualifiedNames().get(0), outputFolder); - - if (config.isVerbose()) - { - System.out.println("Compiling file: " + outputClassFile); - } - - ICompilationUnit unit = cu; - - IJSWriter writer; - if (cuType == ICompilationUnit.UnitType.AS_UNIT) - { - writer = (IJSWriter) project.getBackend().createWriter(project, - errors, unit, false); - } - else - { - writer = (IJSWriter) project.getBackend().createMXMLWriter( - project, errors, unit, false); - } - - BufferedOutputStream out = new BufferedOutputStream( - new FileOutputStream(outputClassFile)); - - BufferedOutputStream sourceMapOut = null; - File outputSourceMapFile = null; - if (project.config.getSourceMap()) - { - outputSourceMapFile = getOutputSourceMapFile( - cu.getQualifiedNames().get(0), outputFolder); - sourceMapOut = new BufferedOutputStream( - new FileOutputStream(outputSourceMapFile)); - } - - writer.writeTo(out, sourceMapOut, outputSourceMapFile); - out.flush(); - out.close(); - if (sourceMapOut != null) - { - sourceMapOut.flush(); - sourceMapOut.close(); - } - writer.close(); - } + writeCompilationUnit(cu, outputFolder); ClosureUtils.collectPropertyNamesToKeep(cu, project, closurePropNamesToKeep); ClosureUtils.collectSymbolNamesToExport(cu, project, closureSymbolNamesToExport); } @@ -413,6 +364,61 @@ public class MXMLJSCNative implements JSCompilerEntryPoint, ProblemQueryProvider return compilationSuccess; } + protected void writeCompilationUnit(ICompilationUnit cu, File outputFolder) throws InterruptedException, FileNotFoundException, IOException + { + ICompilationUnit.UnitType cuType = cu.getCompilationUnitType(); + if (cuType != ICompilationUnit.UnitType.AS_UNIT + && cuType != ICompilationUnit.UnitType.MXML_UNIT) + { + return; + } + + final File outputClassFile = getOutputClassFile( + cu.getQualifiedNames().get(0), outputFolder); + + if (config.isVerbose()) + { + System.out.println("Compiling file: " + outputClassFile); + } + + ICompilationUnit unit = cu; + + IJSWriter writer; + if (cuType == ICompilationUnit.UnitType.AS_UNIT) + { + writer = (IJSWriter) project.getBackend().createWriter(project, + problems.getProblems(), unit, false); + } + else + { + writer = (IJSWriter) project.getBackend().createMXMLWriter( + project, problems.getProblems(), unit, false); + } + + BufferedOutputStream out = new BufferedOutputStream( + new FileOutputStream(outputClassFile)); + + BufferedOutputStream sourceMapOut = null; + File outputSourceMapFile = null; + if (project.config.getSourceMap()) + { + outputSourceMapFile = getOutputSourceMapFile( + cu.getQualifiedNames().get(0), outputFolder); + sourceMapOut = new BufferedOutputStream( + new FileOutputStream(outputSourceMapFile)); + } + + writer.writeTo(out, sourceMapOut, outputSourceMapFile); + out.flush(); + out.close(); + if (sourceMapOut != null) + { + sourceMapOut.flush(); + sourceMapOut.close(); + } + writer.close(); + } + /** * Build target artifact. * diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCNode.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCNode.java index 32132b4..918a3d6 100644 --- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCNode.java +++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCNode.java @@ -339,56 +339,7 @@ public class MXMLJSCNode implements JSCompilerEntryPoint, ProblemQueryProvider, ((RoyaleJSTarget)target).collectMixinMetaData(project.mixinClassNames, reachableCompilationUnits); for (final ICompilationUnit cu : reachableCompilationUnits) { - ICompilationUnit.UnitType cuType = cu.getCompilationUnitType(); - - if (cuType == ICompilationUnit.UnitType.AS_UNIT - || cuType == ICompilationUnit.UnitType.MXML_UNIT) - { - final File outputClassFile = getOutputClassFile( - cu.getQualifiedNames().get(0), outputFolder); - - if (config.isVerbose()) - { - System.out.println("Compiling file: " + outputClassFile); - } - - ICompilationUnit unit = cu; - - IJSWriter writer; - if (cuType == ICompilationUnit.UnitType.AS_UNIT) - { - writer = (IJSWriter) project.getBackend().createWriter(project, - errors, unit, false); - } - else - { - writer = (IJSWriter) project.getBackend().createMXMLWriter( - project, errors, unit, false); - } - - BufferedOutputStream out = new BufferedOutputStream( - new FileOutputStream(outputClassFile)); - - BufferedOutputStream sourceMapOut = null; - File outputSourceMapFile = null; - if (project.config.getSourceMap()) - { - outputSourceMapFile = getOutputSourceMapFile( - cu.getQualifiedNames().get(0), outputFolder); - sourceMapOut = new BufferedOutputStream( - new FileOutputStream(outputSourceMapFile)); - } - - writer.writeTo(out, sourceMapOut, outputSourceMapFile); - out.flush(); - out.close(); - if (sourceMapOut != null) - { - sourceMapOut.flush(); - sourceMapOut.close(); - } - writer.close(); - } + writeCompilationUnit(cu, outputFolder); ClosureUtils.collectPropertyNamesToKeep(cu, project, closurePropNamesToKeep); ClosureUtils.collectSymbolNamesToExport(cu, project, closureSymbolNamesToExport); } @@ -415,6 +366,61 @@ public class MXMLJSCNode implements JSCompilerEntryPoint, ProblemQueryProvider, return compilationSuccess; } + protected void writeCompilationUnit(ICompilationUnit cu, File outputFolder) throws InterruptedException, IOException + { + ICompilationUnit.UnitType cuType = cu.getCompilationUnitType(); + if (cuType != ICompilationUnit.UnitType.AS_UNIT + && cuType != ICompilationUnit.UnitType.MXML_UNIT) + { + return; + } + + final File outputClassFile = getOutputClassFile( + cu.getQualifiedNames().get(0), outputFolder); + + if (config.isVerbose()) + { + System.out.println("Compiling file: " + outputClassFile); + } + + ICompilationUnit unit = cu; + + IJSWriter writer; + if (cuType == ICompilationUnit.UnitType.AS_UNIT) + { + writer = (IJSWriter) project.getBackend().createWriter(project, + problems.getProblems(), unit, false); + } + else + { + writer = (IJSWriter) project.getBackend().createMXMLWriter( + project, problems.getProblems(), unit, false); + } + + BufferedOutputStream out = new BufferedOutputStream( + new FileOutputStream(outputClassFile)); + + BufferedOutputStream sourceMapOut = null; + File outputSourceMapFile = null; + if (project.config.getSourceMap()) + { + outputSourceMapFile = getOutputSourceMapFile( + cu.getQualifiedNames().get(0), outputFolder); + sourceMapOut = new BufferedOutputStream( + new FileOutputStream(outputSourceMapFile)); + } + + writer.writeTo(out, sourceMapOut, outputSourceMapFile); + out.flush(); + out.close(); + if (sourceMapOut != null) + { + sourceMapOut.flush(); + sourceMapOut.close(); + } + writer.close(); + } + /** * Build target artifact. * diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCRoyale.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCRoyale.java index 69b3b98..cf1a615 100644 --- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCRoyale.java +++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCRoyale.java @@ -373,56 +373,7 @@ public class MXMLJSCRoyale implements JSCompilerEntryPoint, ProblemQueryProvider } for (final ICompilationUnit cu : reachableCompilationUnits) { - ICompilationUnit.UnitType cuType = cu.getCompilationUnitType(); - - if (cuType == ICompilationUnit.UnitType.AS_UNIT - || cuType == ICompilationUnit.UnitType.MXML_UNIT) - { - final File outputClassFile = getOutputClassFile( - cu.getQualifiedNames().get(0), outputFolder); - - if (config.isVerbose()) - { - System.out.println("Compiling file: " + outputClassFile); - } - - ICompilationUnit unit = cu; - - IJSWriter writer; - if (cuType == ICompilationUnit.UnitType.AS_UNIT) - { - writer = (IJSWriter) project.getBackend().createWriter(project, - problems.getProblems(), unit, false); - } - else - { - writer = (IJSWriter) project.getBackend().createMXMLWriter( - project, problems.getProblems(), unit, false); - } - - BufferedOutputStream out = new BufferedOutputStream( - new FileOutputStream(outputClassFile)); - - BufferedOutputStream sourceMapOut = null; - File outputSourceMapFile = null; - if (project.config.getSourceMap()) - { - outputSourceMapFile = getOutputSourceMapFile( - cu.getQualifiedNames().get(0), outputFolder); - sourceMapOut = new BufferedOutputStream( - new FileOutputStream(outputSourceMapFile)); - } - - writer.writeTo(out, sourceMapOut, outputSourceMapFile); - out.flush(); - out.close(); - if (sourceMapOut != null) - { - sourceMapOut.flush(); - sourceMapOut.close(); - } - writer.close(); - } + writeCompilationUnit(cu, outputFolder); ClosureUtils.collectPropertyNamesToKeep(cu, project, closurePropNamesToKeep); ClosureUtils.collectSymbolNamesToExport(cu, project, closureSymbolNamesToExport); } @@ -464,6 +415,61 @@ public class MXMLJSCRoyale implements JSCompilerEntryPoint, ProblemQueryProvider return compilationSuccess && (errs.size() == 0); } + protected void writeCompilationUnit(ICompilationUnit cu, File outputFolder) throws InterruptedException, IOException + { + ICompilationUnit.UnitType cuType = cu.getCompilationUnitType(); + if (cuType != ICompilationUnit.UnitType.AS_UNIT + && cuType != ICompilationUnit.UnitType.MXML_UNIT) + { + return; + } + + final File outputClassFile = getOutputClassFile( + cu.getQualifiedNames().get(0), outputFolder); + + if (config.isVerbose()) + { + System.out.println("Compiling file: " + outputClassFile); + } + + ICompilationUnit unit = cu; + + IJSWriter writer; + if (cuType == ICompilationUnit.UnitType.AS_UNIT) + { + writer = (IJSWriter) project.getBackend().createWriter(project, + problems.getProblems(), unit, false); + } + else + { + writer = (IJSWriter) project.getBackend().createMXMLWriter( + project, problems.getProblems(), unit, false); + } + + BufferedOutputStream out = new BufferedOutputStream( + new FileOutputStream(outputClassFile)); + + BufferedOutputStream sourceMapOut = null; + File outputSourceMapFile = null; + if (project.config.getSourceMap()) + { + outputSourceMapFile = getOutputSourceMapFile( + cu.getQualifiedNames().get(0), outputFolder); + sourceMapOut = new BufferedOutputStream( + new FileOutputStream(outputSourceMapFile)); + } + + writer.writeTo(out, sourceMapOut, outputSourceMapFile); + out.flush(); + out.close(); + if (sourceMapOut != null) + { + sourceMapOut.flush(); + sourceMapOut.close(); + } + writer.close(); + } + private void generateExternsReport(File externsReportFile, List<ICompilationUnit> reachableCompilationUnits, ProblemQuery problems) { diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCRoyaleCordova.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCRoyaleCordova.java index a508ec2..5014d70 100644 --- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCRoyaleCordova.java +++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCRoyaleCordova.java @@ -342,56 +342,7 @@ public class MXMLJSCRoyaleCordova implements JSCompilerEntryPoint, ProblemQueryP ((RoyaleJSTarget)target).collectMixinMetaData(project.mixinClassNames, reachableCompilationUnits); for (final ICompilationUnit cu : reachableCompilationUnits) { - ICompilationUnit.UnitType cuType = cu.getCompilationUnitType(); - - if (cuType == ICompilationUnit.UnitType.AS_UNIT - || cuType == ICompilationUnit.UnitType.MXML_UNIT) - { - final File outputClassFile = getOutputClassFile( - cu.getQualifiedNames().get(0), outputFolder); - - if (config.isVerbose()) - { - System.out.println("Compiling file: " + outputClassFile); - } - - ICompilationUnit unit = cu; - - IJSWriter writer; - if (cuType == ICompilationUnit.UnitType.AS_UNIT) - { - writer = (IJSWriter) project.getBackend().createWriter(project, - errors, unit, false); - } - else - { - writer = (IJSWriter) project.getBackend().createMXMLWriter( - project, errors, unit, false); - } - - BufferedOutputStream out = new BufferedOutputStream( - new FileOutputStream(outputClassFile)); - - BufferedOutputStream sourceMapOut = null; - File outputSourceMapFile = null; - if (project.config.getSourceMap()) - { - outputSourceMapFile = getOutputSourceMapFile( - cu.getQualifiedNames().get(0), outputFolder); - sourceMapOut = new BufferedOutputStream( - new FileOutputStream(outputSourceMapFile)); - } - - writer.writeTo(out, sourceMapOut, outputSourceMapFile); - out.flush(); - out.close(); - if (sourceMapOut != null) - { - sourceMapOut.flush(); - sourceMapOut.close(); - } - writer.close(); - } + writeCompilationUnit(cu, outputFolder); ClosureUtils.collectPropertyNamesToKeep(cu, project, closurePropNamesToKeep); ClosureUtils.collectSymbolNamesToExport(cu, project, closureSymbolNamesToExport); } @@ -418,6 +369,61 @@ public class MXMLJSCRoyaleCordova implements JSCompilerEntryPoint, ProblemQueryP return compilationSuccess; } + protected void writeCompilationUnit(ICompilationUnit cu, File outputFolder) throws InterruptedException, IOException + { + ICompilationUnit.UnitType cuType = cu.getCompilationUnitType(); + if (cuType != ICompilationUnit.UnitType.AS_UNIT + && cuType != ICompilationUnit.UnitType.MXML_UNIT) + { + return; + } + + final File outputClassFile = getOutputClassFile( + cu.getQualifiedNames().get(0), outputFolder); + + if (config.isVerbose()) + { + System.out.println("Compiling file: " + outputClassFile); + } + + ICompilationUnit unit = cu; + + IJSWriter writer; + if (cuType == ICompilationUnit.UnitType.AS_UNIT) + { + writer = (IJSWriter) project.getBackend().createWriter(project, + problems.getProblems(), unit, false); + } + else + { + writer = (IJSWriter) project.getBackend().createMXMLWriter( + project, problems.getProblems(), unit, false); + } + + BufferedOutputStream out = new BufferedOutputStream( + new FileOutputStream(outputClassFile)); + + BufferedOutputStream sourceMapOut = null; + File outputSourceMapFile = null; + if (project.config.getSourceMap()) + { + outputSourceMapFile = getOutputSourceMapFile( + cu.getQualifiedNames().get(0), outputFolder); + sourceMapOut = new BufferedOutputStream( + new FileOutputStream(outputSourceMapFile)); + } + + writer.writeTo(out, sourceMapOut, outputSourceMapFile); + out.flush(); + out.close(); + if (sourceMapOut != null) + { + sourceMapOut.flush(); + sourceMapOut.close(); + } + writer.close(); + } + /** * Build target artifact. *