flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ftho...@apache.org
Subject [1/2] git commit: [flex-falcon] [refs/heads/IDEA-FLEX_JS_COMPILER] - Can now compile with IntelliJ Application and Libraries - Would be nice to stub the legacy oem Configuration now.
Date Thu, 28 May 2015 14:25:34 GMT
Repository: flex-falcon
Updated Branches:
  refs/heads/IDEA-FLEX_JS_COMPILER 15b6dd076 -> 92fdcc758 (forced update)


Can now compile with IntelliJ Application and Libraries
- Would be nice to stub the legacy oem Configuration now.


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

Branch: refs/heads/IDEA-FLEX_JS_COMPILER
Commit: 6ddfb7b228d55d22663d570a2b2266f2efcb34af
Parents: 1208609
Author: Frédéric THOMAS <webdoublefx@gmail.com>
Authored: Thu May 28 15:19:12 2015 +0100
Committer: Frédéric THOMAS <webdoublefx@gmail.com>
Committed: Thu May 28 15:19:12 2015 +0100

----------------------------------------------------------------------
 .../apache/flex/compiler/clients/COMPJSC.java   |   4 +-
 .../compiler/clients/JSCompilerEntryPoint.java  |  15 +
 .../apache/flex/compiler/clients/MXMLJSC.java   |  14 +-
 .../clients/problems/ProblemQueryProvider.java  |  12 +
 .../src/flex2/compiler/CompilerAPI.java         |  55 +++-
 .../compiler/common/LocalFilePathResolver.java  |  83 +++++
 .../config/CommandLineConfigurator.java         |   7 +-
 .../src/flex2/compiler/io/NetworkFile.java      | 148 +++++++++
 .../src/flex2/compiler/util/ManifestParser.java | 239 ++++++++++++++
 .../src/flex2/compiler/util/NameMappings.java   | 183 +++++++++++
 .../flex2/compiler/util/ThreadLocalToolkit.java |   7 +-
 .../flex2/compiler/util/URLPathResolver.java    |  75 +++++
 flex-compiler-oem/src/flex2/tools/CompJSC.java  |  15 +
 flex-compiler-oem/src/flex2/tools/Compc.java    |  57 ++++
 flex-compiler-oem/src/flex2/tools/MxmlJSC.java  |  76 +++++
 flex-compiler-oem/src/flex2/tools/Mxmlc.java    | 325 +++++++++++++++++++
 flex-compiler-oem/src/flex2/tools/Tool.java     | 242 ++++++++++++++
 17 files changed, 1535 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6ddfb7b2/compiler.jx/src/org/apache/flex/compiler/clients/COMPJSC.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/clients/COMPJSC.java b/compiler.jx/src/org/apache/flex/compiler/clients/COMPJSC.java
index 5a953f8..694e521 100644
--- a/compiler.jx/src/org/apache/flex/compiler/clients/COMPJSC.java
+++ b/compiler.jx/src/org/apache/flex/compiler/clients/COMPJSC.java
@@ -61,7 +61,7 @@ import sun.reflect.generics.reflectiveObjects.NotImplementedException;
  * @author Erik de Bruin
  * @author Michael Schmalle
  */
-public class COMPJSC extends MXMLJSC implements FlexTool
+public class COMPJSC extends MXMLJSC
 {
     /*
      * Exit code enumerations.
@@ -153,7 +153,7 @@ public class COMPJSC extends MXMLJSC implements FlexTool
         return exitCode;
     }
 
-    protected COMPJSC(IBackend backend)
+    public COMPJSC(IBackend backend)
     {
         super(backend);
     }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6ddfb7b2/compiler.jx/src/org/apache/flex/compiler/clients/JSCompilerEntryPoint.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/clients/JSCompilerEntryPoint.java b/compiler.jx/src/org/apache/flex/compiler/clients/JSCompilerEntryPoint.java
new file mode 100644
index 0000000..b30066a
--- /dev/null
+++ b/compiler.jx/src/org/apache/flex/compiler/clients/JSCompilerEntryPoint.java
@@ -0,0 +1,15 @@
+package org.apache.flex.compiler.clients;
+
+import org.apache.flex.compiler.problems.ICompilerProblem;
+
+import java.util.Set;
+
+/**
+ * @author: Frederic Thomas
+ * Date: 26/05/2015
+ * Time: 16:56
+ */
+public interface JSCompilerEntryPoint {
+    public int mainNoExit(final String[] args, Set<ICompilerProblem> problems,
+                          Boolean printProblems);
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6ddfb7b2/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 c968086..60f9915 100644
--- a/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
+++ b/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
@@ -34,6 +34,7 @@ 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;
+import org.apache.flex.compiler.clients.problems.ProblemQueryProvider;
 import org.apache.flex.compiler.clients.problems.WorkspaceProblemFormatter;
 import org.apache.flex.compiler.codegen.as.IASWriter;
 import org.apache.flex.compiler.codegen.js.IJSPublisher;
@@ -89,11 +90,15 @@ import com.google.common.collect.Iterables;
  * @author Erik de Bruin
  * @author Michael Schmalle
  */
-public class MXMLJSC implements FlexTool
+public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, FlexTool
 {
+    public ProblemQuery getProblemQuery() {
+        return problems;
+    }
+
     /*
-     * JS output type enumerations.
-     */
+		 * JS output type enumerations.
+		 */
     public enum JSOutputType
     {
         AMD("amd"), FLEXJS("flexjs"), GOOG("goog"), VF2JS("vf2js");
@@ -222,6 +227,7 @@ public class MXMLJSC implements FlexTool
 
     protected Workspace workspace;
     protected FlexJSProject project;
+
     protected ProblemQuery problems;
     protected ISourceFileHandler asFileHandler;
     protected Configuration config;
@@ -233,7 +239,7 @@ public class MXMLJSC implements FlexTool
     protected IJSApplication jsTarget;
     private IJSPublisher jsPublisher;
 
-    protected MXMLJSC(IBackend backend)
+    public MXMLJSC(IBackend backend)
     {
         JSSharedData.backend = backend;
         workspace = new Workspace();

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6ddfb7b2/compiler/src/org/apache/flex/compiler/clients/problems/ProblemQueryProvider.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/clients/problems/ProblemQueryProvider.java b/compiler/src/org/apache/flex/compiler/clients/problems/ProblemQueryProvider.java
new file mode 100644
index 0000000..dcce2cc
--- /dev/null
+++ b/compiler/src/org/apache/flex/compiler/clients/problems/ProblemQueryProvider.java
@@ -0,0 +1,12 @@
+package org.apache.flex.compiler.clients.problems;
+
+import org.apache.flex.compiler.clients.problems.ProblemQuery;
+
+/**
+ * @author: Frederic Thomas
+ * Date: 26/05/2015
+ * Time: 15:44
+ */
+public interface ProblemQueryProvider {
+	public ProblemQuery getProblemQuery();
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6ddfb7b2/flex-compiler-oem/src/flex2/compiler/CompilerAPI.java
----------------------------------------------------------------------
diff --git a/flex-compiler-oem/src/flex2/compiler/CompilerAPI.java b/flex-compiler-oem/src/flex2/compiler/CompilerAPI.java
index 54cd78e..a4f7201 100644
--- a/flex-compiler-oem/src/flex2/compiler/CompilerAPI.java
+++ b/flex-compiler-oem/src/flex2/compiler/CompilerAPI.java
@@ -22,11 +22,16 @@ package flex2.compiler;
 import java.io.File;
 import java.io.IOException;
 
+import flex2.compiler.common.Configuration;
+import flex2.compiler.common.LocalFilePathResolver;
+import flex2.compiler.common.SinglePathResolver;
 import flex2.compiler.io.LocalFile;
 import flex2.compiler.io.VirtualFile;
 import flex2.compiler.config.ConfigurationException;
+import flex2.compiler.util.ConsoleLogger;
 import flex2.compiler.util.ThreadLocalToolkit;
 import flex2.compiler.common.PathResolver;
+import flex2.compiler.util.URLPathResolver;
 
 /**
  * This class orchestrates delegation to the subcompilers using
@@ -35,14 +40,6 @@ import flex2.compiler.common.PathResolver;
  * an incremental compilation, resolving dependences, loading a cache
  * from a previous compilation, and storing a compilation cache.
  *
- * @see flex2.compiler.SubCompiler
- * @see flex2.compiler.PersistentStore
- * @see flex2.compiler.abc.AbcCompiler
- * @see flex2.compiler.as3.As3Compiler
- * @see flex2.compiler.css.CssCompiler
- * @see flex2.compiler.fxg.FXGCompiler
- * @see flex2.compiler.i18n.I18nCompiler
- * @see flex2.compiler.mxml.MxmlCompiler
  * @author Clement Wong
  */
 public final class CompilerAPI
@@ -52,6 +49,48 @@ public final class CompilerAPI
     //private final static int TYPES = 3;
     //private final static int EXPRESSIONS = 4;
 
+
+    public static void useAS3()
+    {
+        // do this so there is no need to start java with -DAS3 and -DAVMPLUS...
+        // this will likely not work in server environment.
+        System.setProperty("AS3", "");
+        System.setProperty("AVMPLUS", "");
+    }
+
+	public static void useConsoleLogger()
+	{
+		useConsoleLogger(true, true, true, true);
+	}
+
+	public static void useConsoleLogger(boolean isInfoEnabled, boolean isDebugEnabled, boolean isWarningEnabled, boolean isErrorEnabled)
+	{
+		ThreadLocalToolkit.setLogger(new ConsoleLogger(isInfoEnabled, isDebugEnabled, isWarningEnabled, isErrorEnabled));
+	}
+
+	public static void usePathResolver()
+	{
+		usePathResolver(null);
+	}
+
+	public static void usePathResolver(SinglePathResolver resolver)
+	{
+		PathResolver pathResolver = new PathResolver();
+		if (resolver != null)
+		{
+			pathResolver.addSinglePathResolver(resolver);
+		}
+		pathResolver.addSinglePathResolver( LocalFilePathResolver.getSingleton() );
+		pathResolver.addSinglePathResolver( URLPathResolver.getSingleton() );
+		ThreadLocalToolkit.setPathResolver(pathResolver);
+	}
+
+	public static void removePathResolver()
+	{
+		ThreadLocalToolkit.setPathResolver(null);
+		ThreadLocalToolkit.resetResolvedPaths();
+	}
+
 	static String constructClassName(String namespaceURI, String localPart)
 	{
 		return (namespaceURI.length() == 0) ? localPart : new StringBuilder(namespaceURI.length() + localPart.length() + 1).append(namespaceURI).append(":").append(localPart).toString();

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6ddfb7b2/flex-compiler-oem/src/flex2/compiler/common/LocalFilePathResolver.java
----------------------------------------------------------------------
diff --git a/flex-compiler-oem/src/flex2/compiler/common/LocalFilePathResolver.java b/flex-compiler-oem/src/flex2/compiler/common/LocalFilePathResolver.java
new file mode 100644
index 0000000..e329edf
--- /dev/null
+++ b/flex-compiler-oem/src/flex2/compiler/common/LocalFilePathResolver.java
@@ -0,0 +1,83 @@
+/*
+ *
+ *  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 flex2.compiler.common;
+
+import flash.util.FileUtils;
+import flash.util.Trace;
+import flex2.compiler.io.VirtualFile;
+import flex2.compiler.io.FileUtil;
+import flex2.compiler.io.LocalFile;
+
+import java.io.File;
+
+/**
+ * This class handles resolving absolute file paths.  This resolver
+ * explicitly does not resolve relative paths, because it is included
+ * in the ThreadLocalToolkit's global PathResolver.  The
+ * ThreadLocalToolkit's global PathResolver is used to resolve things
+ * like @Embed assets and we don't want paths which are relative to
+ * the current working directory and not relative to the containing
+ * Mxml document to be resolved.  For example, if we have:
+ *
+ *   C:/foo/bar.mxml
+ *
+ * with:
+ *
+ *   <mx:Image source="@Embed(source='image.jpg')"/>
+ *
+ * and:
+ *
+ *   C:/foo/image.jpg
+ *   C:/image.jpg
+ *
+ * When the current working directory is C:/, we don't want resolve() to return
+ * C:/image.jpg.
+ */
+public class LocalFilePathResolver implements SinglePathResolver
+{
+    private static final LocalFilePathResolver singleton = new LocalFilePathResolver();
+
+    private LocalFilePathResolver()
+    {
+    }
+
+    public static LocalFilePathResolver getSingleton()
+    {
+        return singleton;
+    }
+
+    public VirtualFile resolve( String pathStr )
+    {
+        File path = FileUtil.openFile(pathStr);
+        VirtualFile virt = null;
+
+        if (path != null && FileUtils.exists(path) && FileUtils.isAbsolute(path))
+        {
+            virt = new LocalFile(path);
+        }
+
+        if ((virt != null) && Trace.pathResolver)
+        {
+            Trace.trace("LocalFilePathResolver.resolve: resolved " + pathStr + " to " + virt.getName());
+        }
+
+        return virt;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6ddfb7b2/flex-compiler-oem/src/flex2/compiler/config/CommandLineConfigurator.java
----------------------------------------------------------------------
diff --git a/flex-compiler-oem/src/flex2/compiler/config/CommandLineConfigurator.java b/flex-compiler-oem/src/flex2/compiler/config/CommandLineConfigurator.java
index 9632b47..3c07a6f 100644
--- a/flex-compiler-oem/src/flex2/compiler/config/CommandLineConfigurator.java
+++ b/flex-compiler-oem/src/flex2/compiler/config/CommandLineConfigurator.java
@@ -19,11 +19,12 @@
 
 package flex2.compiler.config;
 
-//import flash.localization.LocalizationManager;
+import flash.localization.LocalizationManager;
 
 import java.util.Arrays;
 import java.util.List;
 import java.util.LinkedList;
+import java.util.TreeSet;
 import java.util.Set;
 import java.util.Iterator;
 import java.util.HashSet;
@@ -369,7 +370,6 @@ public class CommandLineConfigurator
         return ((c == boolean.class) || (c == Boolean.class));
     }
 
-    /*
     public static String brief( String program, String defaultvar, LocalizationManager l10n, String l10nPrefix )
     {
         Map<String, String> params = new HashMap<String, String>();
@@ -486,7 +486,7 @@ public class CommandLineConfigurator
                             printSet.add( var );
                         }
                     }
-                    *//*
+                    */
                 }
             }
         }
@@ -637,7 +637,6 @@ public class CommandLineConfigurator
         }
         return text;
     }
-    */
     
     public static final String source = SOURCE_COMMAND_LINE;
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6ddfb7b2/flex-compiler-oem/src/flex2/compiler/io/NetworkFile.java
----------------------------------------------------------------------
diff --git a/flex-compiler-oem/src/flex2/compiler/io/NetworkFile.java b/flex-compiler-oem/src/flex2/compiler/io/NetworkFile.java
new file mode 100644
index 0000000..44d7a2f
--- /dev/null
+++ b/flex-compiler-oem/src/flex2/compiler/io/NetworkFile.java
@@ -0,0 +1,148 @@
+/*
+ *
+ *  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 flex2.compiler.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+
+/**
+ * A VirtualFile implemenation, which is backed by a file not on a
+ * local disk.
+ */
+public class NetworkFile implements VirtualFile
+{
+	public NetworkFile(URL u) throws IOException
+	{
+		name = u.toExternalForm();
+		conn = u.openConnection();
+	}
+
+	private String name;
+	private URLConnection conn;
+
+	/**
+	 * Return name... It could be canonical path name, URL, etc. But it must be unique among all the files
+	 * processed by the compiler...
+	 *
+	 * The compiler should not use this to get... e.g. parent path... There is no guarantee that this returns
+	 * a pathname even though the underlying implementation deals with files...
+	 */
+	public String getName()
+	{
+		return name;
+	}
+
+	public String getNameForReporting()
+	{
+		return getName();
+	}
+
+	public String getURL()
+	{
+		return name;
+	}
+
+	public String getParent()
+	{
+		return null;
+	}
+
+    public boolean isDirectory()
+    {
+        return false;
+    }
+
+    /**
+	 * Return file size...
+	 */
+	public long size()
+	{
+		return conn.getContentLength();
+	}
+
+	/**
+	 * Return mime type
+	 */
+	public String getMimeType()
+	{
+		return conn.getContentType();
+	}
+
+	/**
+	 * Return input stream...
+	 */
+	public InputStream getInputStream() throws IOException
+	{
+		return conn.getInputStream();
+	}
+
+	public byte[] toByteArray() throws IOException
+	{
+		throw new UnsupportedOperationException("toByteArray() not supported in " + this.getClass().getName());
+	}
+	
+	/**
+	 * Return last time the underlying source is modified.
+	 */
+	public long getLastModified()
+	{
+		return conn.getLastModified();
+	}
+
+	/**
+	 * Return an instance of this interface which represents the specified relative path.
+	 */
+	public VirtualFile resolve(String relative)
+	{
+		return null;
+	}
+
+	/**
+	 * Signal the hosting environment that this instance is no longer used.
+	 */
+	public void close()
+	{
+	}
+
+
+	public boolean equals(Object obj)
+	{
+		if (obj instanceof NetworkFile)
+		{
+			return (this == obj) || name.equals(((NetworkFile) obj).name);
+		}
+		else
+		{
+			return false;
+		}
+	}
+
+	public int hashCode()
+	{
+		return name.hashCode();
+	}
+
+	public boolean isTextBased()
+	{
+		return false;
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6ddfb7b2/flex-compiler-oem/src/flex2/compiler/util/ManifestParser.java
----------------------------------------------------------------------
diff --git a/flex-compiler-oem/src/flex2/compiler/util/ManifestParser.java b/flex-compiler-oem/src/flex2/compiler/util/ManifestParser.java
new file mode 100644
index 0000000..97f57ef
--- /dev/null
+++ b/flex-compiler-oem/src/flex2/compiler/util/ManifestParser.java
@@ -0,0 +1,239 @@
+/*
+ *
+ *  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 flex2.compiler.util;
+
+import flex2.compiler.io.VirtualFile;
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import java.io.BufferedInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Parses a manifest into a NameMappings.
+ *
+ */
+public class ManifestParser
+{
+    public synchronized static void parse(String namespaceURI, VirtualFile file, NameMappings mappings)
+    {
+        if (file == null)
+        {
+            return;
+        }
+
+        InputStream in = null;
+
+        try
+        {
+            in = new BufferedInputStream(file.getInputStream());
+        }
+        catch (FileNotFoundException ex)
+        {
+            // manifest is not found.
+            return;
+        }
+        catch (IOException ex)
+        {
+            ThreadLocalToolkit.logError(file.getNameForReporting(), ex.getMessage());
+            return;
+        }
+
+        try
+        {
+            SAXParserFactory factory = SAXParserFactory.newInstance();
+            factory.setNamespaceAware(true);
+            SAXParser parser = factory.newSAXParser();
+            parser.parse(in, new Parser(file.getName(), mappings, namespaceURI));
+        }
+        catch (Exception ex) // ParserConfigurationException, SAXException, IOException
+        {
+            ThreadLocalToolkit.logError(file.getNameForReporting(), ex.getMessage());
+        }
+        finally
+        {
+            if (in != null)
+            {
+                try
+                {
+                    in.close();
+                }
+                catch (IOException ex)
+                {
+                }
+            }
+        }
+    }
+
+    private static class Parser extends DefaultHandler
+    {
+        Parser(String fileName, NameMappings mappings, String namespaceURI)
+        {
+            this.fileName = fileName;
+            this.mappings = mappings;
+            this.namespaceURI = namespaceURI;
+        }
+
+        private String fileName;
+        private NameMappings mappings;
+        private String namespaceURI;
+        private Locator locator;
+
+        public void startElement(String uri, String localName, String qName, Attributes attributes)
+                throws SAXException
+        {
+            if (localName.equals("component"))
+            {
+                String id = attributes.getValue("id");
+                String className = attributes.getValue("class");
+                if (className == null)
+                {
+	                ThreadLocalToolkit.log(new UndefinedClass(fileName, locator.getLineNumber(), id));
+                    return;
+                }
+                else if ("*".equals(className))
+                {
+	                ThreadLocalToolkit.log(new InvalidClassName(fileName, locator.getLineNumber(), id));
+                }
+	            else
+                {
+	                assert className.indexOf(':') == -1 && className.indexOf('/') == -1 : fileName + ": " + className;
+	                className = NameFormatter.toColon(className);
+                }
+
+                if (id == null)
+                {
+                    id = NameFormatter.retrieveClassName(className);
+                }
+
+                String lookupOnlyStr = attributes.getValue("lookupOnly");
+                boolean lookupOnly = lookupOnlyStr == null ? false : Boolean.valueOf(lookupOnlyStr).booleanValue();
+
+                boolean added = mappings.addClass(namespaceURI, id, className);
+
+                if (! added)
+                {
+	                ThreadLocalToolkit.log(new DuplicateComponentDefinition(fileName, locator.getLineNumber(), id));
+                    return;
+                }
+
+                if (lookupOnly)
+                {
+                    mappings.addLookupOnly(namespaceURI, className);
+                }
+            }
+        }
+
+        public void warning(SAXParseException e)
+        {
+	        ThreadLocalToolkit.log(new ManifestError(fileName, e.getLineNumber(), e.getMessage()));
+        }
+
+        public void error(SAXParseException e)
+        {
+	        ThreadLocalToolkit.log(new ManifestError(fileName, e.getLineNumber(), e.getMessage()));
+        }
+
+        public void fatalError(SAXParseException e)
+                throws SAXParseException
+        {
+	        ThreadLocalToolkit.log(new ManifestError(fileName, e.getLineNumber(), e.getMessage()));
+            throw e;
+        }
+
+        public void setDocumentLocator(Locator locator)
+        {
+            this.locator = locator;
+        }
+    }
+
+	// error messages
+
+	public static class UndefinedClass extends CompilerMessage.CompilerError
+	{
+		private static final long serialVersionUID = 982393613817885400L;
+        public UndefinedClass(String fileName, int line, String tag)
+		{
+			super();
+			this.fileName = fileName;
+			this.line = line;
+			this.tag = tag;
+		}
+
+		public final String fileName;
+		public final int line;
+		public final String tag;
+	}
+
+	public static class InvalidClassName extends CompilerMessage.CompilerError
+	{
+		private static final long serialVersionUID = -1805088670961745449L;
+        public InvalidClassName(String fileName, int line, String tag)
+		{
+			super();
+			this.fileName = fileName;
+			this.line = line;
+			this.tag = tag;
+		}
+
+		public final String fileName;
+		public final int line;
+		public final String tag;
+	}
+
+	public static class DuplicateComponentDefinition extends CompilerMessage.CompilerError
+	{
+		private static final long serialVersionUID = -1072579721984054648L;
+        public DuplicateComponentDefinition(String fileName, int line, String tag)
+		{
+			super();
+			this.fileName = fileName;
+			this.line = line;
+			this.tag = tag;
+		}
+
+		public final String fileName;
+		public final int line;
+		public final String tag;
+	}
+
+	public static class ManifestError extends CompilerMessage.CompilerError
+	{
+		private static final long serialVersionUID = 7519143031979293680L;
+        public ManifestError(String fileName, int line, String message)
+		{
+			super();
+			this.fileName = fileName;
+			this.line = line;
+			this.message = message;
+		}
+
+		public final String fileName;
+		public final int line;
+		public final String message;
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6ddfb7b2/flex-compiler-oem/src/flex2/compiler/util/NameMappings.java
----------------------------------------------------------------------
diff --git a/flex-compiler-oem/src/flex2/compiler/util/NameMappings.java b/flex-compiler-oem/src/flex2/compiler/util/NameMappings.java
new file mode 100644
index 0000000..82669eb
--- /dev/null
+++ b/flex-compiler-oem/src/flex2/compiler/util/NameMappings.java
@@ -0,0 +1,183 @@
+/*
+ *
+ *  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 flex2.compiler.util;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * Stores the mappings of name and uri to classname.
+ *
+ */
+public class NameMappings
+{
+	public NameMappings()
+	{
+		namespaceMap = new HashMap<String, Map<String,String>>();
+        lookupOnly = new HashMap<String, Set<String>>();
+	}
+
+    private Map<String, Map<String,String>> namespaceMap;
+    private Map<String, Set<String>> lookupOnly;
+
+    public NameMappings copy()
+    {
+    	NameMappings m = new NameMappings();
+    	for (Iterator<String> i = namespaceMap.keySet().iterator(); i.hasNext(); )
+    	{
+    		String uri = i.next();
+    		Map<String, String> classMap = namespaceMap.get(uri);
+    		m.namespaceMap.put(uri, new HashMap<String,String>(classMap));
+    	}
+    	m.lookupOnly.putAll(lookupOnly);
+    	return m;
+    }
+    
+	public String lookupPackageName(String nsURI, String localPart)
+	{
+		String className = lookupClassName(nsURI, localPart);
+		if (className == null)
+		{
+			return null;
+		}
+		int index = className.indexOf(":");
+		return (index == -1) ? "" : className.substring(0, index);
+	}
+
+	public String lookupClassName(String nsURI, String localPart)
+	{
+        Map<String, String> classMap = namespaceMap.get(nsURI);
+        return classMap == null ? null : classMap.get(localPart);
+	}
+
+	/**
+	 * Look up namespace;classname against registered entries, then fault to package-style namespace handling
+	 * NOTE: the contract here is that a null return value definitely indicates a missing definition, but a non-null
+	 * return value *by no means* ensures that a definition will be available. E.g. an entry in a manifest doesn't mean
+	 * that the backing code is correct, defines the specified class or even exists. Also, for package-style namespaces
+	 * we simply concatenate the parameters together, since (e.g.) checking the presence or absence of a suitable entry
+	 * on the classpath gives a similarly non-definitive answer.
+	 */
+	public String resolveClassName(String namespaceURI, String localPart)
+	{
+		String className = lookupClassName(namespaceURI, localPart);
+
+		if (className == null)
+		{
+			// C: if namespaceURI is in the form of p1.p2...pn.*...
+            // HIGHLY recommend handling this as old compiler did.  --rg
+			if ("*".equals(namespaceURI))
+			{
+				className = localPart;
+			}
+			else if (namespaceURI.length() > 2 && namespaceURI.endsWith(".*"))
+			{
+				className = namespaceURI.substring(0, namespaceURI.length() - 2) + ':' + localPart;
+				className = className.intern();
+			}
+		}
+
+		return className;
+	}
+
+    public Map<String, String> getNamespace(String nsURI)
+    {
+        return namespaceMap.get(nsURI);
+    }
+
+    public Set<String> getNamespaces()
+    {
+        return namespaceMap.keySet();
+    }
+
+    public void addMappings( NameMappings other )
+    {
+        for (Iterator<Map.Entry<String, Map<String,String>>> nit = other.namespaceMap.entrySet().iterator(); nit.hasNext();)
+        {
+            Map.Entry<String, Map<String,String>> e = nit.next();
+            String namespaceURI = e.getKey();
+            Map<String, String> mappings = e.getValue();
+
+            for (Iterator<Map.Entry<String, String>> it = mappings.entrySet().iterator(); it.hasNext();)
+            {
+                Map.Entry<String, String> lc = it.next();
+                String local = lc.getKey();
+                String className = lc.getValue();
+
+                addClass( namespaceURI, local, className );
+            }
+        }
+    }
+
+    public boolean addClass(String namespaceURI, String localPart, String className)
+    {
+        Map<String, String> classMap = null;
+
+        if (namespaceMap.containsKey(namespaceURI))
+        {
+            classMap = namespaceMap.get(namespaceURI);
+        }
+        else
+        {
+            classMap = new HashMap<String, String>();
+            namespaceMap.put(namespaceURI.intern(), classMap);
+        }
+
+        String current = classMap.get(localPart);
+        if (current == null)
+        {
+            classMap.put(localPart.intern(), className.intern());
+        }
+        else if (! current.equals(className))
+        {
+            return false;
+        }
+        return true;
+    }
+
+    public void addLookupOnly(String namespaceURI, String cls)
+    {
+        Set classes = lookupOnly.get(namespaceURI);
+
+        if (classes == null)
+        {
+            classes = new HashSet<String>();
+            lookupOnly.put(namespaceURI, classes);
+    }
+
+        classes.add(cls);
+    }
+
+    public boolean isLookupOnly(String namespaceURI, String cls)
+    {
+        boolean result = false;
+        Set classes = lookupOnly.get(namespaceURI);
+
+        if (classes != null)
+        {
+            result = classes.contains(cls);
+    }
+
+        return result;
+}
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6ddfb7b2/flex-compiler-oem/src/flex2/compiler/util/ThreadLocalToolkit.java
----------------------------------------------------------------------
diff --git a/flex-compiler-oem/src/flex2/compiler/util/ThreadLocalToolkit.java b/flex-compiler-oem/src/flex2/compiler/util/ThreadLocalToolkit.java
index e50bb77..5a0a368 100644
--- a/flex-compiler-oem/src/flex2/compiler/util/ThreadLocalToolkit.java
+++ b/flex-compiler-oem/src/flex2/compiler/util/ThreadLocalToolkit.java
@@ -20,6 +20,7 @@
 package flex2.compiler.util;
 
 //import flash.localization.LocalizationManager;
+import flash.localization.LocalizationManager;
 import flex2.compiler.ILocalizableMessage;
 import flex2.compiler.Logger;
 import flex2.compiler.Source;
@@ -48,14 +49,13 @@ public final class ThreadLocalToolkit
     private static ThreadLocal<PathResolver> resolver = new ThreadLocal<PathResolver>();
     private static ThreadLocal<Map<String, VirtualFile>> resolved = new ThreadLocal<Map<String, VirtualFile>>();
     private static ThreadLocal<Benchmark> stopWatch = new ThreadLocal<Benchmark>();
-    //private static ThreadLocal<LocalizationManager> localization = new ThreadLocal<LocalizationManager>();
+    private static ThreadLocal<LocalizationManager> localization = new ThreadLocal<LocalizationManager>();
     private static ThreadLocal<MimeMappings> mimeMappings = new ThreadLocal<MimeMappings>();
     private static ThreadLocal<ProgressMeter> progressMeter = new ThreadLocal<ProgressMeter>();
     private static ThreadLocal<CompilerControl> compilerControl = new ThreadLocal<CompilerControl>();
     private static ThreadLocal<StandardDefs> standardDefs = new ThreadLocal<StandardDefs>();
     private static ThreadLocal<Integer> compatibilityVersion = new ThreadLocal<Integer>();
 
-    /*
     //----------------------
     // LocalizationManager
     //----------------------
@@ -69,8 +69,7 @@ public final class ThreadLocalToolkit
     {
         localization.set( mgr );
     }
-    */
-    
+
     //---------------
     // PathResolver
     //---------------

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6ddfb7b2/flex-compiler-oem/src/flex2/compiler/util/URLPathResolver.java
----------------------------------------------------------------------
diff --git a/flex-compiler-oem/src/flex2/compiler/util/URLPathResolver.java b/flex-compiler-oem/src/flex2/compiler/util/URLPathResolver.java
new file mode 100644
index 0000000..c952384
--- /dev/null
+++ b/flex-compiler-oem/src/flex2/compiler/util/URLPathResolver.java
@@ -0,0 +1,75 @@
+/*
+ *
+ *  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 flex2.compiler.util;
+
+import flash.util.Trace;
+import flex2.compiler.common.SinglePathResolver;
+import flex2.compiler.io.NetworkFile;
+import flex2.compiler.io.VirtualFile;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * A resolver with tries to resolve paths using the URL class.
+ */
+public class URLPathResolver implements SinglePathResolver
+{
+    private static final URLPathResolver singleton = new URLPathResolver();
+
+    private URLPathResolver()
+    {
+    }
+
+    public static final URLPathResolver getSingleton()
+    {
+        return singleton;
+    }
+
+    public VirtualFile resolve(String uri)
+    {
+        VirtualFile location = null;
+
+		try
+		{
+			URL url = new URL(uri);
+            if (url != null)
+            {
+                location = new NetworkFile(url);
+            }            
+		}
+		catch (SecurityException securityException)
+		{
+	    }
+	    catch (MalformedURLException malformedURLException)
+		{
+		}
+        catch (IOException ioException)
+        {
+        }
+
+        if ((location != null) && Trace.pathResolver)
+        {
+            Trace.trace("URLPathResolver.resolve: resolved " + uri + " to " + location.getName());
+        }
+
+        return location;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6ddfb7b2/flex-compiler-oem/src/flex2/tools/CompJSC.java
----------------------------------------------------------------------
diff --git a/flex-compiler-oem/src/flex2/tools/CompJSC.java b/flex-compiler-oem/src/flex2/tools/CompJSC.java
new file mode 100644
index 0000000..d291678
--- /dev/null
+++ b/flex-compiler-oem/src/flex2/tools/CompJSC.java
@@ -0,0 +1,15 @@
+package flex2.tools;
+
+import org.apache.flex.compiler.clients.COMPJSC;
+
+/**
+ * @author: Frederic Thomas
+ * Date: 25/05/2015
+ * Time: 14:05
+ */
+public class CompJSC extends MxmlJSC {
+
+    static {
+        COMPILER = COMPJSC.class;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6ddfb7b2/flex-compiler-oem/src/flex2/tools/Compc.java
----------------------------------------------------------------------
diff --git a/flex-compiler-oem/src/flex2/tools/Compc.java b/flex-compiler-oem/src/flex2/tools/Compc.java
new file mode 100644
index 0000000..a502217
--- /dev/null
+++ b/flex-compiler-oem/src/flex2/tools/Compc.java
@@ -0,0 +1,57 @@
+/*
+ *
+ *  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 flex2.tools;
+
+import org.apache.flex.compiler.clients.COMPC;
+
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * Entry-point for compc, the command-line tool for compiling components.
+ */
+public class Compc extends Tool {
+
+    public static final String FILE_SPECS = "include-classes";
+
+    static {
+        COMPILER = COMPC.class;
+        JS_COMPILER = CompJSC.class;
+    }
+
+    /**
+     * The entry-point for Mxmlc.
+     * Note that if you change anything in this method, make sure to check Compc, Shell, and
+     * the server's CompileFilter to see if the same change needs to be made there.  You
+     * should also inform the Zorn team of the change.
+     *
+     * @param args
+     */
+    public static void main(String[] args) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
+        System.exit(compcNoExit(args));
+    }
+
+    public static int compcNoExit(String[] args) throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
+        return compile(args);
+    }
+
+    public static void compc(String[] args) throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
+        compile(args);
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6ddfb7b2/flex-compiler-oem/src/flex2/tools/MxmlJSC.java
----------------------------------------------------------------------
diff --git a/flex-compiler-oem/src/flex2/tools/MxmlJSC.java b/flex-compiler-oem/src/flex2/tools/MxmlJSC.java
new file mode 100644
index 0000000..f23dc2a
--- /dev/null
+++ b/flex-compiler-oem/src/flex2/tools/MxmlJSC.java
@@ -0,0 +1,76 @@
+package flex2.tools;
+
+import org.apache.flex.compiler.clients.problems.ProblemQueryProvider;
+import org.apache.flex.compiler.clients.JSCompilerEntryPoint;
+import org.apache.flex.compiler.clients.MXMLJSC;
+import org.apache.flex.compiler.clients.problems.ProblemQuery;
+import org.apache.flex.compiler.driver.IBackend;
+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.mxml.flexjs.MXMLFlexJSBackend;
+import org.apache.flex.compiler.internal.driver.mxml.vf2js.MXMLVF2JSBackend;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author: Frederic Thomas
+ * Date: 25/05/2015
+ * Time: 14:05
+ */
+public class MxmlJSC implements ProblemQueryProvider {
+
+    protected static Class<? extends MXMLJSC> COMPILER = MXMLJSC.class;
+
+    protected JSCompilerEntryPoint compiler;
+
+    protected JSCompilerEntryPoint getCompilerInstance(IBackend backend) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
+        if (compiler == null) {
+            compiler = COMPILER.getDeclaredConstructor(IBackend.class).newInstance(backend);
+        }
+        return compiler;
+    }
+
+    public int execute(String[] args) throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
+        IBackend backend = new ASBackend();
+        String jsOutputTypeString = "";
+        for (String s : args) {
+            String[] kvp = s.split("=");
+
+            if (s.contains("-js-output-type")) {
+                jsOutputTypeString = kvp[1];
+            }
+        }
+
+        if (jsOutputTypeString.equals("")) {
+            jsOutputTypeString = MXMLJSC.JSOutputType.FLEXJS.getText();
+        }
+
+        MXMLJSC.JSOutputType jsOutputType = MXMLJSC.JSOutputType.fromString(jsOutputTypeString);
+        switch (jsOutputType) {
+            case AMD:
+                backend = new AMDBackend();
+                break;
+            case FLEXJS:
+                backend = new MXMLFlexJSBackend();
+                break;
+            case GOOG:
+                backend = new GoogBackend();
+                break;
+            case VF2JS:
+                backend = new MXMLVF2JSBackend();
+                break;
+        }
+
+        final Set<ICompilerProblem> problems = new HashSet<ICompilerProblem>();
+        return getCompilerInstance(backend).mainNoExit(args, problems, false);
+    }
+
+    @Override
+    public ProblemQuery getProblemQuery() {
+        return ((ProblemQueryProvider) compiler).getProblemQuery();
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6ddfb7b2/flex-compiler-oem/src/flex2/tools/Mxmlc.java
----------------------------------------------------------------------
diff --git a/flex-compiler-oem/src/flex2/tools/Mxmlc.java b/flex-compiler-oem/src/flex2/tools/Mxmlc.java
new file mode 100644
index 0000000..abed94f
--- /dev/null
+++ b/flex-compiler-oem/src/flex2/tools/Mxmlc.java
@@ -0,0 +1,325 @@
+/*
+ *
+ *  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 flex2.tools;
+
+import flash.localization.LocalizationManager;
+import flex2.compiler.common.Configuration;
+import flex2.compiler.common.ConfigurationPathResolver;
+import flex2.compiler.common.PathResolver;
+import flex2.compiler.config.*;
+import flex2.compiler.io.VirtualFile;
+import flex2.compiler.util.CompilerMessage;
+import flex2.compiler.util.ThreadLocalToolkit;
+import org.apache.flex.compiler.clients.MXMLC;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.util.*;
+import java.util.Map.Entry;
+
+/**
+ * A command line tool for compiling Flex applications.  Despite the
+ * name, in addition to .mxml files, this tool can be used to compile
+ * other file formats, like .as and .css.
+ */
+public final class Mxmlc extends Tool {
+    static private String l10nConfigPrefix = "flex2.configuration";
+
+    public static final String FILE_SPECS = "file-specs";
+
+    static {
+        COMPILER = MXMLC.class;
+        JS_COMPILER = MxmlJSC.class;
+    }
+
+    /**
+     * The entry-point for Mxmlc.
+     * Note that if you change anything in this method, make sure to check Compc, Shell, and
+     * the server's CompileFilter to see if the same change needs to be made there.  You
+     * should also inform the Zorn team of the change.
+     *
+     * @param args
+     */
+    public static void main(String[] args) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
+        System.exit(mxmlcNoExit(args));
+    }
+
+    public static int mxmlcNoExit(String[] args) throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
+        return compile(args);
+    }
+
+    public static void mxmlc(String[] args) throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
+        compile(args);
+    }
+
+    public static Configuration processConfiguration(LocalizationManager lmgr, String program, String[] args,
+                                                     ConfigurationBuffer cfgbuf, Class<? extends Configuration> cls, String defaultVar)
+            throws ConfigurationException, IOException {
+        return processConfiguration(lmgr, program, args, cfgbuf, cls, defaultVar, true);
+    }
+
+    public static Configuration processConfiguration(LocalizationManager lmgr, String program, String[] args,
+                                                     ConfigurationBuffer cfgbuf, Class<? extends Configuration> cls, String defaultVar,
+                                                     boolean ignoreUnknownItems)
+            throws IOException {
+        ToolsConfiguration toolsConfiguration = null;
+        try {
+            SystemPropertyConfigurator.load(cfgbuf, "flex");
+
+            // Parse the command line a first time, to peak at stuff like
+            // "flexlib" and "load-config".  The first parse is thrown
+            // away after that and we intentionally parse a second time
+            // below.  See note below.
+            CommandLineConfigurator.parse(cfgbuf, defaultVar, args);
+
+            String flexlib = cfgbuf.getToken("flexlib");
+            if (flexlib == null) {
+                String appHome = System.getProperty("application.home");
+
+                if (appHome == null) {
+                    appHome = ".";
+                } else {
+                    appHome += File.separator + "frameworks";       // FIXME - need to eliminate this from the compiler
+                }
+                cfgbuf.setToken("flexlib", appHome);
+            }
+
+            // Framework Type
+            // halo, gumbo, interop...
+            String framework = cfgbuf.getToken("framework");
+            if (framework == null) {
+                cfgbuf.setToken("framework", "halo");
+            }
+
+            String configname = cfgbuf.getToken("configname");
+            if (configname == null) {
+                cfgbuf.setToken("configname", "flex");
+            }
+
+            String buildNumber = cfgbuf.getToken("build.number");
+            if (buildNumber == null) {
+                if ("".equals(VersionInfo.getBuild())) {
+                    buildNumber = "workspace";
+                } else {
+                    buildNumber = VersionInfo.getBuild();
+                }
+                cfgbuf.setToken("build.number", buildNumber);
+            }
+
+
+            // We need to intercept "help" options because we want to try to correctly
+            // interpret them even when the rest of the configuration is totally screwed up.
+
+            if (cfgbuf.getVar("version") != null) {
+                System.out.println(VersionInfo.buildMessage());
+                System.exit(0);
+            }
+
+            processHelp(cfgbuf, program, defaultVar, lmgr, args);
+
+            // at this point, we should have enough to know both
+            // flexlib and the config file.
+
+            ConfigurationPathResolver configResolver = new ConfigurationPathResolver();
+
+            List<ConfigurationValue> configs = cfgbuf.peekConfigurationVar("load-config");
+
+            if (configs != null) {
+                for (ConfigurationValue cv : configs) {
+                    for (String path : cv.getArgs()) {
+                        VirtualFile configFile = ConfigurationPathResolver.getVirtualFile(path, configResolver, cv);
+                        cfgbuf.calculateChecksum(configFile);
+                        InputStream in = configFile.getInputStream();
+                        if (in != null) {
+                            FileConfigurator.load(cfgbuf, new BufferedInputStream(in), configFile.getName(),
+                                    configFile.getParent(), "flex-config", ignoreUnknownItems);
+                        } else {
+                            throw new ConfigurationException.ConfigurationIOError(path, cv.getVar(), cv.getSource(), cv.getLine());
+                        }
+                    }
+                }
+            }
+
+            PathResolver resolver = ThreadLocalToolkit.getPathResolver();
+            // Load project file, if any...
+            List fileValues = cfgbuf.getVar(FILE_SPECS);
+            if ((fileValues != null) && (fileValues.size() > 0)) {
+                ConfigurationValue cv = (ConfigurationValue) fileValues.get(fileValues.size() - 1);
+                if (cv.getArgs().size() > 0) {
+                    String val = cv.getArgs().get(cv.getArgs().size() - 1);
+                    int index = val.lastIndexOf('.');
+                    if (index != -1) {
+                        String project = val.substring(0, index) + "-config.xml";
+                        VirtualFile projectFile = resolver.resolve(configResolver, project);
+                        if (projectFile != null) {
+                            cfgbuf.calculateChecksum(projectFile);
+                            InputStream in = projectFile.getInputStream();
+                            if (in != null) {
+                                FileConfigurator.load(cfgbuf, new BufferedInputStream(in),
+                                        projectFile.getName(), projectFile.getParent(), "flex-config",
+                                        ignoreUnknownItems);
+                            }
+                        }
+                    }
+                }
+            }
+
+            // The command line needs to take precedence over all defaults and config files.
+            // This is a bit gross, but by simply re-merging the command line back on top,
+            // we will get the behavior we want.
+            cfgbuf.clearSourceVars(CommandLineConfigurator.source);
+            CommandLineConfigurator.parse(cfgbuf, defaultVar, args);
+
+            toolsConfiguration = null;
+            try {
+                toolsConfiguration = (ToolsConfiguration) cls.newInstance();
+                toolsConfiguration.setConfigPathResolver(configResolver);
+            } catch (Exception e) {
+                LocalizationManager l10n = ThreadLocalToolkit.getLocalizationManager();
+                throw new ConfigurationException(l10n.getLocalizedTextString(new CouldNotInstantiate(toolsConfiguration)));
+            }
+            cfgbuf.commit(toolsConfiguration);
+
+            // enterprise service config file has other config file dependencies. add them here...
+            calculateServicesChecksum(toolsConfiguration, cfgbuf);
+
+            toolsConfiguration.validate(cfgbuf);
+
+            // consolidate license keys...
+            VirtualFile licenseFile = toolsConfiguration.getLicenseFile();
+            if (licenseFile != null) {
+                Map<String, String> fileLicenses = Tool.getLicenseMapFromFile(licenseFile.getName());
+                Map<String, String> cmdLicenses = toolsConfiguration.getLicensesConfiguration().getLicenseMap();
+                if (cmdLicenses == null) {
+                    toolsConfiguration.getLicensesConfiguration().setLicenseMap(fileLicenses);
+                } else if (fileLicenses != null) {
+                    fileLicenses.putAll(cmdLicenses);
+                    toolsConfiguration.getLicensesConfiguration().setLicenseMap(fileLicenses);
+                }
+            }
+        } catch (ConfigurationException e) {
+            e.printStackTrace();
+        }
+
+        return toolsConfiguration;
+    }
+
+    static void processHelp(ConfigurationBuffer cfgbuf, String program, String defaultVar, LocalizationManager lmgr, String[] args) {
+        if (cfgbuf.getVar("help") != null) {
+            Set<String> keywords = new HashSet<String>();
+            List vals = cfgbuf.getVar("help");
+            for (Iterator it = vals.iterator(); it.hasNext(); ) {
+                ConfigurationValue val = (ConfigurationValue) it.next();
+                for (Object element : val.getArgs()) {
+                    String keyword = (String) element;
+                    while (keyword.startsWith("-"))
+                        keyword = keyword.substring(1);
+                    keywords.add(keyword);
+                }
+            }
+            if (keywords.size() == 0) {
+                keywords.add("help");
+            }
+
+            ThreadLocalToolkit.logInfo(getStartMessage(program));
+            System.out.println();
+            System.out.println(CommandLineConfigurator.usage(program, defaultVar, cfgbuf, keywords, lmgr, l10nConfigPrefix));
+            System.exit(0);
+        }
+
+        if (args.length == 0 && ("mxmlc".equals(program) || "compc".equals(program))) {
+            ThreadLocalToolkit.logInfo(getStartMessage(program));
+            System.err.println(CommandLineConfigurator.brief(program, defaultVar, lmgr, l10nConfigPrefix));
+            System.exit(1);
+        }
+    }
+
+    private static void calculateServicesChecksum(Configuration config, ConfigurationBuffer cfgbuf) {
+        Map<String, Long> services = null;
+        if (config.getCompilerConfiguration().getServicesDependencies() != null) {
+            services = config.getCompilerConfiguration().getServicesDependencies().getConfigPaths();
+        }
+
+        if (services != null) {
+            for (Entry<String, Long> entry : services.entrySet()) {
+                cfgbuf.calculateChecksum(entry.getKey(), entry.getValue());
+            }
+        }
+    }
+
+    public static void processConfigurationException(ConfigurationException ex, String program) {
+        ThreadLocalToolkit.log(ex);
+
+        if (ex.source == null || ex.source.equals("command line")) {
+            Map<String, String> p = new HashMap<String, String>();
+            p.put("program", program);
+            String help = ThreadLocalToolkit.getLocalizationManager().getLocalizedTextString("flex2.compiler.CommandLineHelp", p);
+            if (help != null) {
+                // "Use '" + program + " -help' for information about using the command line.");
+                System.err.println(help);
+            }
+        }
+    }
+
+    private static String getStartMessage(String program) {
+        LocalizationManager l10n = ThreadLocalToolkit.getLocalizationManager();
+
+        return l10n.getLocalizedTextString(new StartMessage(program, VersionInfo.buildMessage()));
+    }
+
+    public static class CouldNotInstantiate extends CompilerMessage.CompilerInfo {
+        private static final long serialVersionUID = -8970190710117830662L;
+
+        public CouldNotInstantiate(Configuration config) {
+            super();
+            this.config = config;
+        }
+
+        public final Configuration config;
+    }
+
+    public static class StartMessage extends CompilerMessage.CompilerInfo {
+        private static final long serialVersionUID = 4807822711658875257L;
+
+        public StartMessage(String program, String buildMessage) {
+            super();
+            this.program = program;
+            this.buildMessage = buildMessage;
+        }
+
+        public final String program, buildMessage;
+    }
+
+    public static class OutputMessage extends CompilerMessage.CompilerInfo {
+        private static final long serialVersionUID = -4859993585489031839L;
+
+        public String name;
+        public String length;
+
+        public OutputMessage(String name, String length) {
+            this.name = name;
+            this.length = length;
+        }
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6ddfb7b2/flex-compiler-oem/src/flex2/tools/Tool.java
----------------------------------------------------------------------
diff --git a/flex-compiler-oem/src/flex2/tools/Tool.java b/flex-compiler-oem/src/flex2/tools/Tool.java
new file mode 100644
index 0000000..b61fa43
--- /dev/null
+++ b/flex-compiler-oem/src/flex2/tools/Tool.java
@@ -0,0 +1,242 @@
+/*
+ *
+ *  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 flex2.tools;
+
+import flash.localization.LocalizationManager;
+import flex2.compiler.Logger;
+import flex2.compiler.config.ConfigurationException;
+import flex2.compiler.util.CompilerMessage;
+import flex2.compiler.util.CompilerMessage.CompilerError;
+import flex2.compiler.util.ThreadLocalToolkit;
+import flex2.tools.oem.Message;
+import org.apache.flex.compiler.clients.problems.ProblemQueryProvider;
+import org.apache.flex.compiler.clients.MXMLC;
+import org.apache.flex.compiler.clients.problems.ProblemQuery;
+import org.apache.flex.compiler.problems.CompilerProblemSeverity;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.problems.annotations.DefaultSeverity;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Common base class for most flex tools.
+ */
+public class Tool
+{
+    protected static Class<? extends MXMLC> COMPILER;
+    protected static Class<? extends MxmlJSC> JS_COMPILER;
+
+    protected static int compile(String[] args) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
+        int exitCode;
+
+        if (hasJsOutputType(args)) {
+            MxmlJSC mxmlJSC = JS_COMPILER.newInstance();
+            exitCode = mxmlJSC.execute(args);
+            processProblemReport(mxmlJSC);
+        } else {
+            MXMLC mxmlc = COMPILER.newInstance();
+            exitCode = mxmlc.execute(args);
+            processProblemReport(new CompilerRequestableProblems(mxmlc));
+        }
+
+        return exitCode;
+    }
+
+    protected static boolean hasJsOutputType(String[] args) {
+        boolean found = false;
+
+        for (String s : args) {
+            String[] kvp = s.split("=");
+
+            if (s.contains("-js-output-type")) {
+                found = true;
+                break;
+            }
+        }
+
+        return found;
+    }
+
+    public static Map<String, String> getLicenseMapFromFile(String fileName) throws ConfigurationException
+    {
+        Map<String, String> result = null;
+        FileInputStream in = null;
+
+        try
+        {
+            in = new FileInputStream(fileName);
+            Properties properties = new Properties();
+            properties.load(in);
+            Enumeration enumeration = properties.propertyNames();
+
+            if ( enumeration.hasMoreElements() )
+            {
+                result = new HashMap<String, String>();
+
+                while ( enumeration.hasMoreElements() )
+                {
+                    String propertyName = (String) enumeration.nextElement();
+                    result.put(propertyName, properties.getProperty(propertyName));
+                }
+            }
+        }
+        catch (IOException ioException)
+        {
+        	LocalizationManager l10n = ThreadLocalToolkit.getLocalizationManager();
+            throw new ConfigurationException(l10n.getLocalizedTextString(new FailedToLoadLicenseFile(fileName)));
+        }
+        finally
+        {
+            if (in != null)
+            {
+                try
+                {
+                    in.close();
+                }
+                catch (IOException ioe)
+                {
+                }
+            }
+        }
+
+        return result;
+    }
+
+	public static class FailedToLoadLicenseFile extends CompilerError
+	{
+		private static final long serialVersionUID = -2980033917773108328L;
+        
+        public String fileName;
+
+		public FailedToLoadLicenseFile(String fileName)
+		{
+			super();
+			this.fileName = fileName;
+		}
+	}
+
+    public static void processProblemReport(ProblemQueryProvider requestableProblems)
+    {
+        for (ICompilerProblem problem : requestableProblems.getProblemQuery().getProblems())
+        {
+            Class aClass = problem.getClass();
+            Annotation[] annotations = aClass.getAnnotations();
+
+            for(Annotation annotation : annotations){
+                if(annotation instanceof DefaultSeverity){
+                    DefaultSeverity myAnnotation = (DefaultSeverity) annotation;
+                    CompilerProblemSeverity cps = myAnnotation.value();
+                    String level;
+                    if (cps.equals(CompilerProblemSeverity.ERROR))
+                        level = Message.ERROR;
+                    else if (cps.equals(CompilerProblemSeverity.WARNING))
+                        level = Message.WARNING;
+                    else
+                        break; // skip if IGNORE?
+                    CompilerMessage msg = new CompilerMessage(level,
+                            problem.getSourcePath(),
+                            problem.getLine() + 1,
+                            problem.getColumn());
+                    try
+                    {
+                        String errText = (String) aClass.getField("DESCRIPTION").get(aClass);
+                        while (errText.contains("${"))
+                        {
+                            int start = errText.indexOf("${");
+                            int end = errText.indexOf("}", start);
+                            String token = errText.substring(start + 2, end);
+                            String value = (String) aClass.getField(token).get(problem);
+                            token = "${" + token + "}";
+                            errText = errText.replace(token, value);
+                        }
+
+                        msg.setMessage(errText);
+                        logMessage(msg);
+                    }
+                    catch (IllegalArgumentException e)
+                    {
+                        // TODO Auto-generated catch block
+                        e.printStackTrace();
+                    }
+                    catch (SecurityException e)
+                    {
+                        // TODO Auto-generated catch block
+                        e.printStackTrace();
+                    }
+                    catch (IllegalAccessException e)
+                    {
+                        // TODO Auto-generated catch block
+                        e.printStackTrace();
+                    }
+                    catch (NoSuchFieldException e)
+                    {
+                        // TODO Auto-generated catch block
+                        e.printStackTrace();
+                    }
+                }
+            }
+
+        }
+    }
+
+    private static void logMessage(CompilerMessage msg) {
+
+        final Logger logger = ThreadLocalToolkit.getLogger();
+
+        if (logger != null) {
+            if (msg.getLevel().equals(Message.INFO)) {
+                logger.logInfo(msg.getPath(), msg.getLine(), msg.getColumn(), msg.getMessage());
+            } else if (msg.getLevel().equals(Message.WARNING)) {
+                logger.logWarning(msg.getPath(), msg.getLine(), msg.getColumn(), msg.getMessage());
+            } else if (msg.getLevel().equals(Message.ERROR)) {
+                logger.logError(msg.getPath(), msg.getLine(), msg.getColumn(), msg.getMessage());
+            }
+        }
+    }
+
+    public static class NoUpdateMessage extends CompilerMessage.CompilerInfo {
+        private static final long serialVersionUID = 6943388392279226490L;
+        public String name;
+
+        public NoUpdateMessage(String name) {
+            this.name = name;
+        }
+    }
+
+    static class CompilerRequestableProblems implements ProblemQueryProvider {
+        private MXMLC mxmlc;
+
+        public CompilerRequestableProblems(MXMLC mxmlc) {
+            this.mxmlc = mxmlc;
+        }
+
+        @Override
+        public ProblemQuery getProblemQuery() {
+            return mxmlc.getProblems();
+        }
+    }
+}


Mime
View raw message