You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cd...@apache.org on 2014/11/23 12:38:00 UTC
git commit: [flex-falcon] [refs/heads/feature/flex-tool-api] - -
Adjusted the build to use the released version of the flex-tool-api - Had to
disable support for VF2JS as both compilers use the same base classes and
overwrite each others static state var
Repository: flex-falcon
Updated Branches:
refs/heads/feature/flex-tool-api 8dec67448 -> e92a0e9c1
- Adjusted the build to use the released version of the flex-tool-api
- Had to disable support for VF2JS as both compilers use the same base classes and overwrite each others static state variables.
- Added code to dump the content of a jar to a given directory (Needed in order to dump closure-library artifact)
- Made MXMLFlexJSPublisher and MXMLVF2JSPublisher dump the content of the closure-library if the library-path is not set and closure resources are available on the classpath.
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/e92a0e9c
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/e92a0e9c
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/e92a0e9c
Branch: refs/heads/feature/flex-tool-api
Commit: e92a0e9c11fea71ff3d96395b80a9fe8a0aa37bd
Parents: 8dec674
Author: Christofer Dutz <ch...@codecentric.de>
Authored: Sun Nov 23 12:37:51 2014 +0100
Committer: Christofer Dutz <ch...@codecentric.de>
Committed: Sun Nov 23 12:37:51 2014 +0100
----------------------------------------------------------------------
compiler.jx/downloads.xml | 26 ++--
.../apache/flex/compiler/clients/COMPJSC.java | 2 +-
.../flex/compiler/clients/FlexJSToolGroup.java | 2 +-
.../apache/flex/compiler/clients/MXMLJSC.java | 103 +++++----------
.../flex/compiler/clients/VF2JSToolGroup.java | 6 +-
.../codegen/js/goog/JSGoogPublisher.java | 36 +++++-
.../mxml/flexjs/MXMLFlexJSPublisher.java | 125 +++++++++++++++----
.../codegen/mxml/vf2js/MXMLVF2JSPublisher.java | 83 ++++++++----
.../driver/js/goog/JSGoogConfiguration.java | 6 +-
.../compiler/internal/graph/GoogDepsWriter.java | 58 ++++-----
compiler/downloads.xml | 24 ++--
.../org/apache/flex/compiler/clients/COMPC.java | 2 +-
.../org/apache/flex/compiler/clients/MXMLC.java | 2 +-
.../apache/flex/compiler/clients/Optimizer.java | 2 +-
maven/falcon-jx-compiler.pom | 5 +
15 files changed, 293 insertions(+), 189 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e92a0e9c/compiler.jx/downloads.xml
----------------------------------------------------------------------
diff --git a/compiler.jx/downloads.xml b/compiler.jx/downloads.xml
index dd64945..a14de7a 100644
--- a/compiler.jx/downloads.xml
+++ b/compiler.jx/downloads.xml
@@ -151,19 +151,19 @@
<param name="dest.filename" value="${org.json.name}.jar"/>
</antcall>
- <!-- flex-tool-api -->
- <property name="flexToolApi.name" value="flex-tool-api"/>
- <property name="flexToolApi.version" value="1.0.0-SNAPSHOT"/>
- <antcall target="download-dependency">
- <param name="name" value="${flexToolApi.name}"/>
- <param name="src.server" value="http://repository.apache.org/content/groups/snapshots"/>
- <param name="src.folder" value="org/apache/flex/flex-tool-api/${flexToolApi.version}"/>
- <param name="src.filename" value="flex-tool-api-1.0.0-20141105.140704-1.jar"/>
- <param name="src.checksum" value="b37c99011d06e1ff794d8ee9153ab2c4"/>
- <param name="dest.folder" value=""/>
- <param name="dest.filename" value="${flexToolApi.name}.jar"/>
- <param name="license.use.apache" value="true"/>
- </antcall>
+ <!-- flex-tool-api -->
+ <property name="flexToolApi.name" value="flex-tool-api"/>
+ <property name="flexToolApi.version" value="1.0.0"/>
+ <antcall target="download-dependency">
+ <param name="name" value="${flexToolApi.name}"/>
+ <param name="src.server" value="${maven.search.url}"/>
+ <param name="src.folder" value="org/apache/flex/${flexToolApi.name}/${flexToolApi.version}"/>
+ <param name="src.filename" value="${flexToolApi.name}-${flexToolApi.version}.jar"/>
+ <param name="src.checksum" value="b8f76174b2c4d3b83e5c9fa78703c52b"/>
+ <param name="dest.folder" value=""/>
+ <param name="dest.filename" value="${flexToolApi.name}.jar"/>
+ <param name="license.use.apache" value="true"/>
+ </antcall>
</target>
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e92a0e9c/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 068b2f3..5a953f8 100644
--- a/compiler.jx/src/org/apache/flex/compiler/clients/COMPJSC.java
+++ b/compiler.jx/src/org/apache/flex/compiler/clients/COMPJSC.java
@@ -84,7 +84,7 @@ public class COMPJSC extends MXMLJSC implements FlexTool
@Override
public String getName() {
- return "COMPC";
+ return FLEX_TOOL_COMPC;
}
@Override
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e92a0e9c/compiler.jx/src/org/apache/flex/compiler/clients/FlexJSToolGroup.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/clients/FlexJSToolGroup.java b/compiler.jx/src/org/apache/flex/compiler/clients/FlexJSToolGroup.java
index 1f10aa7..f7c48be 100644
--- a/compiler.jx/src/org/apache/flex/compiler/clients/FlexJSToolGroup.java
+++ b/compiler.jx/src/org/apache/flex/compiler/clients/FlexJSToolGroup.java
@@ -30,7 +30,7 @@ public class FlexJSToolGroup extends AbstractFlexToolGroup {
public FlexJSToolGroup() {
super("FlexJS");
addFlexTool(new COMPJSC(new MXMLFlexJSBackend()));
- addFlexTool(new COMPJSC(new MXMLFlexJSBackend()));
+ addFlexTool(new MXMLJSC(new MXMLFlexJSBackend()));
}
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e92a0e9c/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 2716aea..c968086 100644
--- a/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
+++ b/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
@@ -146,7 +146,7 @@ public class MXMLJSC implements FlexTool
@Override
public String getName() {
- return "MXMLC";
+ return FLEX_TOOL_MXMLC;
}
@Override
@@ -288,29 +288,29 @@ public class MXMLJSC implements FlexTool
{
String[] adjustedArgs = args;
- switch (jsOutputType)
- {
- case VF2JS:
- boolean isFlashBuilderProject = useFlashBuilderProjectFiles(args);
+ if(jsOutputType != null) {
+ switch (jsOutputType) {
+ case VF2JS:
+ boolean isFlashBuilderProject = useFlashBuilderProjectFiles(args);
- if (isFlashBuilderProject)
- {
- adjustedArgs = FlashBuilderConfigurator
- .computeFlashBuilderArgs(adjustedArgs,
- getTargetType().getExtension());
- }
+ if (isFlashBuilderProject) {
+ adjustedArgs = FlashBuilderConfigurator
+ .computeFlashBuilderArgs(adjustedArgs,
+ getTargetType().getExtension());
+ }
+
+ //String projectFilePath = adjustedArgs[adjustedArgs.length - 1];
+ //
+ //String newProjectFilePath = VF2JSProjectUtils
+ // .createTempProject(projectFilePath,
+ // isFlashBuilderProject);
+ //
+ //adjustedArgs[adjustedArgs.length - 1] = newProjectFilePath;
- //String projectFilePath = adjustedArgs[adjustedArgs.length - 1];
- //
- //String newProjectFilePath = VF2JSProjectUtils
- // .createTempProject(projectFilePath,
- // isFlashBuilderProject);
- //
- //adjustedArgs[adjustedArgs.length - 1] = newProjectFilePath;
-
- break;
- default:
- break;
+ break;
+ default:
+ break;
+ }
}
final boolean continueCompilation = configure(adjustedArgs);
@@ -401,32 +401,17 @@ public class MXMLJSC implements FlexTool
return false;
}
- switch (jsOutputType)
- {
- case FLEXJS: {
+ if(JSSharedData.backend instanceof MXMLFlexJSBackend) {
jsPublisher = new MXMLFlexJSPublisher(config, project);
-
- break;
- }
-
- case GOOG: {
- jsPublisher = new JSGoogPublisher(config);
-
- break;
}
-
- case VF2JS: {
+ else if(JSSharedData.backend instanceof MXMLVF2JSBackend) {
jsPublisher = new MXMLVF2JSPublisher(config, project);
-
- break;
}
-
- case AMD:
- default: {
- jsPublisher = new JSPublisher(config);
-
- break;
+ else if(JSSharedData.backend instanceof GoogBackend) {
+ jsPublisher = new JSGoogPublisher(config);
}
+ else {
+ jsPublisher = new JSPublisher(config);
}
File outputFolder = jsPublisher.getOutputFolder();
@@ -473,37 +458,11 @@ public class MXMLJSC implements FlexTool
}
}
- switch (jsOutputType)
- {
- case AMD: {
- //
-
- break;
- }
-
- case FLEXJS: {
- //
-
- break;
- }
-
- case GOOG: {
- //
-
- break;
- }
-
- case VF2JS: {
- //
-
- break;
- }
- }
-
- if (jsPublisher != null)
+ if (jsPublisher != null) {
compilationSuccess = jsPublisher.publish(problems);
- else
+ } else {
compilationSuccess = true;
+ }
}
}
catch (Exception e)
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e92a0e9c/compiler.jx/src/org/apache/flex/compiler/clients/VF2JSToolGroup.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/clients/VF2JSToolGroup.java b/compiler.jx/src/org/apache/flex/compiler/clients/VF2JSToolGroup.java
index 12500da..3c72962 100644
--- a/compiler.jx/src/org/apache/flex/compiler/clients/VF2JSToolGroup.java
+++ b/compiler.jx/src/org/apache/flex/compiler/clients/VF2JSToolGroup.java
@@ -19,7 +19,7 @@
package org.apache.flex.compiler.clients;
-import org.apache.flex.compiler.internal.driver.js.vf2js.VF2JSBackend;
+import org.apache.flex.compiler.internal.driver.mxml.vf2js.MXMLVF2JSBackend;
import org.apache.flex.tools.AbstractFlexToolGroup;
/**
@@ -29,8 +29,8 @@ public class VF2JSToolGroup extends AbstractFlexToolGroup {
public VF2JSToolGroup() {
super("VF2JS");
- addFlexTool(new COMPJSC(new VF2JSBackend()));
- addFlexTool(new COMPJSC(new VF2JSBackend()));
+// addFlexTool(new COMPJSC(new MXMLVF2JSBackend()));
+// addFlexTool(new MXMLJSC(new MXMLVF2JSBackend()));
}
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e92a0e9c/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogPublisher.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogPublisher.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogPublisher.java
index 24e2f01..a37974e 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogPublisher.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogPublisher.java
@@ -18,12 +18,13 @@
*/
package org.apache.flex.compiler.internal.codegen.js.goog;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
+import java.io.*;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Enumeration;
import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.filefilter.DirectoryFileFilter;
@@ -264,6 +265,35 @@ public class JSGoogPublisher extends JSPublisher implements IJSPublisher
fw.close();
}
+
+ protected void dumpJar(File jarFile, File outputDir) throws IOException {
+ JarFile jar = new JarFile(jarFile);
+
+ for (Enumeration<JarEntry> jarEntries = jar.entries(); jarEntries.hasMoreElements();) {
+ JarEntry jarEntry = jarEntries.nextElement();
+ if (!jarEntry.getName().endsWith("/")) {
+ File file = new File(outputDir, jarEntry.getName());
+
+ // Check if the parent directory exists. If not -> create it.
+ File dir = file.getParentFile();
+ if(!dir.exists()) {
+ if (!dir.mkdirs()) {
+ throw new IOException("Unable to create directory " + dir.getAbsolutePath());
+ }
+ }
+
+ // Dump the file.
+ InputStream is = jar.getInputStream(jarEntry);
+ FileOutputStream fos = new FileOutputStream(file);
+ while (is.available() > 0) {
+ fos.write(is.read());
+ }
+ fos.close();
+ is.close();
+ }
+ }
+ }
+
public class JSGoogErrorManager implements ErrorManager
{
@Override
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e92a0e9c/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
index dff5d23..9378b3d 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
@@ -23,6 +23,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -77,8 +78,7 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
this.isMarmotinniRun = ((JSGoogConfiguration) configuration)
.getMarmotinni() != null;
- this.outputPathParameter = ((JSGoogConfiguration) configuration)
- .getOutput();
+ this.outputPathParameter = configuration.getOutput();
this.useStrictPublishing = ((JSGoogConfiguration) configuration)
.getStrictPublish();
@@ -133,7 +133,7 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
@Override
public boolean publish(ProblemQuery problems) throws IOException
{
- boolean ok = true;
+ boolean ok;
boolean subsetGoog = true;
final String intermediateDirPath = outputFolder.getPath();
@@ -151,14 +151,94 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
if (!isMarmotinniRun)
{
- if (releaseDir.exists())
+ if (releaseDir.exists()) {
org.apache.commons.io.FileUtils.deleteQuietly(releaseDir);
+ }
+
+ if(!releaseDir.mkdirs()) {
+ throw new IOException(
+ "Unable to create release directory at " + releaseDir.getAbsolutePath());
+ }
+ }
+
+ // If the closure-lib parameter is empty we'll try to find the resources
+ // in the classpath, dump its content to the output directory and use this
+ // as closure-lib parameter.
+ final String closureLibDirPath;
+ if(((JSGoogConfiguration) configuration).isClosureLibSet()) {
+ closureLibDirPath = ((JSGoogConfiguration) configuration).getClosureLib();
+ } else {
+ // Check if the "goog/deps.js" is available in the classpath.
+ URL resource = Thread.currentThread().getContextClassLoader().getResource("goog/deps.js");
+ if(resource != null) {
+ File closureLibDir = new File(intermediateDir.getParent(), "closure");
+
+ // Only create and dump the content, if the directory does not exists.
+ if(!closureLibDir.exists()) {
+ if(!closureLibDir.mkdirs()) {
+ throw new IOException(
+ "Unable to create directory for closure-lib at " + closureLibDir.getAbsolutePath());
+ }
+
+ // Strip the url of the parts we don't need.
+ // Unless we are not using some insanely complex setup
+ // the resource will always be on the same machine.
+ String resourceJarPath = resource.getFile();
+ if(resourceJarPath.contains(":")) {
+ resourceJarPath = resourceJarPath.substring(resourceJarPath.lastIndexOf(":") + 1);
+ }
+ if(resourceJarPath.contains("!")) {
+ resourceJarPath = resourceJarPath.substring(0, resourceJarPath.indexOf("!"));
+ }
+ File resourceJar = new File(resourceJarPath);
- releaseDir.mkdirs();
+ // Dump the closure lib from classpath.
+ dumpJar(resourceJar, closureLibDir);
+ }
+ // The compiler automatically adds a "closure" to the lib dir path,
+ // so we omit this here.
+ closureLibDirPath = intermediateDir.getParentFile().getPath();
+ }
+ // Fallback to the default.
+ else {
+ closureLibDirPath = ((JSGoogConfiguration) configuration).getClosureLib();
+ }
+ }
+
+ // Dump FlexJS to the target directory.
+ String flexJsLibDirPath;
+ // Check if the "FlexJS/src/createjs_externals.js" is available in the classpath.
+ URL resource = Thread.currentThread().getContextClassLoader().getResource("FlexJS/src/createjs_externals.js");
+ if(resource != null) {
+ File flexJsLibDir = new File(intermediateDir.getParent(), "flexjs");
+
+ // Only create and dump the content, if the directory does not exists.
+ if(!flexJsLibDir.exists()) {
+ if(!flexJsLibDir.mkdirs()) {
+ throw new IOException(
+ "Unable to create directory for flexjs-lib at " + flexJsLibDir.getAbsolutePath());
+ }
+
+ // Strip the url of the parts we don't need.
+ // Unless we are not using some insanely complex setup
+ // the resource will always be on the same machine.
+ String resourceJarPath = resource.getFile();
+ if(resourceJarPath.contains(":")) {
+ resourceJarPath = resourceJarPath.substring(resourceJarPath.lastIndexOf(":") + 1);
+ }
+ if(resourceJarPath.contains("!")) {
+ resourceJarPath = resourceJarPath.substring(0, resourceJarPath.indexOf("!"));
+ }
+ File resourceJar = new File(resourceJarPath);
+
+ // Dump the closure lib from classpath.
+ dumpJar(resourceJar, flexJsLibDir);
+ }
+ // The compiler automatically adds a "closure" to the lib dir path,
+ // so we omit this here.
+ flexJsLibDirPath = intermediateDir.getParentFile().getPath();
}
- final String closureLibDirPath = ((JSGoogConfiguration) configuration)
- .getClosureLib();
final String closureGoogSrcLibDirPath = closureLibDirPath
+ "/closure/goog/";
final String closureGoogTgtLibDirPath = intermediateDirPath
@@ -258,7 +338,7 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
Collections.sort(subsetdeps, new DependencyLineComparator());
for (DependencyRecord subsetdeprec : subsetdeps)
{
- sb.append(subsetdeprec.line + "\n");
+ sb.append(subsetdeprec.line).append("\n");
}
writeFile(depsTgtFilePath, sb.toString() + depsFileData.toString(), false);
// copy the required files
@@ -341,8 +421,9 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
if (!isMarmotinniRun)
{
String allDeps = "";
- if (!subsetGoog)
+ if (!subsetGoog) {
allDeps += FileUtils.readFileToString(srcDeps);
+ }
allDeps += FileUtils.readFileToString(new File(depsTgtFilePath));
FileUtils.writeStringToFile(srcDeps, allDeps);
@@ -361,8 +442,9 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
private void addDeps(ArrayList<DependencyRecord> subsetdeps, HashMap<String, String> gotgoog,
HashMap<String, DependencyRecord> defmap, String deps)
{
- if (deps.length() == 0)
+ if (deps.length() == 0) {
return;
+ }
String[] deplist = deps.split(",");
for (String dep : deplist)
@@ -382,15 +464,8 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
private void appendExportSymbol(String path, String projectName)
throws IOException
{
- StringBuilder appendString = new StringBuilder();
- appendString
- .append("\n\n// Ensures the symbol will be visible after compiler renaming.\n");
- appendString.append("goog.exportSymbol('");
- appendString.append(projectName);
- appendString.append("', ");
- appendString.append(projectName);
- appendString.append(");\n");
- writeFile(path, appendString.toString(), true);
+ writeFile(path, "\n\n// Ensures the symbol will be visible after compiler renaming.\n" +
+ "goog.exportSymbol('" + projectName + "', " + projectName + ");\n", true);
}
private void appendEncodedCSS(String path, String projectName)
@@ -456,13 +531,12 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
htmlFile.append("<head>\n");
htmlFile.append("\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\">\n");
htmlFile.append("\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n");
- htmlFile.append("\t<link rel=\"stylesheet\" type=\"text/css\" href=\""
- + projectName + ".css\">\n");
+ htmlFile.append("\t<link rel=\"stylesheet\" type=\"text/css\" href=\"").append(projectName).append(".css\">\n");
for (String s : additionalHTML)
- htmlFile.append(s + "\n");
+ htmlFile.append(s).append("\n");
- if (type == "intermediate")
+ if ("intermediate".equals(type))
{
htmlFile.append("\t<script type=\"text/javascript\" src=\"./library/closure/goog/base.js\"></script>\n");
htmlFile.append("\t<script type=\"text/javascript\">\n");
@@ -496,10 +570,7 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
private void writeCSS(String projectName, String dirPath)
throws IOException
{
- StringBuilder cssFile = new StringBuilder();
- cssFile.append(project.cssDocument);
-
writeFile(dirPath + File.separator + projectName + ".css",
- cssFile.toString(), false);
+ project.cssDocument, false);
}
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e92a0e9c/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSPublisher.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSPublisher.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSPublisher.java
index 3c44bd0..7a01109 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSPublisher.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSPublisher.java
@@ -18,18 +18,9 @@
*/
package org.apache.flex.compiler.internal.codegen.mxml.vf2js;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Scanner;
+import java.io.*;
+import java.net.URL;
+import java.util.*;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
@@ -77,8 +68,7 @@ public class MXMLVF2JSPublisher extends JSGoogPublisher implements
this.isMarmotinniRun = ((JSGoogConfiguration) configuration)
.getMarmotinni() != null;
- this.outputPathParameter = ((JSGoogConfiguration) configuration)
- .getOutput();
+ this.outputPathParameter = configuration.getOutput();
this.useStrictPublishing = ((JSGoogConfiguration) configuration)
.getStrictPublish();
@@ -133,7 +123,7 @@ public class MXMLVF2JSPublisher extends JSGoogPublisher implements
@Override
public boolean publish(ProblemQuery problems) throws IOException
{
- boolean ok = true;
+ boolean ok;
boolean subsetGoog = true;
final String intermediateDirPath = outputFolder.getPath();
@@ -157,8 +147,50 @@ public class MXMLVF2JSPublisher extends JSGoogPublisher implements
releaseDir.mkdirs();
}
- final String closureLibDirPath = ((JSGoogConfiguration) configuration)
- .getClosureLib();
+ // If the closure-lib parameter is empty we'll try to find the resources
+ // in the classpath, dump its content to the output directory and use this
+ // as closure-lib parameter.
+ final String closureLibDirPath;
+ if(((JSGoogConfiguration) configuration).isClosureLibSet()) {
+ closureLibDirPath = ((JSGoogConfiguration) configuration).getClosureLib();
+ } else {
+ // Check if the "goog/deps.js" is available in the classpath.
+ URL resource = Thread.currentThread().getContextClassLoader().getResource("goog/deps.js");
+ if(resource != null) {
+ File closureLibDir = new File(intermediateDir.getParent(), "closure");
+
+ // Only create and dump the content, if the directory does not exists.
+ if(!closureLibDir.exists()) {
+ if(!closureLibDir.mkdirs()) {
+ throw new IOException(
+ "Unable to create directory for closure-lib at " + closureLibDir.getAbsolutePath());
+ }
+
+ // Strip the url of the parts we don't need.
+ // Unless we are not using some insanely complex setup
+ // the resource will always be on the same machine.
+ String resourceJarPath = resource.getFile();
+ if(resourceJarPath.contains(":")) {
+ resourceJarPath = resourceJarPath.substring(resourceJarPath.lastIndexOf(":") + 1);
+ }
+ if(resourceJarPath.contains("!")) {
+ resourceJarPath = resourceJarPath.substring(0, resourceJarPath.indexOf("!"));
+ }
+ File resourceJar = new File(resourceJarPath);
+
+ // Dump the closure lib from classpath.
+ dumpJar(resourceJar, closureLibDir);
+ }
+ // The compiler automatically adds a "closure" to the lib dir path,
+ // so we omit this here.
+ closureLibDirPath = intermediateDir.getParentFile().getPath();
+ }
+ // Fallback to the default.
+ else {
+ closureLibDirPath = ((JSGoogConfiguration) configuration).getClosureLib();
+ }
+ }
+
final String closureGoogSrcLibDirPath = closureLibDirPath
+ "/closure/goog/";
final String closureGoogTgtLibDirPath = intermediateDirPath
@@ -177,11 +209,11 @@ public class MXMLVF2JSPublisher extends JSGoogPublisher implements
if (!subsetGoog)
{
// (erikdebruin) We need to leave the 'goog' files and dependencies well
- // enough alone. We copy the entire library over so the
+ // enough alone. We copy the entire library over so the
// 'goog' dependencies will resolve without our help.
FileUtils.copyDirectory(new File(closureGoogSrcLibDirPath), new File(closureGoogTgtLibDirPath));
}
-
+
JSClosureCompilerWrapper compilerWrapper = new JSClosureCompilerWrapper();
GoogDepsWriter gdw = new GoogDepsWriter(intermediateDir, projectName, (JSGoogConfiguration) configuration);
@@ -258,7 +290,7 @@ public class MXMLVF2JSPublisher extends JSGoogPublisher implements
Collections.sort(subsetdeps, new DependencyLineComparator());
for (DependencyRecord subsetdeprec : subsetdeps)
{
- sb.append(subsetdeprec.line + "\n");
+ sb.append(subsetdeprec.line).append("\n");
}
writeFile(depsTgtFilePath, sb.toString() + depsFileData.toString(), false);
// copy the required files
@@ -461,13 +493,14 @@ public class MXMLVF2JSPublisher extends JSGoogPublisher implements
htmlFile.append("<head>\n");
htmlFile.append("\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\">\n");
htmlFile.append("\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n");
- htmlFile.append("\t<link rel=\"stylesheet\" type=\"text/css\" href=\""
- + projectName + ".css\">\n");
+ htmlFile.append("\t<link rel=\"stylesheet\" type=\"text/css\" href=\"");
+ htmlFile.append(projectName);
+ htmlFile.append(".css\">\n");
for (String s : additionalHTML)
- htmlFile.append(s + "\n");
+ htmlFile.append(s).append("\n");
- if (type == "intermediate")
+ if ("intermediate".equals(type))
{
htmlFile.append("\t<script type=\"text/javascript\" src=\"./library/closure/goog/base.js\"></script>\n");
htmlFile.append("\t<script type=\"text/javascript\" src=\"./sdk-deps.js\"></script>\n");
@@ -525,7 +558,7 @@ public class MXMLVF2JSPublisher extends JSGoogPublisher implements
htmlFile.append("\t\t\t infoObject[\"currentDomain\"] = new flash.system.ApplicationDomain();\n");
htmlFile.append("\t\t\t infoObject[\"fonts\"] = '';\n");
htmlFile.append("\t\t\t infoObject[\"frames\"] = '';\n");
- htmlFile.append("\t\t\t infoObject[\"mainClassName\"] = '" + projectName + "';\n");
+ htmlFile.append("\t\t\t infoObject[\"mainClassName\"] = '").append(projectName).append("';\n");
htmlFile.append("\t\t\t infoObject[\"mixins\"] = '';\n");
htmlFile.append("\t\t\t infoObject[\"preloader\"] = new mx.preloaders.DownloadProgressBar();\n");
htmlFile.append("\t\t\t infoObject[\"rsls\"] = '';\n");
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e92a0e9c/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/goog/JSGoogConfiguration.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/goog/JSGoogConfiguration.java b/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/goog/JSGoogConfiguration.java
index d5608ea..1b7efe1 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/goog/JSGoogConfiguration.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/goog/JSGoogConfiguration.java
@@ -57,13 +57,17 @@ public class JSGoogConfiguration extends JSConfiguration
protected String closureLib = "";
+ public boolean isClosureLibSet() {
+ return !closureLib.isEmpty();
+ }
+
public String getClosureLib()
{
try
{
if (closureLib.equals(""))
{
- closureLib = getAbsolutePathFromPathRelativeToMXMLC(
+ return getAbsolutePathFromPathRelativeToMXMLC(
"../../js/lib/google/closure-library");
}
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e92a0e9c/compiler.jx/src/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java b/compiler.jx/src/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java
index cde5681..e390c5f 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java
@@ -44,6 +44,7 @@ public class GoogDepsWriter {
this.outputFolderPath = outputFolder.getAbsolutePath();
this.mainName = mainClassName;
otherPaths = config.getSDKJSLib();
+ otherPaths.add(new File(outputFolder.getParent(), "flexjs/FlexJS/src").getPath());
}
private ProblemQuery problems;
@@ -145,6 +146,9 @@ public class GoogDepsWriter {
GoogDep gd = new GoogDep();
gd.className = className;
gd.filePath = getFilePath(className);
+ if(gd.filePath.isEmpty()) {
+ throw new RuntimeException("Unable to find JavaScript filePath for class: " + className);
+ }
depMap.put(gd.className, gd);
ArrayList<String> deps = getDirectDependencies(gd.filePath);
@@ -261,7 +265,7 @@ public class GoogDepsWriter {
FileUtils.copyFile(f, destFile);
// (erikdebruin) copy class assets files
- if (className.indexOf("org.apache.flex") > -1)
+ if (className.contains("org.apache.flex"))
{
File assetsDir = new File(f.getParentFile(), "assets");
if (assetsDir.exists())
@@ -269,32 +273,30 @@ public class GoogDepsWriter {
String nameOfClass = className.substring(className.lastIndexOf('.') + 1);
File[] assetsList = assetsDir.listFiles();
- for (int i = 0; i < assetsList.length; i++)
- {
- File assetFile = assetsList[i];
- String assetFileName = assetFile.getName();
-
- if (assetFile.isFile() && assetFileName.indexOf(nameOfClass) == 0)
- {
- String pathOfClass = "";
- pathOfClass = className.substring(0, className.lastIndexOf('.'));
- pathOfClass = pathOfClass.replace(".", File.separator);
-
- destFile = new File(outputFolderPath +
- File.separator + pathOfClass +
- File.separator + "assets" +
- File.separator + assetFileName);
- FileUtils.copyFile(assetFile, destFile);
-
- destFile = new File(outputFolderPath.replace("js-debug", "js-release") +
- File.separator + pathOfClass +
- File.separator + "assets" +
- File.separator + assetFileName);
- FileUtils.copyFile(assetFile, destFile);
-
- System.out.println("Copied assets of the '" + nameOfClass + "' class");
- }
- }
+ assert assetsList != null;
+ for (File assetFile : assetsList) {
+ String assetFileName = assetFile.getName();
+
+ if (assetFile.isFile() && assetFileName.indexOf(nameOfClass) == 0) {
+ String pathOfClass;
+ pathOfClass = className.substring(0, className.lastIndexOf('.'));
+ pathOfClass = pathOfClass.replace(".", File.separator);
+
+ destFile = new File(outputFolderPath +
+ File.separator + pathOfClass +
+ File.separator + "assets" +
+ File.separator + assetFileName);
+ FileUtils.copyFile(assetFile, destFile);
+
+ destFile = new File(outputFolderPath.replace("js-debug", "js-release") +
+ File.separator + pathOfClass +
+ File.separator + "assets" +
+ File.separator + assetFileName);
+ FileUtils.copyFile(assetFile, destFile);
+
+ System.out.println("Copied assets of the '" + nameOfClass + "' class");
+ }
+ }
}
}
} catch (IOException e) {
@@ -322,7 +324,7 @@ public class GoogDepsWriter {
while (scanner.hasNextLine())
{
String s = scanner.nextLine();
- if (s.indexOf("goog.inherits") > -1)
+ if (s.contains("goog.inherits"))
break;
if (inInjectHTML)
{
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e92a0e9c/compiler/downloads.xml
----------------------------------------------------------------------
diff --git a/compiler/downloads.xml b/compiler/downloads.xml
index d1b4d6a..d2c14f3 100644
--- a/compiler/downloads.xml
+++ b/compiler/downloads.xml
@@ -218,18 +218,18 @@
</antcall>
<!-- flex-tool-api -->
- <property name="flexToolApi.name" value="flex-tool-api"/>
- <property name="flexToolApi.version" value="1.0.0-SNAPSHOT"/>
- <antcall target="download-dependency">
- <param name="name" value="${flexToolApi.name}"/>
- <param name="src.server" value="http://repository.apache.org/content/groups/snapshots"/>
- <param name="src.folder" value="org/apache/flex/flex-tool-api/${flexToolApi.version}"/>
- <param name="src.filename" value="flex-tool-api-1.0.0-20141110.132854-7.jar"/>
- <param name="src.checksum" value="ea3468a0af7f7b5ef6a3bf91d768c78d"/>
- <param name="dest.folder" value=""/>
- <param name="dest.filename" value="${flexToolApi.name}.jar"/>
- <param name="license.use.apache" value="true"/>
- </antcall>
+ <property name="flexToolApi.name" value="flex-tool-api"/>
+ <property name="flexToolApi.version" value="1.0.0"/>
+ <antcall target="download-dependency">
+ <param name="name" value="${flexToolApi.name}"/>
+ <param name="src.server" value="${maven.search.url}"/>
+ <param name="src.folder" value="org/apache/flex/${flexToolApi.name}/${flexToolApi.version}"/>
+ <param name="src.filename" value="${flexToolApi.name}-${flexToolApi.version}.jar"/>
+ <param name="src.checksum" value="b8f76174b2c4d3b83e5c9fa78703c52b"/>
+ <param name="dest.folder" value=""/>
+ <param name="dest.filename" value="${flexToolApi.name}.jar"/>
+ <param name="license.use.apache" value="true"/>
+ </antcall>
</target>
<target name="maven-related" description="Downloads and copies all dependencies to the lib directory.">
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e92a0e9c/compiler/src/org/apache/flex/compiler/clients/COMPC.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/clients/COMPC.java b/compiler/src/org/apache/flex/compiler/clients/COMPC.java
index af55eac..547f40f 100644
--- a/compiler/src/org/apache/flex/compiler/clients/COMPC.java
+++ b/compiler/src/org/apache/flex/compiler/clients/COMPC.java
@@ -79,7 +79,7 @@ public class COMPC extends MXMLC implements FlexTool
@Override
public String getName() {
- return "COMPC";
+ return FLEX_TOOL_COMPC;
}
@Override
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e92a0e9c/compiler/src/org/apache/flex/compiler/clients/MXMLC.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/clients/MXMLC.java b/compiler/src/org/apache/flex/compiler/clients/MXMLC.java
index 2b7e97b..51830b1 100644
--- a/compiler/src/org/apache/flex/compiler/clients/MXMLC.java
+++ b/compiler/src/org/apache/flex/compiler/clients/MXMLC.java
@@ -177,7 +177,7 @@ public class MXMLC implements FlexTool
@Override
public String getName() {
- return "MXMLC";
+ return FLEX_TOOL_MXMLC;
}
@Override
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e92a0e9c/compiler/src/org/apache/flex/compiler/clients/Optimizer.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/clients/Optimizer.java b/compiler/src/org/apache/flex/compiler/clients/Optimizer.java
index 1566cf5..fa62e0a 100644
--- a/compiler/src/org/apache/flex/compiler/clients/Optimizer.java
+++ b/compiler/src/org/apache/flex/compiler/clients/Optimizer.java
@@ -101,7 +101,7 @@ public class Optimizer implements FlexTool
@Override
public String getName() {
- return "OPTIMIZER";
+ return FLEX_TOOL_OPTIMIZER;
}
@Override
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e92a0e9c/maven/falcon-jx-compiler.pom
----------------------------------------------------------------------
diff --git a/maven/falcon-jx-compiler.pom b/maven/falcon-jx-compiler.pom
index 8753648..fb408d3 100644
--- a/maven/falcon-jx-compiler.pom
+++ b/maven/falcon-jx-compiler.pom
@@ -54,6 +54,11 @@
<artifactId>closure-compiler</artifactId>
<version>v20141023</version>
</dependency>
+ <dependency>
+ <groupId>org.clojure</groupId>
+ <artifactId>google-closure-library</artifactId>
+ <version>0.0-20140718-946a7d39</version>
+ </dependency>
</dependencies>
</project>