You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ms...@apache.org on 2015/06/29 00:09:44 UTC

git commit: [flex-falcon] [refs/heads/develop] - Added IPublisher impl and JSCBackend - Refactored all Publisher creation to occur in the backend. - Created JSCBackend so we can have fine grained control of plain js creation and publishing. - For now,

Repository: flex-falcon
Updated Branches:
  refs/heads/develop 830d3c64f -> 7d2b63de7


Added IPublisher impl and JSCBackend
- Refactored all Publisher creation to occur in the backend.
- Created JSCBackend so we can have fine grained control of
  plain js creation and publishing.
- For now, just overrode writeHTML() on MXML publisher.


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/7d2b63de
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/7d2b63de
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/7d2b63de

Branch: refs/heads/develop
Commit: 7d2b63de73c0ee894e3429adfa884c668e5d266d
Parents: 830d3c6
Author: Michael Schmalle <ms...@apache.org>
Authored: Sun Jun 28 18:09:36 2015 -0400
Committer: Michael Schmalle <ms...@apache.org>
Committed: Sun Jun 28 18:09:36 2015 -0400

----------------------------------------------------------------------
 .../apache/flex/compiler/clients/MXMLJSC.java   | 188 ++++++-------
 .../flex/compiler/codegen/js/IJSPublisher.java  |   3 +-
 .../apache/flex/compiler/driver/IBackend.java   |  13 +-
 .../apache/flex/compiler/driver/IPublisher.java |  25 ++
 .../codegen/js/goog/JSGoogPublisher.java        |   2 +-
 .../internal/codegen/js/jsc/JSCJSEmitter.java   |   1 -
 .../internal/codegen/js/jsc/JSCPublisher.java   |  43 +++
 .../mxml/flexjs/MXMLFlexJSPublisher.java        | 266 +++++++++++--------
 .../compiler/internal/driver/as/ASBackend.java  |   8 +
 .../compiler/internal/driver/js/JSBackend.java  |   9 +
 .../driver/js/flexjs/FlexJSBackend.java         |   4 +-
 .../internal/driver/js/goog/GoogBackend.java    |  12 +
 .../internal/driver/js/jsc/JSCBackend.java      |  47 ++++
 .../driver/mxml/flexjs/MXMLFlexJSBackend.java   |  12 +-
 .../driver/mxml/vf2js/MXMLVF2JSBackend.java     |  13 +-
 15 files changed, 425 insertions(+), 221 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7d2b63de/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java b/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
index f39c4be..8677102 100644
--- a/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
+++ b/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
@@ -19,9 +19,18 @@
 
 package org.apache.flex.compiler.clients;
 
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
 import org.apache.commons.io.FilenameUtils;
 import org.apache.flex.compiler.clients.problems.ProblemPrinter;
 import org.apache.flex.compiler.clients.problems.ProblemQuery;
@@ -39,18 +48,14 @@ import org.apache.flex.compiler.exceptions.ConfigurationException;
 import org.apache.flex.compiler.exceptions.ConfigurationException.IOError;
 import org.apache.flex.compiler.exceptions.ConfigurationException.MustSpecifyTarget;
 import org.apache.flex.compiler.exceptions.ConfigurationException.OnlyOneSource;
-import org.apache.flex.compiler.internal.codegen.js.JSPublisher;
 import org.apache.flex.compiler.internal.codegen.js.JSSharedData;
-import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogPublisher;
-import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSPublisher;
-import org.apache.flex.compiler.internal.codegen.mxml.vf2js.MXMLVF2JSPublisher;
 import org.apache.flex.compiler.internal.config.FlashBuilderConfigurator;
 import org.apache.flex.compiler.internal.driver.as.ASBackend;
 import org.apache.flex.compiler.internal.driver.js.amd.AMDBackend;
 import org.apache.flex.compiler.internal.driver.js.goog.GoogBackend;
 import org.apache.flex.compiler.internal.driver.js.goog.JSGoogConfiguration;
+import org.apache.flex.compiler.internal.driver.js.jsc.JSCBackend;
 import org.apache.flex.compiler.internal.driver.mxml.flexjs.MXMLFlexJSBackend;
-import org.apache.flex.compiler.internal.driver.mxml.jsc.MXMLJSCJSBackend;
 import org.apache.flex.compiler.internal.driver.mxml.vf2js.MXMLVF2JSBackend;
 import org.apache.flex.compiler.internal.parsing.as.FlexJSASDocDelegate;
 import org.apache.flex.compiler.internal.projects.CompilerProject;
@@ -60,7 +65,11 @@ import org.apache.flex.compiler.internal.targets.JSTarget;
 import org.apache.flex.compiler.internal.units.ResourceModuleCompilationUnit;
 import org.apache.flex.compiler.internal.units.SourceCompilationUnitFactory;
 import org.apache.flex.compiler.internal.workspaces.Workspace;
-import org.apache.flex.compiler.problems.*;
+import org.apache.flex.compiler.problems.ConfigurationProblem;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.problems.InternalCompilerProblem;
+import org.apache.flex.compiler.problems.UnableToBuildSWFProblem;
+import org.apache.flex.compiler.problems.UnexpectedExceptionProblem;
 import org.apache.flex.compiler.projects.ICompilerProject;
 import org.apache.flex.compiler.targets.ITarget;
 import org.apache.flex.compiler.targets.ITarget.TargetType;
@@ -70,25 +79,34 @@ import org.apache.flex.tools.FlexTool;
 import org.apache.flex.utils.ArgumentUtil;
 import org.apache.flex.utils.FilenameNormalization;
 
-import java.io.*;
-import java.util.*;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
 
 /**
  * @author Erik de Bruin
  * @author Michael Schmalle
  */
-public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, FlexTool
+public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider,
+        FlexTool
 {
-    public ProblemQuery getProblemQuery() {
+    @Override
+    public ProblemQuery getProblemQuery()
+    {
         return problems;
     }
 
     /*
-		 * JS output type enumerations.
-		 */
+    	 * JS output type enumerations.
+    	 */
     public enum JSOutputType
     {
-        AMD("amd"), FLEXJS("flexjs"), GOOG("goog"), VF2JS("vf2js"), FLEXJS_DUAL("flexjs_dual"), JSC("jsc");
+        AMD("amd"),
+        FLEXJS("flexjs"),
+        GOOG("goog"),
+        VF2JS("vf2js"),
+        FLEXJS_DUAL("flexjs_dual"),
+        JSC("jsc");
 
         private String text;
 
@@ -137,12 +155,14 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, Flex
     public static boolean keepASDoc;
 
     @Override
-    public String getName() {
+    public String getName()
+    {
         return FLEX_TOOL_MXMLC;
     }
 
     @Override
-    public int execute(String[] args) {
+    public int execute(String[] args)
+    {
         final Set<ICompilerProblem> problems = new HashSet<ICompilerProblem>();
         return mainNoExit(args, problems, true);
     }
@@ -192,7 +212,7 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, Flex
             backend = new AMDBackend();
             break;
         case JSC:
-            backend = new MXMLJSCJSBackend();
+            backend = new JSCBackend();
             break;
         case FLEXJS:
         case FLEXJS_DUAL:
@@ -242,6 +262,7 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, Flex
         asFileHandler = backend.getSourceFileHandlerInstance();
     }
 
+    @Override
     public int mainNoExit(final String[] args, Set<ICompilerProblem> problems,
             Boolean printProblems)
     {
@@ -285,28 +306,30 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, Flex
         {
             String[] adjustedArgs = args;
 
-            if(jsOutputType != null) {
-                switch (jsOutputType) {
-                    case VF2JS:
-                        boolean isFlashBuilderProject = useFlashBuilderProjectFiles(args);
-
-                        if (isFlashBuilderProject) {
-                            adjustedArgs = FlashBuilderConfigurator
-                                    .computeFlashBuilderArgs(adjustedArgs,
-                                            getTargetType().getExtension());
-                        }
+            if (jsOutputType != null)
+            {
+                switch (jsOutputType)
+                {
+                case VF2JS:
+                    boolean isFlashBuilderProject = useFlashBuilderProjectFiles(args);
 
-                        //String projectFilePath = adjustedArgs[adjustedArgs.length - 1];
-                        //
-                        //String newProjectFilePath = VF2JSProjectUtils
-                        //        .createTempProject(projectFilePath,
-                        //                isFlashBuilderProject);
-                        //
-                        //adjustedArgs[adjustedArgs.length - 1] = newProjectFilePath;
+                    if (isFlashBuilderProject)
+                    {
+                        adjustedArgs = FlashBuilderConfigurator.computeFlashBuilderArgs(
+                                adjustedArgs, getTargetType().getExtension());
+                    }
 
-                        break;
-                    default:
-                        break;
+                    //String projectFilePath = adjustedArgs[adjustedArgs.length - 1];
+                    //
+                    //String newProjectFilePath = VF2JSProjectUtils
+                    //        .createTempProject(projectFilePath,
+                    //                isFlashBuilderProject);
+                    //
+                    //adjustedArgs[adjustedArgs.length - 1] = newProjectFilePath;
+
+                    break;
+                default:
+                    break;
                 }
             }
 
@@ -314,7 +337,7 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, Flex
 
             // ToDo (erikdebruin): use JSSharedData for globals ...
             keepASDoc = ((JSGoogConfiguration) config).getKeepASDoc();
-            
+
             if (outProblems != null && !config.isVerbose())
                 JSSharedData.STDOUT = JSSharedData.STDERR = null;
 
@@ -388,8 +411,8 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, Flex
 
             if (jsTarget != null)
             {
-                Collection<ICompilerProblem> errors = new ArrayList<ICompilerProblem>();
-                Collection<ICompilerProblem> warnings = new ArrayList<ICompilerProblem>();
+                List<ICompilerProblem> errors = new ArrayList<ICompilerProblem>();
+                List<ICompilerProblem> warnings = new ArrayList<ICompilerProblem>();
 
                 if (!config.getCreateTargetWithErrors())
                 {
@@ -398,37 +421,23 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, Flex
                         return false;
                 }
 
-                if(JSSharedData.backend instanceof MXMLFlexJSBackend) {
-                    jsPublisher = new MXMLFlexJSPublisher(config, project);
-                }
-                else if(JSSharedData.backend instanceof MXMLVF2JSBackend) {
-                    jsPublisher = new MXMLVF2JSPublisher(config, project);
-                }
-                else if(JSSharedData.backend instanceof GoogBackend) {
-                    jsPublisher = new JSGoogPublisher(config);
-                }
-                else {
-                    jsPublisher = new JSPublisher(config);
-                }
+                jsPublisher = (IJSPublisher) JSSharedData.backend.createPublisher(
+                        project, errors, config);
 
                 File outputFolder = jsPublisher.getOutputFolder();
 
-                List<ICompilationUnit> reachableCompilationUnits = project
-                        .getReachableCompilationUnitsInSWFOrder(ImmutableSet
-                                .of(mainCU));
+                List<ICompilationUnit> reachableCompilationUnits = project.getReachableCompilationUnitsInSWFOrder(ImmutableSet.of(mainCU));
                 for (final ICompilationUnit cu : reachableCompilationUnits)
                 {
-                    ICompilationUnit.UnitType cuType = cu
-                            .getCompilationUnitType();
+                    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);
+                        final File outputClassFile = getOutputClassFile(
+                                cu.getQualifiedNames().get(0), outputFolder);
 
-                        System.out
-                                .println("Compiling file: " + outputClassFile);
+                        System.out.println("Compiling file: " + outputClassFile);
 
                         ICompilationUnit unit = cu;
 
@@ -436,14 +445,12 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, Flex
                         if (cuType == ICompilationUnit.UnitType.AS_UNIT)
                         {
                             writer = JSSharedData.backend.createWriter(project,
-                                    (List<ICompilerProblem>) errors, unit,
-                                    false);
+                                    errors, unit, false);
                         }
                         else
                         {
                             writer = JSSharedData.backend.createMXMLWriter(
-                                    project, (List<ICompilerProblem>) errors,
-                                    unit, false);
+                                    project, errors, unit, false);
                         }
 
                         BufferedOutputStream out = new BufferedOutputStream(
@@ -455,9 +462,12 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, Flex
                     }
                 }
 
-                if (jsPublisher != null) {
+                if (jsPublisher != null)
+                {
                     compilationSuccess = jsPublisher.publish(problems);
-                } else {
+                }
+                else
+                {
                     compilationSuccess = true;
                 }
             }
@@ -489,7 +499,7 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, Flex
     {
         final List<ICompilerProblem> problemsBuildingSWF = new ArrayList<ICompilerProblem>();
 
-        ((FlexJSProject)project).mainCU = mainCU;
+        project.mainCU = mainCU;
         final IJSApplication app = buildApplication(project,
                 config.getMainDefinition(), mainCU, problemsBuildingSWF);
         problems.addAll(problemsBuildingSWF);
@@ -518,8 +528,7 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, Flex
             Collection<ICompilerProblem> problems) throws InterruptedException,
             ConfigurationException, FileNotFoundException
     {
-        Collection<ICompilerProblem> fatalProblems = applicationProject
-                .getFatalProblems();
+        Collection<ICompilerProblem> fatalProblems = applicationProject.getFatalProblems();
         if (!fatalProblems.isEmpty())
         {
             problems.addAll(fatalProblems);
@@ -540,8 +549,8 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, Flex
         if (config.getOutput() == null)
         {
             final String extension = "." + JSSharedData.OUTPUT_EXTENSION;
-            return FilenameUtils.removeExtension(config.getTargetFile())
-                    .concat(extension);
+            return FilenameUtils.removeExtension(config.getTargetFile()).concat(
+                    extension);
         }
         else
             return config.getOutput();
@@ -550,9 +559,9 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, Flex
     /**
      * @author Erik de Bruin
      * 
-     * Get the output class file. This includes the (sub)directory in which the
-     * original class file lives. If the directory structure doesn't exist, it
-     * is created.
+     *         Get the output class file. This includes the (sub)directory in
+     *         which the original class file lives. If the directory structure
+     *         doesn't exist, it is created.
      * 
      * @param qname
      * @param outputFolder
@@ -591,11 +600,9 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, Flex
     {
         final String mainFileName = config.getTargetFile();
 
-        final String normalizedMainFileName = FilenameNormalization
-                .normalize(mainFileName);
+        final String normalizedMainFileName = FilenameNormalization.normalize(mainFileName);
 
-        final SourceCompilationUnitFactory compilationUnitFactory = project
-                .getSourceCompilationUnitFactory();
+        final SourceCompilationUnitFactory compilationUnitFactory = project.getSourceCompilationUnitFactory();
 
         File normalizedMainFile = new File(normalizedMainFileName);
         if (compilationUnitFactory.canCreateCompilationUnit(normalizedMainFile))
@@ -611,8 +618,7 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, Flex
                     final String otherPath = new File(path).getAbsolutePath();
                     if (mainFileName.startsWith(otherPath))
                     {
-                        mainQName = mainFileName
-                                .substring(otherPath.length() + 1);
+                        mainQName = mainFileName.substring(otherPath.length() + 1);
                         mainQName = mainQName.replaceAll("\\\\", "/");
                         mainQName = mainQName.replaceAll("\\/", ".");
                         if (mainQName.endsWith(".as"))
@@ -626,8 +632,8 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, Flex
             if (mainQName == null)
                 mainQName = FilenameUtils.getBaseName(mainFileName);
 
-            Collection<ICompilationUnit> mainFileCompilationUnits = workspace
-                    .getCompilationUnits(normalizedMainFileName, project);
+            Collection<ICompilationUnit> mainFileCompilationUnits = workspace.getCompilationUnits(
+                    normalizedMainFileName, project);
 
             mainCU = Iterables.getOnlyElement(mainFileCompilationUnits);
 
@@ -682,9 +688,9 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, Flex
             if (useFlashBuilderProjectFiles(args)
                     && !jsOutputType.equals(JSOutputType.VF2JS))
             {
-                projectConfigurator.setConfiguration(FlashBuilderConfigurator
-                        .computeFlashBuilderArgs(args, getTargetType()
-                                .getExtension()),
+                projectConfigurator.setConfiguration(
+                        FlashBuilderConfigurator.computeFlashBuilderArgs(args,
+                                getTargetType().getExtension()),
                         ICompilerSettingsConstants.FILE_SPECS_VAR);
             }
             else
@@ -738,7 +744,8 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, Flex
     {
         for (String arg : args)
         {
-            if (arg.equals("-fb") || arg.equals("-use-flashbuilder-project-files"))
+            if (arg.equals("-fb")
+                    || arg.equals("-use-flashbuilder-project-files"))
                 return true;
         }
         return false;
@@ -781,8 +788,7 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, Flex
         }
         finally
         {
-            workspace.endIdleState(Collections
-                    .<ICompilerProject, Set<ICompilationUnit>> emptyMap());
+            workspace.endIdleState(Collections.<ICompilerProject, Set<ICompilationUnit>> emptyMap());
         }
     }
 

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7d2b63de/compiler.jx/src/org/apache/flex/compiler/codegen/js/IJSPublisher.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/codegen/js/IJSPublisher.java b/compiler.jx/src/org/apache/flex/compiler/codegen/js/IJSPublisher.java
index 3b2ea98..2d62436 100644
--- a/compiler.jx/src/org/apache/flex/compiler/codegen/js/IJSPublisher.java
+++ b/compiler.jx/src/org/apache/flex/compiler/codegen/js/IJSPublisher.java
@@ -23,6 +23,7 @@ import java.io.File;
 import java.io.IOException;
 
 import org.apache.flex.compiler.clients.problems.ProblemQuery;
+import org.apache.flex.compiler.driver.IPublisher;
 
 /**
  * The {@link IJSPublisher} interface allows the abstraction of project output
@@ -30,7 +31,7 @@ import org.apache.flex.compiler.clients.problems.ProblemQuery;
  * 
  * @author Erik de Bruin
  */
-public interface IJSPublisher
+public interface IJSPublisher extends IPublisher
 {
 
     File getOutputFolder();

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7d2b63de/compiler.jx/src/org/apache/flex/compiler/driver/IBackend.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/driver/IBackend.java b/compiler.jx/src/org/apache/flex/compiler/driver/IBackend.java
index 3f12ba5..4ec1fa7 100644
--- a/compiler.jx/src/org/apache/flex/compiler/driver/IBackend.java
+++ b/compiler.jx/src/org/apache/flex/compiler/driver/IBackend.java
@@ -28,6 +28,7 @@ import org.apache.flex.compiler.codegen.IDocEmitter;
 import org.apache.flex.compiler.codegen.as.IASEmitter;
 import org.apache.flex.compiler.codegen.as.IASWriter;
 import org.apache.flex.compiler.codegen.mxml.IMXMLEmitter;
+import org.apache.flex.compiler.config.Configuration;
 import org.apache.flex.compiler.config.Configurator;
 import org.apache.flex.compiler.internal.codegen.as.ASFilterWriter;
 import org.apache.flex.compiler.internal.projects.ISourceFileHandler;
@@ -76,7 +77,7 @@ public interface IBackend
      * @param project The current {@link ICompilerProject}.
      * @param settings The target's custom settings.
      * @param monitor The compilation monitor used during asynchronous parsing
-     * of {@link ICompilationUnit}s.
+     *        of {@link ICompilationUnit}s.
      * @return A new {@link JSTarget} used during compilation.
      */
     ITarget createTarget(IASProject project, ITargetSettings settings,
@@ -93,12 +94,16 @@ public interface IBackend
     IASWriter createWriter(IASProject project, List<ICompilerProblem> errors,
             ICompilationUnit compilationUnit, boolean enableDebug);
 
-    IASWriter createMXMLWriter(IASProject project, List<ICompilerProblem> errors,
-            ICompilationUnit compilationUnit, boolean enableDebug);
+    IASWriter createMXMLWriter(IASProject project,
+            List<ICompilerProblem> errors, ICompilationUnit compilationUnit,
+            boolean enableDebug);
 
     IASBlockWalker createWalker(IASProject project,
             List<ICompilerProblem> errors, IASEmitter emitter);
 
+    IPublisher createPublisher(IASProject project,
+            List<ICompilerProblem> errors, Configuration config);
+
     /**
      * Creates an AST walker capable of traversing MXML AST and calling back to
      * the {@link IASBlockWalker} for ActionScript source code production.
@@ -110,7 +115,7 @@ public interface IBackend
      * @param project The current {@link IASProject}.
      * @param errors The current {@link ICompilerProblem} list.
      * @param emitter The current {@link IASEmitter} that is used for it's
-     * emitter and is available for callbacks to it's visit methods.
+     *        emitter and is available for callbacks to it's visit methods.
      */
     IMXMLBlockWalker createMXMLWalker(IASProject project,
             List<ICompilerProblem> errors, IMXMLEmitter mxmlEmitter,

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7d2b63de/compiler.jx/src/org/apache/flex/compiler/driver/IPublisher.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/driver/IPublisher.java b/compiler.jx/src/org/apache/flex/compiler/driver/IPublisher.java
new file mode 100644
index 0000000..a2535bd
--- /dev/null
+++ b/compiler.jx/src/org/apache/flex/compiler/driver/IPublisher.java
@@ -0,0 +1,25 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.driver;
+
+public interface IPublisher
+{
+
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7d2b63de/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogPublisher.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogPublisher.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogPublisher.java
index c5d80fe..a031737 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogPublisher.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogPublisher.java
@@ -218,7 +218,7 @@ public class JSGoogPublisher extends JSPublisher implements IJSPublisher
             org.apache.commons.io.FileUtils.copyFile(srcFile, new File(tgtPath));
     }
 
-    private void writeHTML(String type, String projectName, String dirPath)
+    protected void writeHTML(String type, String projectName, String dirPath)
             throws IOException
     {
         StringBuilder htmlFile = new StringBuilder();

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7d2b63de/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jsc/JSCJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jsc/JSCJSEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jsc/JSCJSEmitter.java
index 7a75043..8d2bdf8 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jsc/JSCJSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jsc/JSCJSEmitter.java
@@ -35,7 +35,6 @@ public class JSCJSEmitter extends JSFlexJSEmitter
     public JSCJSEmitter(FilterWriter out)
     {
         super(out);
-        // TODO Auto-generated constructor stub
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7d2b63de/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jsc/JSCPublisher.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jsc/JSCPublisher.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jsc/JSCPublisher.java
new file mode 100644
index 0000000..2193fc3
--- /dev/null
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jsc/JSCPublisher.java
@@ -0,0 +1,43 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.js.jsc;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.flex.compiler.config.Configuration;
+import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSPublisher;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
+
+public class JSCPublisher extends MXMLFlexJSPublisher
+{
+
+    public JSCPublisher(Configuration config, FlexJSProject project)
+    {
+        super(config, project);
+    }
+
+    @Override
+    protected void writeHTML(String type, String projectName, String dirPath,
+            String deps, List<String> additionalHTML) throws IOException
+    {
+        // super.writeHTML(type, projectName, dirPath, deps, additionalHTML);
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7d2b63de/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
index 582c130..75224ce 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
@@ -65,23 +65,23 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
         String line;
         int lineNumber;
     }
-    
-    class DependencyLineComparator implements Comparator<DependencyRecord> {
+
+    class DependencyLineComparator implements Comparator<DependencyRecord>
+    {
         @Override
-        public int compare(DependencyRecord o1, DependencyRecord o2) {
+        public int compare(DependencyRecord o1, DependencyRecord o2)
+        {
             return new Integer(o1.lineNumber).compareTo(o2.lineNumber);
         }
     }
-    
+
     public MXMLFlexJSPublisher(Configuration config, FlexJSProject project)
     {
         super(config);
 
-        this.isMarmotinniRun = ((JSGoogConfiguration) configuration)
-                .getMarmotinni() != null;
+        this.isMarmotinniRun = ((JSGoogConfiguration) configuration).getMarmotinni() != null;
         this.outputPathParameter = configuration.getOutput();
-        this.useStrictPublishing = ((JSGoogConfiguration) configuration)
-                .getStrictPublish();
+        this.useStrictPublishing = ((JSGoogConfiguration) configuration).getStrictPublish();
 
         this.project = project;
     }
@@ -136,61 +136,74 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
     public boolean publish(ProblemQuery problems) throws IOException
     {
         @SuppressWarnings("unused")
-		boolean ok;
+        boolean ok;
         //boolean subsetGoog = true;
-        
+
         final String intermediateDirPath = outputFolder.getPath();
         final File intermediateDir = new File(intermediateDirPath);
         File srcDir = new File(configuration.getTargetFile());
         srcDir = srcDir.getParentFile();
 
-        final String projectName = FilenameUtils.getBaseName(configuration
-                .getTargetFile());
-        final String outputFileName = projectName
-                + "." + JSSharedData.OUTPUT_EXTENSION;
+        final String projectName = FilenameUtils.getBaseName(configuration.getTargetFile());
+        final String outputFileName = projectName + "."
+                + JSSharedData.OUTPUT_EXTENSION;
 
         File releaseDir = new File(outputParentFolder, FLEXJS_RELEASE_DIR_NAME);
         final String releaseDirPath = releaseDir.getPath();
 
         if (!isMarmotinniRun)
         {
-            if (releaseDir.exists()) {
+            if (releaseDir.exists())
+            {
                 org.apache.commons.io.FileUtils.deleteQuietly(releaseDir);
             }
 
-            if(!releaseDir.mkdirs()) {
-                throw new IOException(
-                        "Unable to create release directory at " + releaseDir.getAbsolutePath());
+            if (!releaseDir.mkdirs())
+            {
+                throw new IOException("Unable to create release directory at "
+                        + releaseDir.getAbsolutePath());
             }
         }
 
         // If the closure-lib parameter is empty we'll try to find the resources
         // in the classpath, dump its content to the output directory and use this
         // as closure-lib parameter.
-        if(((JSGoogConfiguration) configuration).isClosureLibSet()) {
+        if (((JSGoogConfiguration) configuration).isClosureLibSet())
+        {
             closureLibDirPath = ((JSGoogConfiguration) configuration).getClosureLib();
-        } else {
+        }
+        else
+        {
             // Check if the "goog/deps.js" is available in the classpath.
-            URL resource = Thread.currentThread().getContextClassLoader().getResource("goog/deps.js");
-            if(resource != null) {
-                File closureLibDir = new File(intermediateDir.getParent(), "closure");
+            URL resource = Thread.currentThread().getContextClassLoader().getResource(
+                    "goog/deps.js");
+            if (resource != null)
+            {
+                File closureLibDir = new File(intermediateDir.getParent(),
+                        "closure");
 
                 // Only create and dump the content, if the directory does not exists.
-                if(!closureLibDir.exists()) {
-                    if(!closureLibDir.mkdirs()) {
+                if (!closureLibDir.exists())
+                {
+                    if (!closureLibDir.mkdirs())
+                    {
                         throw new IOException(
-                                "Unable to create directory for closure-lib at " + closureLibDir.getAbsolutePath());
+                                "Unable to create directory for closure-lib at "
+                                        + closureLibDir.getAbsolutePath());
                     }
 
                     // Strip the url of the parts we don't need.
                     // Unless we are not using some insanely complex setup
                     // the resource will always be on the same machine.
                     String resourceJarPath = resource.getFile();
-                    if(resourceJarPath.contains(":")) {
+                    if (resourceJarPath.contains(":"))
+                    {
                         resourceJarPath = resourceJarPath.substring(resourceJarPath.lastIndexOf(":") + 1);
                     }
-                    if(resourceJarPath.contains("!")) {
-                        resourceJarPath = resourceJarPath.substring(0, resourceJarPath.indexOf("!"));
+                    if (resourceJarPath.contains("!"))
+                    {
+                        resourceJarPath = resourceJarPath.substring(0,
+                                resourceJarPath.indexOf("!"));
                     }
                     File resourceJar = new File(resourceJarPath);
 
@@ -202,35 +215,44 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
                 closureLibDirPath = intermediateDir.getParentFile().getPath();
             }
             // Fallback to the default.
-            else {
+            else
+            {
                 closureLibDirPath = ((JSGoogConfiguration) configuration).getClosureLib();
             }
         }
 
         // Dump FlexJS to the target directory.
         @SuppressWarnings("unused")
-		String flexJsLibDirPath;
+        String flexJsLibDirPath;
         // Check if the "FlexJS/src/createjs_externals.js" is available in the classpath.
-        URL resource = Thread.currentThread().getContextClassLoader().getResource("FlexJS/src/createjs_externals.js");
-        if(resource != null) {
+        URL resource = Thread.currentThread().getContextClassLoader().getResource(
+                "FlexJS/src/createjs_externals.js");
+        if (resource != null)
+        {
             File flexJsLibDir = new File(intermediateDir.getParent(), "flexjs");
 
             // Only create and dump the content, if the directory does not exists.
-            if(!flexJsLibDir.exists()) {
-                if(!flexJsLibDir.mkdirs()) {
+            if (!flexJsLibDir.exists())
+            {
+                if (!flexJsLibDir.mkdirs())
+                {
                     throw new IOException(
-                            "Unable to create directory for flexjs-lib at " + flexJsLibDir.getAbsolutePath());
+                            "Unable to create directory for flexjs-lib at "
+                                    + flexJsLibDir.getAbsolutePath());
                 }
 
                 // Strip the url of the parts we don't need.
                 // Unless we are not using some insanely complex setup
                 // the resource will always be on the same machine.
                 String resourceJarPath = resource.getFile();
-                if(resourceJarPath.contains(":")) {
+                if (resourceJarPath.contains(":"))
+                {
                     resourceJarPath = resourceJarPath.substring(resourceJarPath.lastIndexOf(":") + 1);
                 }
-                if(resourceJarPath.contains("!")) {
-                    resourceJarPath = resourceJarPath.substring(0, resourceJarPath.indexOf("!"));
+                if (resourceJarPath.contains("!"))
+                {
+                    resourceJarPath = resourceJarPath.substring(0,
+                            resourceJarPath.indexOf("!"));
                 }
                 File resourceJar = new File(resourceJarPath);
 
@@ -249,11 +271,11 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
         //final String depsSrcFilePath = intermediateDirPath
         //        + "/library/closure/goog/deps.js";
         @SuppressWarnings("unused")
-		final String depsTgtFilePath = intermediateDirPath + "/deps.js";
+        final String depsTgtFilePath = intermediateDirPath + "/deps.js";
         final String projectIntermediateJSFilePath = intermediateDirPath
                 + File.separator + outputFileName;
-        final String projectReleaseJSFilePath = releaseDirPath
-                + File.separator + outputFileName;
+        final String projectReleaseJSFilePath = releaseDirPath + File.separator
+                + outputFileName;
 
         appendExportSymbol(projectIntermediateJSFilePath, projectName);
         appendEncodedCSS(projectIntermediateJSFilePath, projectName);
@@ -261,26 +283,27 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
 
         //if (!subsetGoog)
         //{
-            // (erikdebruin) We need to leave the 'goog' files and dependencies well
-            //               enough alone. We copy the entire library over so the 
-            //               'goog' dependencies will resolve without our help.
-            FileUtils.copyDirectory(new File(closureGoogSrcLibDirPath), new File(closureGoogTgtLibDirPath));
+        // (erikdebruin) We need to leave the 'goog' files and dependencies well
+        //               enough alone. We copy the entire library over so the 
+        //               'goog' dependencies will resolve without our help.
+        FileUtils.copyDirectory(new File(closureGoogSrcLibDirPath), new File(
+                closureGoogTgtLibDirPath));
         //}
-        
+
         JSClosureCompilerWrapper compilerWrapper = new JSClosureCompilerWrapper();
 
-        GoogDepsWriter gdw = new GoogDepsWriter(intermediateDir, projectName, 
-        		(JSGoogConfiguration) configuration, project.getLibraries());
+        GoogDepsWriter gdw = new GoogDepsWriter(intermediateDir, projectName,
+                (JSGoogConfiguration) configuration, project.getLibraries());
         StringBuilder depsFileData = new StringBuilder();
         try
         {
-        	ArrayList<String> fileList = gdw.getListOfFiles(problems);
-        	for (String file : fileList)
-        	{
-                compilerWrapper.addJSSourceFile(file);	
-        	}
+            ArrayList<String> fileList = gdw.getListOfFiles(problems);
+            for (String file : fileList)
+            {
+                compilerWrapper.addJSSourceFile(file);
+            }
             ok = gdw.generateDeps(problems, depsFileData);
-        	/*
+            /*
             if (!subsetGoog)
             {
                 writeFile(depsTgtFilePath, depsFileData.toString(), false); 
@@ -372,31 +395,35 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
             e.printStackTrace();
             return false;
         }
-        
+
         IOFileFilter pngSuffixFilter = FileFilterUtils.and(FileFileFilter.FILE,
                 FileFilterUtils.suffixFileFilter(".png"));
         IOFileFilter gifSuffixFilter = FileFilterUtils.and(FileFileFilter.FILE,
                 FileFilterUtils.suffixFileFilter(".gif"));
         IOFileFilter jpgSuffixFilter = FileFilterUtils.and(FileFileFilter.FILE,
                 FileFilterUtils.suffixFileFilter(".jpg"));
-        IOFileFilter jsonSuffixFilter = FileFilterUtils.and(FileFileFilter.FILE,
-                FileFilterUtils.suffixFileFilter(".json"));
+        IOFileFilter jsonSuffixFilter = FileFilterUtils.and(
+                FileFileFilter.FILE, FileFilterUtils.suffixFileFilter(".json"));
         IOFileFilter assetFiles = FileFilterUtils.or(pngSuffixFilter,
                 jpgSuffixFilter, gifSuffixFilter, jsonSuffixFilter);
-        IOFileFilter subdirs = FileFilterUtils.or(DirectoryFileFilter.DIRECTORY, assetFiles);
+        IOFileFilter subdirs = FileFilterUtils.or(
+                DirectoryFileFilter.DIRECTORY, assetFiles);
 
         FileUtils.copyDirectory(srcDir, intermediateDir, subdirs);
         FileUtils.copyDirectory(srcDir, releaseDir, subdirs);
 
         //File srcDeps = new File(depsSrcFilePath);
 
-        writeHTML("intermediate", projectName, intermediateDirPath, depsFileData.toString(), gdw.additionalHTML);
-        writeHTML("release", projectName, releaseDirPath, null, gdw.additionalHTML);
-    	if (project.needCSS) {
-	        writeCSS(projectName, intermediateDirPath);
-	        writeCSS(projectName, releaseDirPath);
-    	}
-    	
+        writeHTML("intermediate", projectName, intermediateDirPath,
+                depsFileData.toString(), gdw.additionalHTML);
+        writeHTML("release", projectName, releaseDirPath, null,
+                gdw.additionalHTML);
+        if (project.needCSS)
+        {
+            writeCSS(projectName, intermediateDirPath);
+            writeCSS(projectName, releaseDirPath);
+        }
+
         /*
         if (!subsetGoog)
         {
@@ -410,14 +437,14 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
             }
         }
         */
-        Collection<File> files = org.apache.commons.io.FileUtils.listFiles(new File(
-        		closureGoogSrcLibDirPath), new RegexFileFilter("^.*(\\.js)"),
-                DirectoryFileFilter.DIRECTORY);
+        Collection<File> files = org.apache.commons.io.FileUtils.listFiles(
+                new File(closureGoogSrcLibDirPath), new RegexFileFilter(
+                        "^.*(\\.js)"), DirectoryFileFilter.DIRECTORY);
         for (File file : files)
         {
             compilerWrapper.addJSSourceFile(file.getCanonicalPath());
         }
-        
+
         /*
         // (erikdebruin) add project files
         for (String filePath : gdw.filePathsInOrder)
@@ -426,25 +453,25 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
                     new File(filePath).getCanonicalPath());   
         }
         */
-        
-        compilerWrapper.setOptions(
-                projectReleaseJSFilePath, useStrictPublishing, projectName);
-        
+
+        compilerWrapper.setOptions(projectReleaseJSFilePath,
+                useStrictPublishing, projectName);
+
         /*
         // (erikdebruin) Include the 'goog' deps to allow the compiler to resolve
         //               dependencies.
         compilerWrapper.addJSSourceFile(
                 closureGoogSrcLibDirPath + File.separator + "deps.js");
         */
-        List<String> externs = ((JSGoogConfiguration)configuration).getExternalJSLib();
+        List<String> externs = ((JSGoogConfiguration) configuration).getExternalJSLib();
         for (String extern : externs)
         {
             compilerWrapper.addJSExternsFile(extern);
         }
-        
+
         compilerWrapper.targetFilePath = projectReleaseJSFilePath;
         compilerWrapper.compile();
-        
+
         appendSourceMapLocation(projectReleaseJSFilePath, projectName);
 
         /*
@@ -460,13 +487,12 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
             
             org.apache.commons.io.FileUtils.deleteQuietly(new File(depsTgtFilePath));
         }
-		*/
-        
+        */
+
         //if (ok)
-            System.out.println("The project '"
-                + projectName
+        System.out.println("The project '" + projectName
                 + "' has been successfully compiled and optimized.");
-        
+
         return true;
     }
 
@@ -492,19 +518,22 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
             }
         }
     }*/
-    
+
     private void appendExportSymbol(String path, String projectName)
             throws IOException
     {
-        writeFile(path, "\n\n// Ensures the symbol will be visible after compiler renaming.\n" +
-                "goog.exportSymbol('" + projectName + "', " + projectName + ");\n", true);
+        writeFile(path,
+                "\n\n// Ensures the symbol will be visible after compiler renaming.\n"
+                        + "goog.exportSymbol('" + projectName + "', "
+                        + projectName + ");\n", true);
     }
 
     private void appendEncodedCSS(String path, String projectName)
             throws IOException
     {
-    	if (!project.needCSS) return;
-    	
+        if (!project.needCSS)
+            return;
+
         StringBuilder appendString = new StringBuilder();
         appendString.append("\n\n");
         appendString.append(projectName);
@@ -529,34 +558,34 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
             writeFile(path, appendString.toString(), true);
         }
     }
-     
+
     private void appendLanguage(String path, String projectName)
-    	throws IOException
-	{
-		StringBuilder appendString = new StringBuilder();
-		appendString.append(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
-		appendString.append(ASEmitterTokens.PAREN_OPEN.getToken());
-		appendString.append(ASEmitterTokens.SINGLE_QUOTE.getToken());
-		appendString.append(JSFlexJSEmitterTokens.LANGUAGE_QNAME.getToken());
-		appendString.append(ASEmitterTokens.SINGLE_QUOTE.getToken());
-		appendString.append(ASEmitterTokens.PAREN_CLOSE.getToken());
-		appendString.append(ASEmitterTokens.SEMICOLON.getToken());
-		appendString.append("\n");
-		
-	    String fileData = readCode(new File(path));
-	    int reqidx = fileData.indexOf(appendString.toString());
-	    if (reqidx == -1 && project.needLanguage)
-	    {
-	    	reqidx = fileData.lastIndexOf(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
-	    	if (reqidx == -1)
-	    		reqidx = fileData.lastIndexOf(JSGoogEmitterTokens.GOOG_PROVIDE.getToken());
-	    	reqidx = fileData.indexOf(";", reqidx);
-		    String after = fileData.substring(reqidx + 1);
-		    String before = fileData.substring(0, reqidx + 1);
-		    String s = before + "\n" + appendString.toString() + after;
-		    writeFile(path, s, false);
-	    }
-	}
+            throws IOException
+    {
+        StringBuilder appendString = new StringBuilder();
+        appendString.append(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
+        appendString.append(ASEmitterTokens.PAREN_OPEN.getToken());
+        appendString.append(ASEmitterTokens.SINGLE_QUOTE.getToken());
+        appendString.append(JSFlexJSEmitterTokens.LANGUAGE_QNAME.getToken());
+        appendString.append(ASEmitterTokens.SINGLE_QUOTE.getToken());
+        appendString.append(ASEmitterTokens.PAREN_CLOSE.getToken());
+        appendString.append(ASEmitterTokens.SEMICOLON.getToken());
+        appendString.append("\n");
+
+        String fileData = readCode(new File(path));
+        int reqidx = fileData.indexOf(appendString.toString());
+        if (reqidx == -1 && project.needLanguage)
+        {
+            reqidx = fileData.lastIndexOf(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
+            if (reqidx == -1)
+                reqidx = fileData.lastIndexOf(JSGoogEmitterTokens.GOOG_PROVIDE.getToken());
+            reqidx = fileData.indexOf(";", reqidx);
+            String after = fileData.substring(reqidx + 1);
+            String before = fileData.substring(0, reqidx + 1);
+            String s = before + "\n" + appendString.toString() + after;
+            writeFile(path, s, false);
+        }
+    }
 
     protected String readCode(File file)
     {
@@ -585,8 +614,8 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
         return code;
     }
 
-    private void writeHTML(String type, String projectName, String dirPath, String deps, List<String> additionalHTML)
-            throws IOException
+    protected void writeHTML(String type, String projectName, String dirPath,
+            String deps, List<String> additionalHTML) throws IOException
     {
         StringBuilder htmlFile = new StringBuilder();
         htmlFile.append("<!DOCTYPE html>\n");
@@ -594,11 +623,12 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
         htmlFile.append("<head>\n");
         htmlFile.append("\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\">\n");
         htmlFile.append("\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n");
-        htmlFile.append("\t<link rel=\"stylesheet\" type=\"text/css\" href=\"").append(projectName).append(".css\">\n");
+        htmlFile.append("\t<link rel=\"stylesheet\" type=\"text/css\" href=\"").append(
+                projectName).append(".css\">\n");
 
         for (String s : additionalHTML)
             htmlFile.append(s).append("\n");
-        
+
         if ("intermediate".equals(type))
         {
             htmlFile.append("\t<script type=\"text/javascript\" src=\"./library/closure/goog/base.js\"></script>\n");

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7d2b63de/compiler.jx/src/org/apache/flex/compiler/internal/driver/as/ASBackend.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/driver/as/ASBackend.java b/compiler.jx/src/org/apache/flex/compiler/internal/driver/as/ASBackend.java
index 485fa82..647efa5 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/driver/as/ASBackend.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/driver/as/ASBackend.java
@@ -27,8 +27,10 @@ import org.apache.flex.compiler.codegen.IDocEmitter;
 import org.apache.flex.compiler.codegen.as.IASEmitter;
 import org.apache.flex.compiler.codegen.as.IASWriter;
 import org.apache.flex.compiler.codegen.mxml.IMXMLEmitter;
+import org.apache.flex.compiler.config.Configuration;
 import org.apache.flex.compiler.config.Configurator;
 import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.driver.IPublisher;
 import org.apache.flex.compiler.internal.codegen.as.ASAfterNodeStrategy;
 import org.apache.flex.compiler.internal.codegen.as.ASBeforeNodeStrategy;
 import org.apache.flex.compiler.internal.codegen.as.ASBlockWalker;
@@ -148,4 +150,10 @@ public class ASBackend implements IBackend
         return null;
     }
 
+    @Override
+    public IPublisher createPublisher(IASProject project,
+            List<ICompilerProblem> errors, Configuration config)
+    {
+        return null;
+    }
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7d2b63de/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/JSBackend.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/JSBackend.java b/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/JSBackend.java
index 56d64bb..20ff965 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/JSBackend.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/JSBackend.java
@@ -29,14 +29,17 @@ import org.apache.flex.compiler.codegen.as.IASEmitter;
 import org.apache.flex.compiler.codegen.js.IJSEmitter;
 import org.apache.flex.compiler.codegen.js.IJSWriter;
 import org.apache.flex.compiler.codegen.mxml.IMXMLEmitter;
+import org.apache.flex.compiler.config.Configuration;
 import org.apache.flex.compiler.config.Configurator;
 import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.driver.IPublisher;
 import org.apache.flex.compiler.internal.codegen.as.ASAfterNodeStrategy;
 import org.apache.flex.compiler.internal.codegen.as.ASBeforeNodeStrategy;
 import org.apache.flex.compiler.internal.codegen.as.ASBlockWalker;
 import org.apache.flex.compiler.internal.codegen.js.JSDocEmitter;
 import org.apache.flex.compiler.internal.codegen.js.JSEmitter;
 import org.apache.flex.compiler.internal.codegen.js.JSFilterWriter;
+import org.apache.flex.compiler.internal.codegen.js.JSPublisher;
 import org.apache.flex.compiler.internal.codegen.js.JSWriter;
 import org.apache.flex.compiler.internal.projects.ISourceFileHandler;
 import org.apache.flex.compiler.internal.targets.JSTarget;
@@ -151,4 +154,10 @@ public class JSBackend implements IBackend
         return null;
     }
 
+    @Override
+    public IPublisher createPublisher(IASProject project,
+            List<ICompilerProblem> errors, Configuration config)
+    {
+        return new JSPublisher(config);
+    }
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7d2b63de/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/flexjs/FlexJSBackend.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/flexjs/FlexJSBackend.java b/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/flexjs/FlexJSBackend.java
index 1e06bcc..cccbe71 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/flexjs/FlexJSBackend.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/flexjs/FlexJSBackend.java
@@ -43,13 +43,11 @@ public class FlexJSBackend extends GoogBackend
         emitter.setDocEmitter(createDocEmitter(emitter));
         return emitter;
     }
-    
+
     @Override
     public JSTarget createTarget(IASProject project, ITargetSettings settings,
             ITargetProgressMonitor monitor)
     {
         return new FlexJSTarget(project, settings, monitor);
     }
-
-
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7d2b63de/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/goog/GoogBackend.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/goog/GoogBackend.java b/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/goog/GoogBackend.java
index 88469fa..af8129a 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/goog/GoogBackend.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/goog/GoogBackend.java
@@ -20,15 +20,20 @@
 package org.apache.flex.compiler.internal.driver.js.goog;
 
 import java.io.FilterWriter;
+import java.util.List;
 
 import org.apache.flex.compiler.codegen.IDocEmitter;
 import org.apache.flex.compiler.codegen.as.IASEmitter;
 import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.config.Configuration;
 import org.apache.flex.compiler.config.Configurator;
 import org.apache.flex.compiler.driver.IBackend;
 import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogDocEmitter;
 import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitter;
+import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogPublisher;
 import org.apache.flex.compiler.internal.driver.js.JSBackend;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.projects.IASProject;
 
 /**
  * A concrete implementation of the {@link IBackend} API for the 'goog' code
@@ -58,4 +63,11 @@ public class GoogBackend extends JSBackend
         emitter.setDocEmitter(createDocEmitter(emitter));
         return emitter;
     }
+
+    @Override
+    public JSGoogPublisher createPublisher(IASProject project,
+            List<ICompilerProblem> errors, Configuration config)
+    {
+        return new JSGoogPublisher(config);
+    }
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7d2b63de/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/jsc/JSCBackend.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/jsc/JSCBackend.java b/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/jsc/JSCBackend.java
new file mode 100644
index 0000000..10d049f
--- /dev/null
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/jsc/JSCBackend.java
@@ -0,0 +1,47 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.driver.js.jsc;
+
+import java.util.List;
+
+import org.apache.flex.compiler.config.Configuration;
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.internal.codegen.js.jsc.JSCPublisher;
+import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSPublisher;
+import org.apache.flex.compiler.internal.driver.mxml.jsc.MXMLJSCJSBackend;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.projects.IASProject;
+
+/**
+ * A concrete implementation of the {@link IBackend} API for the 'jsc' code
+ * production.
+ * 
+ * @author Michael Schmalle
+ */
+public class JSCBackend extends MXMLJSCJSBackend
+{
+    @Override
+    public MXMLFlexJSPublisher createPublisher(IASProject project,
+            List<ICompilerProblem> errors, Configuration config)
+    {
+        return new JSCPublisher(config, (FlexJSProject) project);
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7d2b63de/compiler.jx/src/org/apache/flex/compiler/internal/driver/mxml/flexjs/MXMLFlexJSBackend.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/driver/mxml/flexjs/MXMLFlexJSBackend.java b/compiler.jx/src/org/apache/flex/compiler/internal/driver/mxml/flexjs/MXMLFlexJSBackend.java
index 40453e5..612b089 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/driver/mxml/flexjs/MXMLFlexJSBackend.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/driver/mxml/flexjs/MXMLFlexJSBackend.java
@@ -27,6 +27,7 @@ import org.apache.flex.compiler.codegen.as.IASEmitter;
 import org.apache.flex.compiler.codegen.js.IJSEmitter;
 import org.apache.flex.compiler.codegen.js.IJSWriter;
 import org.apache.flex.compiler.codegen.mxml.IMXMLEmitter;
+import org.apache.flex.compiler.config.Configuration;
 import org.apache.flex.compiler.config.Configurator;
 import org.apache.flex.compiler.driver.IBackend;
 import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter;
@@ -35,8 +36,10 @@ import org.apache.flex.compiler.internal.codegen.mxml.MXMLBlockWalker;
 import org.apache.flex.compiler.internal.codegen.mxml.MXMLWriter;
 import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSBlockWalker;
 import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSEmitter;
+import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSPublisher;
 import org.apache.flex.compiler.internal.driver.js.goog.JSGoogConfiguration;
 import org.apache.flex.compiler.internal.driver.mxml.MXMLBackend;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
 import org.apache.flex.compiler.internal.targets.FlexJSTarget;
 import org.apache.flex.compiler.internal.targets.JSTarget;
 import org.apache.flex.compiler.internal.visitor.as.ASNodeSwitch;
@@ -103,7 +106,7 @@ public class MXMLFlexJSBackend extends MXMLBackend
         emitter.setDocEmitter(createDocEmitter(emitter));
         return emitter;
     }
-    
+
     @Override
     public IJSWriter createMXMLWriter(IASProject project,
             List<ICompilerProblem> problems, ICompilationUnit compilationUnit,
@@ -118,4 +121,11 @@ public class MXMLFlexJSBackend extends MXMLBackend
     {
         return new FlexJSTarget(project, settings, monitor);
     }
+
+    @Override
+    public MXMLFlexJSPublisher createPublisher(IASProject project,
+            List<ICompilerProblem> errors, Configuration config)
+    {
+        return new MXMLFlexJSPublisher(config, (FlexJSProject) project);
+    }
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7d2b63de/compiler.jx/src/org/apache/flex/compiler/internal/driver/mxml/vf2js/MXMLVF2JSBackend.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/driver/mxml/vf2js/MXMLVF2JSBackend.java b/compiler.jx/src/org/apache/flex/compiler/internal/driver/mxml/vf2js/MXMLVF2JSBackend.java
index 397d977..f69d499 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/driver/mxml/vf2js/MXMLVF2JSBackend.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/driver/mxml/vf2js/MXMLVF2JSBackend.java
@@ -27,16 +27,20 @@ import org.apache.flex.compiler.codegen.as.IASEmitter;
 import org.apache.flex.compiler.codegen.js.IJSEmitter;
 import org.apache.flex.compiler.codegen.js.IJSWriter;
 import org.apache.flex.compiler.codegen.mxml.IMXMLEmitter;
+import org.apache.flex.compiler.config.Configuration;
 import org.apache.flex.compiler.config.Configurator;
 import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.driver.IPublisher;
 import org.apache.flex.compiler.internal.codegen.js.vf2js.JSVF2JSDocEmitter;
 import org.apache.flex.compiler.internal.codegen.js.vf2js.JSVF2JSEmitter;
 import org.apache.flex.compiler.internal.codegen.mxml.MXMLBlockWalker;
 import org.apache.flex.compiler.internal.codegen.mxml.MXMLWriter;
 import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSBlockWalker;
 import org.apache.flex.compiler.internal.codegen.mxml.vf2js.MXMLVF2JSEmitter;
+import org.apache.flex.compiler.internal.codegen.mxml.vf2js.MXMLVF2JSPublisher;
 import org.apache.flex.compiler.internal.driver.js.vf2js.JSVF2JSConfiguration;
 import org.apache.flex.compiler.internal.driver.mxml.MXMLBackend;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
 import org.apache.flex.compiler.internal.targets.FlexJSTarget;
 import org.apache.flex.compiler.internal.targets.JSTarget;
 import org.apache.flex.compiler.internal.visitor.as.ASNodeSwitch;
@@ -103,7 +107,7 @@ public class MXMLVF2JSBackend extends MXMLBackend
         emitter.setDocEmitter(createDocEmitter(emitter));
         return emitter;
     }
-    
+
     @Override
     public IJSWriter createMXMLWriter(IASProject project,
             List<ICompilerProblem> problems, ICompilationUnit compilationUnit,
@@ -118,4 +122,11 @@ public class MXMLVF2JSBackend extends MXMLBackend
     {
         return new FlexJSTarget(project, settings, monitor);
     }
+
+    @Override
+    public IPublisher createPublisher(IASProject project,
+            List<ICompilerProblem> errors, Configuration config)
+    {
+        return new MXMLVF2JSPublisher(config, (FlexJSProject) project);
+    }
 }