MXMLJSC, COMPJSC: remove dead code
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSC.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSC.java
index 06b218a..3fdd841 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSC.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSC.java
@@ -19,57 +19,19 @@
 
 package org.apache.royale.compiler.clients;
 
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.Charset;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.time.ZoneId;
-import java.time.ZonedDateTime;
 import java.util.*;
-import java.util.zip.CRC32;
-import java.util.zip.Deflater;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-import java.util.zip.ZipOutputStream;
 
-import com.google.debugging.sourcemap.SourceMapConsumerV3;
-import com.google.debugging.sourcemap.SourceMapGeneratorV3;
-import com.google.debugging.sourcemap.SourceMapParseException;
-
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.io.IOUtils;
 import org.apache.royale.compiler.clients.problems.ProblemPrinter;
 import org.apache.royale.compiler.clients.problems.WorkspaceProblemFormatter;
-import org.apache.royale.compiler.codegen.js.IJSWriter;
 import org.apache.royale.compiler.config.CompilerDiagnosticsConstants;
-import org.apache.royale.compiler.driver.js.IJSApplication;
 import org.apache.royale.compiler.exceptions.ConfigurationException;
 import org.apache.royale.compiler.exceptions.ConfigurationException.IOError;
 import org.apache.royale.compiler.exceptions.ConfigurationException.MustSpecifyTarget;
 import org.apache.royale.compiler.internal.driver.js.goog.JSGoogCompcConfiguration;
 import org.apache.royale.compiler.internal.parsing.as.RoyaleASDocDelegate;
-import org.apache.royale.compiler.internal.projects.CompilerProject;
-import org.apache.royale.compiler.internal.targets.RoyaleSWCTarget;
-import org.apache.royale.compiler.internal.units.SWCCompilationUnit;
-import org.apache.royale.compiler.internal.targets.JSTarget;
 import org.apache.royale.compiler.problems.ICompilerProblem;
-import org.apache.royale.compiler.problems.InternalCompilerProblem;
-import org.apache.royale.compiler.problems.LibraryNotFoundProblem;
-import org.apache.royale.compiler.problems.UnableToBuildSWFProblem;
 import org.apache.royale.compiler.problems.UnexpectedExceptionProblem;
 import org.apache.royale.compiler.targets.ITarget.TargetType;
-import org.apache.royale.compiler.targets.ITargetSettings;
-import org.apache.royale.compiler.units.ICompilationUnit;
-import org.apache.royale.compiler.utils.SourceMapUtils;
-import org.apache.royale.swc.ISWCFileEntry;
-import org.apache.royale.swc.io.SWCReader;
 import org.apache.royale.utils.ArgumentUtil;
 
 /**
@@ -294,688 +256,7 @@
         super();
     }
 
-    /**
-     * Main body of this program. This method is called from the public static
-     * method's for this program.
-     * 
-     * @return true if compiler succeeds
-     * @throws IOException
-     * @throws InterruptedException
-     */
     @Override
-    protected boolean compile()
-    {
-        boolean compilationSuccess = false;
-
-        try
-        {
-            project.getSourceCompilationUnitFactory().addHandler(asFileHandler);
-
-            if (setupTargetFile())
-                buildArtifact();
-
-            if (jsTarget != null)
-            {
-                Collection<ICompilerProblem> errors = new ArrayList<ICompilerProblem>();
-                Collection<ICompilerProblem> warnings = new ArrayList<ICompilerProblem>();
-
-                if (!config.getCreateTargetWithErrors())
-                {
-                    problems.getErrorsAndWarnings(errors, warnings);
-                    if (errors.size() > 0)
-                        return false;
-                }
-
-                boolean packingSWC = false;
-                String outputFolderName = getOutputFilePath();
-            	File swcFile = new File(outputFolderName);
-            	File jsOut = new File("js/out");
-            	File externsOut = new File("externs");
-                ZipFile zipFile = null;
-            	ZipOutputStream zipOutputStream = null;
-            	String catalog = null;
-            	StringBuilder fileList = new StringBuilder();
-                if (outputFolderName.endsWith(".swc"))
-                {
-                	packingSWC = true;
-                	if (!swcFile.exists())
-                	{
-                		problems.add(new LibraryNotFoundProblem(outputFolderName));
-                		return false;
-                	}
-                    zipFile = new ZipFile(swcFile, ZipFile.OPEN_READ);
-                    final InputStream catalogInputStream = SWCReader.getInputStream(zipFile, SWCReader.CATALOG_XML);
-                    
-                    catalog = IOUtils.toString(catalogInputStream);
-                    catalogInputStream.close();
-                    zipOutputStream = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(outputFolderName + ".new")));
-                    zipOutputStream.setLevel(Deflater.NO_COMPRESSION);
-                    for (final Enumeration<? extends ZipEntry> entryEnum = zipFile.entries(); entryEnum.hasMoreElements();)
-                    {
-                        final ZipEntry entry = entryEnum.nextElement();
-                        if (!entry.getName().contains("js/out") &&
-                        	!entry.getName().contains(SWCReader.CATALOG_XML))
-                        {
-                            if (config.isVerbose())
-                            {
-                                System.out.println("Copy " + entry.getName());
-                            }
-                        	InputStream input = zipFile.getInputStream(entry);
-                        	ZipEntry ze = new ZipEntry(entry.getName());
-                        	ze.setMethod(ZipEntry.STORED);
-                        	ze.setTime(entry.getTime());
-                        	ze.setSize(entry.getSize());
-                        	ze.setCompressedSize(entry.getCompressedSize());
-                        	ze.setCrc(entry.getCrc());
-                        	zipOutputStream.putNextEntry(ze);
-                        	IOUtils.copy(input, zipOutputStream);
-                            zipOutputStream.flush();
-                        	zipOutputStream.closeEntry();
-                        }
-                    }
-                    int filesIndex = catalog.indexOf("<files>");
-                    if (filesIndex != -1)
-                    {
-                    	int filesIndex2 = catalog.indexOf("</files>");
-                    	String files = catalog.substring(filesIndex, filesIndex2);
-                    	int fileIndex = files.indexOf("<file", 6);
-                    	int pathIndex = files.indexOf("path=");
-                    	while (pathIndex != -1)
-                    	{
-                    		int pathIndex2 = files.indexOf("\"", pathIndex + 6);
-                    		int fileIndex2 = files.indexOf("/>", fileIndex);
-                    		String path = files.substring(pathIndex + 6, pathIndex2);
-                    		if (!path.startsWith("js/out"))
-                    		{
-                    			fileList.append(files.substring(fileIndex - 8, fileIndex2 + 3));
-                    		}
-                    		pathIndex = files.indexOf("path=", pathIndex2);
-                    		fileIndex = files.indexOf("<file", fileIndex2);
-                    	}
-                        catalog = catalog.substring(0, filesIndex) + catalog.substring(filesIndex2 + 8);
-                    }
-                }
-
-                File outputFolder = null;
-                if (!packingSWC) 
-                	outputFolder = new File(outputFolderName);
-
-                Set<String> externs = config.getExterns();
-                Collection<ICompilationUnit> roots = ((RoyaleSWCTarget)target).getReachableCompilationUnits(errors);
-                Collection<ICompilationUnit> reachableCompilationUnits = project.getReachableCompilationUnitsInSWFOrder(roots);
-                for (final ICompilationUnit cu : reachableCompilationUnits)
-                {
-                    ICompilationUnit.UnitType cuType = cu.getCompilationUnitType();
-
-                    if (cuType == ICompilationUnit.UnitType.AS_UNIT
-                            || cuType == ICompilationUnit.UnitType.MXML_UNIT)
-                    {
-                    	String symbol = cu.getQualifiedNames().get(0);
-                    	if (externs.contains(symbol)) continue;
-                    	
-                    	if (project.isExternalLinkage(cu)) continue;
-                    	
-                    	if (!packingSWC)
-                    	{
-	                        final File outputClassFile = getOutputClassFile(
-	                                cu.getQualifiedNames().get(0), outputFolder, true);
-	
-                            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,
-	                                    (List<ICompilerProblem>) errors, unit,
-	                                    false);
-	                        }
-	                        else
-	                        {
-	                            writer = (IJSWriter) project.getBackend().createMXMLWriter(
-	                                    project, (List<ICompilerProblem>) errors,
-	                                    unit, false);
-	                        }
-	                        problems.addAll(errors);
-
-                            BufferedOutputStream out = new BufferedOutputStream(
-	                                new FileOutputStream(outputClassFile));
-                            BufferedOutputStream sourceMapOut = null;
-                            File outputSourceMapFile = null;
-                            if (project.config.getSourceMap())
-                            {
-                                outputSourceMapFile = getOutputSourceMapFile(
-                                        cu.getQualifiedNames().get(0), outputFolder, true);
-                                sourceMapOut = new BufferedOutputStream(
-                                    new FileOutputStream(outputSourceMapFile));
-                            }
-                            writer.writeTo(out, sourceMapOut, outputSourceMapFile);
-	                        out.flush();
-	                        out.close();
-                            if (sourceMapOut != null)
-                            {
-                                sourceMapOut.flush();
-                                sourceMapOut.close();
-                            }
-	                        writer.close();
-                    	}
-                    	else
-                    	{
-	                        if (config.isVerbose())
-                            {
-                                System.out.println("Compiling file: " + cu.getQualifiedNames().get(0));
-                            }
-	                    	
-	                        ICompilationUnit unit = cu;
-	
-	                        IJSWriter writer;
-	                        if (cuType == ICompilationUnit.UnitType.AS_UNIT)
-	                        {
-	                            writer = (IJSWriter) project.getBackend().createWriter(project,
-	                                    (List<ICompilerProblem>) errors, unit,
-	                                    false);
-	                        }
-	                        else
-	                        {
-	                            writer = (IJSWriter) project.getBackend().createMXMLWriter(
-	                                    project, (List<ICompilerProblem>) errors,
-	                                    unit, false);
-	                        }
-	                        problems.addAll(errors);
-	                        ByteArrayOutputStream temp = new ByteArrayOutputStream();
-                            ByteArrayOutputStream sourceMapTemp = null;
-
-                            boolean isExterns = false;
-                            if(cu.getDefinitionPromises().size() > 0)
-                            {
-                                isExterns = project.isExterns(cu.getDefinitionPromises().get(0).getQualifiedName());
-                            }
-
-                            // if the file is @externs DON'T create source map file
-                            if (project.config.getSourceMap() && !isExterns)
-	                        {
-                                sourceMapTemp = new ByteArrayOutputStream();
-	                        }
-                            writer.writeTo(temp, sourceMapTemp, null);
-
-                    		File outputClassFile = getOutputClassFile(
-                                    cu.getQualifiedNames().get(0),
-                                    isExterns ? externsOut : jsOut,
-                                    false);
-                            String outputClassFilePath = outputClassFile.getPath();
-                    		outputClassFilePath = outputClassFilePath.replace('\\', '/');
-	                        if (config.isVerbose())
-                            {
-                                System.out.println("Writing file: " + outputClassFilePath);     	
-                            }
-	                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-	                        temp.writeTo(baos);
-                            writeFileToZip(zipOutputStream, outputClassFilePath, baos, fileList);
-                            if(sourceMapTemp != null)
-                            {
-                                String sourceMapFilePath = getOutputSourceMapFile(
-                                    cu.getQualifiedNames().get(0),
-                                    isExterns ? externsOut : jsOut,
-                                    false).getPath();
-                                sourceMapFilePath = sourceMapFilePath.replace('\\', '/');
-                                if (config.isVerbose())
-                                {
-                                    System.out.println("Writing file: " + sourceMapFilePath);
-                                }
-    	                        baos = new ByteArrayOutputStream();
-                                processSourceMap(sourceMapTemp, baos, outputClassFile, symbol);
-                                writeFileToZip(zipOutputStream, sourceMapFilePath, baos, fileList);
-                            }
-                            writer.close();
-                        }
-                    }
-                    else if (cuType == ICompilationUnit.UnitType.SWC_UNIT)
-                    {
-                    	String symbol = cu.getQualifiedNames().get(0);
-                    	if (externs.contains(symbol)) continue;
-                    	if (project.isExternalLinkage(cu)) continue;
-                    	if (!packingSWC)
-                    	{
-                            // we probably shouldn't skip this -JT
-                            continue;
-                        }
-
-                        // if another .swc file is on our library-path, we must
-                        // include the .js (and .js.map) files because the
-                        // bytecode will also be included. if we have the
-                        // bytecode, but not the .js files, the compiler won't
-                        // know where to find the .js files. that's really bad.
-
-                        // if the bytecode and .js files should not be included,
-                        // then the developer is expected to use
-                        // external-library-path instead of library-path.
-
-                        SWCCompilationUnit swcCU = (SWCCompilationUnit) cu;
-                        String outputClassFile = getOutputClassFile(
-                                cu.getQualifiedNames().get(0),
-                                jsOut,
-                                false).getPath();
-                        outputClassFile = outputClassFile.replace('\\', '/');
-                        ISWCFileEntry fileEntry = swcCU.getSWC().getFile(outputClassFile);
-                        if (fileEntry == null)
-                        {
-                            continue;
-                        }
-                        if (config.isVerbose())
-                        {
-                            System.out.println("Writing file: " + outputClassFile + " from SWC: " + swcCU.getAbsoluteFilename());
-                        }
-                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-                        InputStream fileStream = fileEntry.createInputStream();
-                        IOUtils.copy(fileStream, baos);
-                        fileStream.close();
-                        writeFileToZip(zipOutputStream, outputClassFile, baos, fileList);
-
-                        String outputMapFile = outputClassFile + ".map";
-                        fileEntry = swcCU.getSWC().getFile(outputMapFile);
-                        if (fileEntry == null)
-                        {
-                            continue;
-                        }
-                        if (config.isVerbose())
-                        {
-                            System.out.println("Writing file: " + outputMapFile + " from SWC: " + swcCU.getAbsoluteFilename());
-                        }
-                        baos = new ByteArrayOutputStream();
-                        fileStream = fileEntry.createInputStream();
-                        IOUtils.copy(fileStream, baos);
-                        fileStream.close();
-                        writeFileToZip(zipOutputStream, outputMapFile, baos, fileList);
-                    }
-                }
-                if (packingSWC)
-                {
-                	zipFile.close();
-                    long fileDate = System.currentTimeMillis();
-                    long zipFileDate = fileDate;
-                	String metadataDate = targetSettings.getSWFMetadataDate();
-                	if (metadataDate != null)
-                	{
-                		String metadataFormat = targetSettings.getSWFMetadataDateFormat();
-                		try {
-                			SimpleDateFormat sdf = new SimpleDateFormat(metadataFormat);
-                			Date d = sdf.parse(metadataDate);
-                			Calendar cal = new GregorianCalendar();
-                			cal.setTime(d);
-                            sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
-                			d = sdf.parse(metadataDate);
-                			fileDate = d.getTime();
-                			ZonedDateTime zdt = ZonedDateTime.of(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH), 
-                									cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND), 0, ZoneId.systemDefault());
-                			zipFileDate = zdt.toInstant().toEpochMilli();
-                		} catch (ParseException e) {
-            				// TODO Auto-generated catch block
-            				e.printStackTrace();
-            			} catch (IllegalArgumentException e1) {
-            				e1.printStackTrace();
-            			}
-                        // TODO: Fix this the same way that the compiler normalized the date
-                        // strip off timezone.  Zip format doesn't store timezone
-                        // and the goal is to have the same date and time regardless
-                        // of which timezone the build machine is using.
-                        int c = metadataDate.lastIndexOf(' ');
-                        if(c != -1) {
-                            metadataDate = metadataDate.substring(0, c);
-                        }
-                        c = metadataFormat.lastIndexOf(' ');
-                        if(c != -1) {
-                            metadataFormat = metadataFormat.substring(0, c);
-                        }
-                		try {
-                			SimpleDateFormat sdf = new SimpleDateFormat(metadataFormat);
-                			Date d = sdf.parse(metadataDate);
-                			// zip file wants dates in local time
-                			Calendar cal = new GregorianCalendar();
-                			cal.setTime(d);
-                            sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
-                			d = sdf.parse(metadataDate);
-                			// other timestamps are in UTC
-                			fileDate = d.getTime();
-                			ZonedDateTime zdt = ZonedDateTime.of(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH), 
-                									cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND), 0, ZoneId.systemDefault());
-                			zipFileDate = zdt.toInstant().toEpochMilli();
-                		} catch (ParseException e) {
-            				// TODO Auto-generated catch block
-            				e.printStackTrace();
-            			} catch (IllegalArgumentException e1) {
-            				e1.printStackTrace();
-            			}
-                	}
-                	int libraryIndex = catalog.indexOf("</libraries>");
-                	catalog = catalog.substring(0, libraryIndex + 13) +
-                		"    <files>\n" + fileList.toString() + "    </files>" + 
-                		catalog.substring(libraryIndex + 13);
-                	ZipEntry ze = new ZipEntry(SWCReader.CATALOG_XML);
-                	ze.setTime(zipFileDate);
-                	ze.setMethod(ZipEntry.STORED);
-                	
-                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
-                	baos.write(catalog.getBytes());
-                    ze.setSize(baos.size());
-                    ze.setCompressedSize(baos.size());
-                    CRC32 crc = new CRC32();
-                    crc.reset();
-                    crc.update(baos.toByteArray());
-                    ze.setCrc(crc.getValue());
-                	
-                    zipOutputStream.putNextEntry(ze);
-                    baos.writeTo(zipOutputStream);
-                    zipOutputStream.flush();
-                    zipOutputStream.closeEntry();
-                    zipOutputStream.flush();
-                	zipOutputStream.close();
-                	swcFile.delete();
-                	File newSWCFile = new File(outputFolderName + ".new");
-                	newSWCFile.renameTo(swcFile);
-                }
-                compilationSuccess = true;
-            }
-        }
-        catch (Exception e)
-        {
-            System.out.println(e);
-            final ICompilerProblem problem = new InternalCompilerProblem(e);
-            problems.add(problem);
-        }
-
-        return compilationSuccess;
-    }
-
-    private void processSourceMap(ByteArrayOutputStream sourceMapTemp, ByteArrayOutputStream baos, File outputClassFile, String symbol)
-    {
-        String sourceMapSourceRoot = project.config.getSourceMapSourceRoot();
-        if(sourceMapSourceRoot != null && sourceMapSourceRoot.length() > 0)
-        {
-            String sourceMapContents = null;
-            try
-            {
-                sourceMapContents = sourceMapTemp.toString("utf8");
-            }
-            catch(UnsupportedEncodingException e)
-            {
-                sourceMapContents = null;
-            }
-            if(sourceMapContents != null)
-            {
-                SourceMapConsumerV3 sourceMapConsumer = new SourceMapConsumerV3();
-                try
-                {
-                    sourceMapConsumer.parse(sourceMapContents);
-                }
-                catch(SourceMapParseException e)
-                {
-                    sourceMapConsumer = null;
-                }
-                if (sourceMapConsumer != null && !sourceMapSourceRoot.equals(sourceMapConsumer.getSourceRoot()))
-                {
-                    SourceMapGeneratorV3 sourceMapGenerator = SourceMapUtils.sourceMapConsumerToGeneratorWithRemappedSourceRoot(sourceMapConsumer, sourceMapSourceRoot, symbol);
-                    String newSourceMapContents = SourceMapUtils.sourceMapGeneratorToString(sourceMapGenerator, outputClassFile.getName());
-                    try
-                    {
-                        IOUtils.write(newSourceMapContents, baos, Charset.forName("utf8"));
-                    }
-                    catch(IOException e)
-                    {
-                    }
-                    return;
-                }
-            }
-        }
-        try
-        {
-            sourceMapTemp.writeTo(baos);
-        }
-        catch(IOException e)
-        {
-
-        }
-    }
-
-    private void writeFileToZip(ZipOutputStream zipOutputStream, String entryFilePath, ByteArrayOutputStream baos, StringBuilder fileList) throws IOException
-    {
-        long fileDate = System.currentTimeMillis();
-        long zipFileDate = fileDate;
-        String metadataDate = targetSettings.getSWFMetadataDate();
-        if (metadataDate != null)
-        {
-            String metadataFormat = targetSettings.getSWFMetadataDateFormat();
-            try {
-                SimpleDateFormat sdf = new SimpleDateFormat(metadataFormat);
-                Date d = sdf.parse(metadataDate);
-                Calendar cal = new GregorianCalendar();
-                cal.setTime(d);
-                sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
-                d = sdf.parse(metadataDate);
-                fileDate = d.getTime();
-                ZonedDateTime zdt = ZonedDateTime.of(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH), 
-                                        cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND), 0, ZoneId.systemDefault());
-                zipFileDate = zdt.toInstant().toEpochMilli();
-            } catch (ParseException e) {
-                // TODO Auto-generated catch block
-                e.printStackTrace();
-            } catch (IllegalArgumentException e1) {
-                e1.printStackTrace();
-            }
-        }
-        ZipEntry ze = new ZipEntry(entryFilePath);
-        ze.setTime(zipFileDate);
-        ze.setMethod(ZipEntry.STORED);
-        
-        ze.setSize(baos.size());
-        ze.setCompressedSize(baos.size());
-        CRC32 crc = new CRC32();
-        crc.reset();
-        crc.update(baos.toByteArray());
-        ze.setCrc(crc.getValue());
-
-        zipOutputStream.putNextEntry(ze);
-        baos.writeTo(zipOutputStream);
-        zipOutputStream.flush();
-        zipOutputStream.closeEntry();
-        fileList.append("        <file path=\"" + entryFilePath + "\" mod=\"" + fileDate + "\"/>\n");
-    }
-
-    /**
-     * Build target artifact.
-     * 
-     * @throws InterruptedException threading error
-     * @throws IOException IO error
-     * @throws ConfigurationException
-     */
-    @Override
-    protected void buildArtifact() throws InterruptedException, IOException,
-            ConfigurationException
-    {
-        jsTarget = buildJSTarget();
-    }
-
-    private IJSApplication buildJSTarget() throws InterruptedException,
-            FileNotFoundException, ConfigurationException
-    {
-        final List<ICompilerProblem> problemsBuildingSWF = new ArrayList<ICompilerProblem>();
-
-        final IJSApplication app = buildApplication(project,
-                config.getMainDefinition(), null, problemsBuildingSWF);
-        problems.addAll(problemsBuildingSWF);
-        if (app == null)
-        {
-            ICompilerProblem problem = new UnableToBuildSWFProblem(
-                    getOutputFilePath());
-            problems.add(problem);
-        }
-
-        return app;
-    }
-
-    /**
-     * Replaces RoyaleApplicationProject::buildSWF()
-     * 
-     * @param applicationProject
-     * @param rootClassName
-     * @param problems
-     * @return
-     * @throws InterruptedException
-     */
-
-    private IJSApplication buildApplication(CompilerProject applicationProject,
-            String rootClassName, ICompilationUnit mainCU,
-            Collection<ICompilerProblem> problems) throws InterruptedException,
-            ConfigurationException, FileNotFoundException
-    {
-        Collection<ICompilerProblem> fatalProblems = applicationProject.getFatalProblems();
-        if (!fatalProblems.isEmpty())
-        {
-            problems.addAll(fatalProblems);
-            return null;
-        }
-
-        return ((JSTarget) target).build(mainCU, problems);
-    }
-
-    /**
-     * Get the output file path. If {@code -output} is specified, use its value;
-     * otherwise, use the same base name as the target file.
-     * 
-     * @return output file path
-     */
-    private String getOutputFilePath()
-    {
-        if (config.getOutput() == null)
-        {
-            final String extension = "." + project.getBackend().getOutputExtension();
-            return FilenameUtils.removeExtension(config.getTargetFile()).concat(
-                    extension);
-        }
-        else
-        {
-            String outputFolderName = config.getOutput();
-            return outputFolderName;
-        }
-    }
-
-    /**
-     * 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, if specified.
-     * 
-     * @author Erik de Bruin
-     * @param qname
-     * @param outputFolder
-     * @param createDirs
-     * @return output class file path
-     */
-    private File getOutputClassFile(String qname, File outputFolder, boolean createDirs)
-    {
-        String[] cname = qname.split("\\.");
-        String sdirPath = outputFolder + File.separator;
-        if (cname.length > 0)
-        {
-            for (int i = 0, n = cname.length - 1; i < n; i++)
-            {
-                sdirPath += cname[i] + File.separator;
-            }
-
-            if (createDirs)
-            {
-                File sdir = new File(sdirPath);
-                if (!sdir.exists())
-                    sdir.mkdirs();
-            }
-
-            qname = cname[cname.length - 1];
-        }
-
-        return new File(sdirPath + qname + "." + project.getBackend().getOutputExtension());
-    }
-
-    /**
-     * Similar to getOutputClassFile, but for the source map file.
-     * 
-     * @param qname
-     * @param outputFolder
-     * @param createDirs
-     * @return output source map file path
-     */
-    private File getOutputSourceMapFile(String qname, File outputFolder, boolean createDirs)
-    {
-        String[] cname = qname.split("\\.");
-        String sdirPath = outputFolder + File.separator;
-        if (cname.length > 0)
-        {
-            for (int i = 0, n = cname.length - 1; i < n; i++)
-            {
-                sdirPath += cname[i] + File.separator;
-            }
-
-            if (createDirs)
-            {
-                File sdir = new File(sdirPath);
-                if (!sdir.exists())
-                    sdir.mkdirs();
-            }
-
-            qname = cname[cname.length - 1];
-        }
-
-        return new File(sdirPath + qname + "." + project.getBackend().getOutputExtension() + ".map");
-    }
-
-    /**
-     * Mxmlc uses target file as the main compilation unit and derive the output
-     * SWF file name from this file.
-     * 
-     * @return true if successful, false otherwise.
-     * @throws InterruptedException
-     */
-    @Override
-    protected boolean setupTargetFile() throws InterruptedException
-    {
-        config.getTargetFile();
-
-        ITargetSettings settings = getTargetSettings();
-        if (settings != null)
-            project.setTargetSettings(settings);
-        else
-            return false;
-
-        target = project.getBackend().createTarget(project,
-                getTargetSettings(), null);
-
-        return true;
-    }
-
-    private ITargetSettings getTargetSettings()
-    {
-        if (targetSettings == null)
-            targetSettings = projectConfigurator.getTargetSettings(getTargetType());
-
-        if (targetSettings == null)
-            problems.addAll(projectConfigurator.getConfigurationProblems());
-
-        return targetSettings;
-    }
-
-    /**
-     * Validate target file.
-     * 
-     * @throws MustSpecifyTarget
-     * @throws IOError
-     */
-    @Override
-    protected void validateTargetFile() throws ConfigurationException
-    {
-
-    }
-
     protected String getProgramName()
     {
         return "compc";
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 9b3a2ec..5951645 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
@@ -19,14 +19,8 @@
 
 package org.apache.royale.compiler.clients;
 
-import java.io.BufferedOutputStream;
 import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
 import java.io.OutputStream;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
 import java.util.*;
 
 import org.apache.commons.io.FilenameUtils;
@@ -35,8 +29,6 @@
 import org.apache.royale.compiler.clients.problems.ProblemQuery;
 import org.apache.royale.compiler.clients.problems.ProblemQueryProvider;
 import org.apache.royale.compiler.clients.problems.WorkspaceProblemFormatter;
-import org.apache.royale.compiler.codegen.js.IJSWriter;
-import org.apache.royale.compiler.codegen.js.goog.IJSGoogPublisher;
 import org.apache.royale.compiler.common.VersionInfo;
 import org.apache.royale.compiler.config.CommandLineConfigurator;
 import org.apache.royale.compiler.config.CompilerDiagnosticsConstants;
@@ -47,35 +39,25 @@
 import org.apache.royale.compiler.config.ICompilerProblemSettings;
 import org.apache.royale.compiler.config.ICompilerSettingsConstants;
 import org.apache.royale.compiler.driver.js.IJSApplication;
-import org.apache.royale.compiler.exceptions.ConfigurationException;
-import org.apache.royale.compiler.exceptions.ConfigurationException.IOError;
-import org.apache.royale.compiler.exceptions.ConfigurationException.MustSpecifyTarget;
 import org.apache.royale.compiler.exceptions.ConfigurationException.OnlyOneSource;
 import org.apache.royale.compiler.internal.config.FlashBuilderConfigurator;
 import org.apache.royale.compiler.internal.config.localization.LocalizationManager;
 import org.apache.royale.compiler.internal.definitions.DefinitionBase;
 import org.apache.royale.compiler.internal.driver.js.goog.JSGoogConfiguration;
 import org.apache.royale.compiler.internal.parsing.as.RoyaleASDocDelegate;
-import org.apache.royale.compiler.internal.projects.CompilerProject;
 import org.apache.royale.compiler.internal.projects.RoyaleJSProject;
 import org.apache.royale.compiler.internal.projects.RoyaleProjectConfigurator;
 import org.apache.royale.compiler.internal.projects.ISourceFileHandler;
-import org.apache.royale.compiler.internal.targets.RoyaleJSTarget;
-import org.apache.royale.compiler.internal.targets.JSTarget;
-import org.apache.royale.compiler.internal.units.ResourceModuleCompilationUnit;
 import org.apache.royale.compiler.internal.units.SourceCompilationUnitFactory;
 import org.apache.royale.compiler.internal.workspaces.Workspace;
 import org.apache.royale.compiler.problems.ConfigurationProblem;
 import org.apache.royale.compiler.problems.ICompilerProblem;
-import org.apache.royale.compiler.problems.InternalCompilerProblem;
-import org.apache.royale.compiler.problems.UnableToBuildSWFProblem;
 import org.apache.royale.compiler.problems.UnexpectedExceptionProblem;
 import org.apache.royale.compiler.projects.ICompilerProject;
 import org.apache.royale.compiler.targets.ITarget;
 import org.apache.royale.compiler.targets.ITarget.TargetType;
 import org.apache.royale.compiler.targets.ITargetSettings;
 import org.apache.royale.compiler.units.ICompilationUnit;
-import org.apache.royale.compiler.utils.ClosureUtils;
 import org.apache.royale.swf.ISWF;
 import org.apache.royale.swf.SWF;
 import org.apache.royale.swf.types.RGB;
@@ -273,7 +255,6 @@
     protected ITarget target;
     protected ITargetSettings targetSettings;
     protected IJSApplication jsTarget;
-    private IJSGoogPublisher jsPublisher;
     protected MXMLC mxmlc;
     protected JSCompilerEntryPoint lastCompiler;
     public boolean noLink;
@@ -495,296 +476,6 @@
     	}
     	return list.toArray(new String[0]);
     }
-    
-    /**
-     * Main body of this program. This method is called from the public static
-     * method's for this program.
-     * 
-     * @return true if compiler succeeds
-     * @throws IOException
-     * @throws InterruptedException
-     */
-    protected boolean compile()
-    {
-        JSGoogConfiguration googConfiguration = (JSGoogConfiguration) config;
-        boolean compilationSuccess = false;
-
-        try
-        {
-            project.getSourceCompilationUnitFactory().addHandler(asFileHandler);
-
-            if (!googConfiguration.getSkipTranspile())
-            {
-	            if (!setupTargetFile()) {
-                    return false;
-                }
-
-	            buildArtifact();
-            }
-            if (jsTarget != null || googConfiguration.getSkipTranspile())
-            {
-                List<ICompilerProblem> errors = new ArrayList<ICompilerProblem>();
-                List<ICompilerProblem> warnings = new ArrayList<ICompilerProblem>();
-
-                if (!config.getCreateTargetWithErrors())
-                {
-                    problems.getErrorsAndWarnings(errors, warnings);
-                    if (errors.size() > 0)
-                        return false;
-                }
-
-                Set<String> closurePropNamesToKeep = new HashSet<String>();
-                //use a LinkedHashSet because the order of the exported names matters -JT
-                LinkedHashSet<String> closureSymbolNamesToExport = new LinkedHashSet<String>();
-                jsPublisher = (IJSGoogPublisher) project.getBackend().createPublisher(
-                        project, errors, config);
-
-                File outputFolder = jsPublisher.getOutputFolder();
-
-                if (!googConfiguration.getSkipTranspile())
-                {
-	                ArrayList<ICompilationUnit> roots = new ArrayList<ICompilationUnit>();
-	                roots.add(mainCU);
-	                Set<ICompilationUnit> incs = target.getIncludesCompilationUnits();
-	                roots.addAll(incs);
-	                project.mixinClassNames = new TreeSet<String>();
-	                project.remoteClassAliasMap = new HashMap<String, String>();
-	                List<ICompilationUnit> reachableCompilationUnits = project.getReachableCompilationUnitsInSWFOrder(roots);
-	                ((RoyaleJSTarget)target).collectMixinMetaData(project.mixinClassNames, reachableCompilationUnits);
-	                ((RoyaleJSTarget)target).collectRemoteClassMetaData(project.remoteClassAliasMap, reachableCompilationUnits);
-	                for (final ICompilationUnit cu : reachableCompilationUnits)
-	                {
-                        writeCompilationUnit(cu, outputFolder);
-                        ClosureUtils.collectPropertyNamesToKeep(cu, project, closurePropNamesToKeep);
-                        ClosureUtils.collectSymbolNamesToExport(cu, project, closureSymbolNamesToExport);
-	                }
-                }
-                
-                if (jsPublisher != null)
-                {
-                    jsPublisher.setClosurePropertyNamesToKeep(closurePropNamesToKeep);
-                    jsPublisher.setClosureSymbolNamesToExport(closureSymbolNamesToExport);
-                    compilationSuccess = jsPublisher.publish(problems);
-                }
-                else
-                {
-                    compilationSuccess = true;
-                }
-            }
-        }
-        catch (Exception e)
-        {
-            final ICompilerProblem problem = new InternalCompilerProblem(e);
-            problems.add(problem);
-        }
-
-        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.
-     * 
-     * @throws InterruptedException threading error
-     * @throws IOException IO error
-     * @throws ConfigurationException
-     */
-    protected void buildArtifact() throws InterruptedException, IOException,
-            ConfigurationException
-    {
-        jsTarget = buildJSTarget();
-    }
-
-    private IJSApplication buildJSTarget() throws InterruptedException,
-            FileNotFoundException, ConfigurationException
-    {
-        final List<ICompilerProblem> problemsBuildingSWF = new ArrayList<ICompilerProblem>();
-
-        project.mainCU = mainCU;
-        final IJSApplication app = buildApplication(project,
-                config.getMainDefinition(), mainCU, problemsBuildingSWF);
-        problems.addAll(problemsBuildingSWF);
-        if (app == null)
-        {
-            ICompilerProblem problem = new UnableToBuildSWFProblem(
-                    getOutputFilePath());
-            problems.add(problem);
-        }
-
-        return app;
-    }
-
-    /**
-     * Replaces RoyaleApplicationProject::buildSWF()
-     * 
-     * @param applicationProject
-     * @param rootClassName
-     * @param problems
-     * @return
-     * @throws InterruptedException
-     */
-
-    private IJSApplication buildApplication(CompilerProject applicationProject,
-            String rootClassName, ICompilationUnit mainCU,
-            Collection<ICompilerProblem> problems) throws InterruptedException,
-            ConfigurationException, FileNotFoundException
-    {
-        Collection<ICompilerProblem> fatalProblems = applicationProject.getFatalProblems();
-        if (!fatalProblems.isEmpty())
-        {
-            problems.addAll(fatalProblems);
-            return null;
-        }
-
-        return ((JSTarget) target).build(mainCU, problems);
-    }
-
-    /**
-     * Get the output file path. If {@code -output} is specified, use its value;
-     * otherwise, use the same base name as the target file.
-     * 
-     * @return output file path
-     */
-    private String getOutputFilePath()
-    {
-        if (config.getOutput() == null)
-        {
-            final String extension = "." + project.getBackend().getOutputExtension();
-            return FilenameUtils.removeExtension(config.getTargetFile()).concat(
-                    extension);
-        }
-        else
-            return config.getOutput();
-    }
-
-    /**
-     * @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.
-     * 
-     * @param qname
-     * @param outputFolder
-     * @return output class file path
-     */
-    private File getOutputClassFile(String qname, File outputFolder)
-    {
-        String[] cname = qname.split("\\.");
-        String sdirPath = outputFolder + File.separator;
-        if (cname.length > 0)
-        {
-            for (int i = 0, n = cname.length - 1; i < n; i++)
-            {
-                sdirPath += cname[i] + File.separator;
-            }
-
-            File sdir = new File(sdirPath);
-            if (!sdir.exists())
-                sdir.mkdirs();
-
-            qname = cname[cname.length - 1];
-        }
-
-        return new File(sdirPath + qname + "." + project.getBackend().getOutputExtension());
-    }
-
-    /**
-     * @param qname
-     * @param outputFolder
-     * @return output source map file path
-     */
-    private File getOutputSourceMapFile(String qname, File outputFolder)
-    {
-        String[] cname = qname.split("\\.");
-        String sdirPath = outputFolder + File.separator;
-        if (cname.length > 0)
-        {
-            for (int i = 0, n = cname.length - 1; i < n; i++)
-            {
-                sdirPath += cname[i] + File.separator;
-            }
-
-            File sdir = new File(sdirPath);
-            if (!sdir.exists())
-                sdir.mkdirs();
-
-            qname = cname[cname.length - 1];
-        }
-
-        return new File(sdirPath + qname + "." + project.getBackend().getOutputExtension() + ".map");
-    }
 
     /**
      * Mxmlc uses target file as the main compilation unit and derive the output
@@ -1040,26 +731,6 @@
     }
 
     /**
-     * Validate target file.
-     * 
-     * @throws MustSpecifyTarget
-     * @throws IOError
-     */
-    protected void validateTargetFile() throws ConfigurationException
-    {
-        if (mainCU instanceof ResourceModuleCompilationUnit)
-            return; //when compiling a Resource Module, no target file is defined.
-
-        final String targetFile = config.getTargetFile();
-        if (targetFile == null)
-            throw new ConfigurationException.MustSpecifyTarget(null, null, -1);
-
-        final File file = new File(targetFile);
-        if (!file.exists())
-            throw new ConfigurationException.IOError(targetFile);
-    }
-
-    /**
      * Wait till the workspace to finish compilation and close.
      */
     protected void waitAndClose()