Make sure publish errors end up in the error list. Also return different exit code if there are only warnings.
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/6c7fb602 Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/6c7fb602 Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/6c7fb602 Branch: refs/heads/maven Commit: 6c7fb60283c2b1b650d494650f384c9c3d14388c Parents: e3be84e Author: Alex Harui <aha...@apache.org> Authored: Tue Dec 3 14:31:45 2013 -0800 Committer: Alex Harui <aha...@apache.org> Committed: Tue Dec 3 14:31:45 2013 -0800 ---------------------------------------------------------------------- .../org/apache/flex/compiler/clients/MXMLJSC.java | 18 ++++++++++++------ .../flex/compiler/codegen/js/IJSPublisher.java | 4 +++- .../compiler/internal/codegen/js/JSPublisher.java | 4 +++- .../internal/codegen/js/goog/JSGoogPublisher.java | 6 +++++- .../codegen/mxml/flexjs/MXMLFlexJSPublisher.java | 16 ++++++++++++---- .../compiler/internal/graph/GoogDepsWriter.java | 13 +++++++++++-- 6 files changed, 46 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6c7fb602/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 841b815..37b3f9b 100644 --- a/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java +++ b/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java @@ -124,8 +124,9 @@ public class MXMLJSC SUCCESS(0), PRINT_HELP(1), FAILED_WITH_PROBLEMS(2), - FAILED_WITH_EXCEPTIONS(3), - FAILED_WITH_CONFIG_PROBLEMS(4); + FAILED_WITH_ERRORS(3), + FAILED_WITH_EXCEPTIONS(4), + FAILED_WITH_CONFIG_PROBLEMS(5); ExitCode(int code) { @@ -260,7 +261,12 @@ public class MXMLJSC { compile(); if (problems.hasFilteredProblems()) - exitCode = ExitCode.FAILED_WITH_PROBLEMS; + { + if (problems.hasErrors()) + exitCode = ExitCode.FAILED_WITH_ERRORS; + else + exitCode = ExitCode.FAILED_WITH_PROBLEMS; + } } else if (problems.hasFilteredProblems()) { @@ -418,9 +424,9 @@ public class MXMLJSC } if (jsPublisher != null) - jsPublisher.publish(); - - compilationSuccess = true; + compilationSuccess = jsPublisher.publish(problems); + else + compilationSuccess = true; } } catch (Exception e) http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6c7fb602/compiler.jx/src/org/apache/flex/compiler/codegen/js/IJSPublisher.java ---------------------------------------------------------------------- diff --git a/compiler.jx/src/org/apache/flex/compiler/codegen/js/IJSPublisher.java b/compiler.jx/src/org/apache/flex/compiler/codegen/js/IJSPublisher.java index e02f3be..3b2ea98 100644 --- a/compiler.jx/src/org/apache/flex/compiler/codegen/js/IJSPublisher.java +++ b/compiler.jx/src/org/apache/flex/compiler/codegen/js/IJSPublisher.java @@ -22,6 +22,8 @@ package org.apache.flex.compiler.codegen.js; import java.io.File; import java.io.IOException; +import org.apache.flex.compiler.clients.problems.ProblemQuery; + /** * The {@link IJSPublisher} interface allows the abstraction of project output * generation. @@ -33,6 +35,6 @@ public interface IJSPublisher File getOutputFolder(); - void publish() throws IOException; + boolean publish(ProblemQuery problems) throws IOException; } http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6c7fb602/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSPublisher.java ---------------------------------------------------------------------- diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSPublisher.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSPublisher.java index 468485d..cc49504 100644 --- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSPublisher.java +++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSPublisher.java @@ -23,6 +23,7 @@ import java.io.File; import java.io.IOException; import org.apache.commons.io.FilenameUtils; +import org.apache.flex.compiler.clients.problems.ProblemQuery; import org.apache.flex.compiler.codegen.js.IJSPublisher; import org.apache.flex.compiler.config.Configuration; @@ -74,10 +75,11 @@ public class JSPublisher implements IJSPublisher return configuration.getOutput(); } - public void publish() throws IOException + public boolean publish(ProblemQuery problems) throws IOException { System.out .println("The project has been successfully compiled and optimized."); + return true; } } http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6c7fb602/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 c44c8bb..d43c932 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 @@ -10,6 +10,7 @@ import java.util.List; import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.filefilter.DirectoryFileFilter; import org.apache.commons.io.filefilter.RegexFileFilter; +import org.apache.flex.compiler.clients.problems.ProblemQuery; import org.apache.flex.compiler.codegen.js.IJSPublisher; import org.apache.flex.compiler.config.Configuration; import org.apache.flex.compiler.internal.codegen.js.JSPublisher; @@ -48,7 +49,8 @@ public class JSGoogPublisher extends JSPublisher implements IJSPublisher return outputFolder; } - public void publish() throws IOException + @Override + public boolean publish(ProblemQuery problems) throws IOException { final String intermediateDirPath = getOutputFolder().getPath(); @@ -153,6 +155,8 @@ public class JSGoogPublisher extends JSPublisher implements IJSPublisher System.out.println("The project '" + projectName + "' has been successfully compiled and optimized."); + + return true; } private void appendExportSymbol(String path, String projectName) http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6c7fb602/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 b101eaf..61f175e 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 @@ -16,6 +16,7 @@ import org.apache.commons.io.filefilter.FileFileFilter; import org.apache.commons.io.filefilter.FileFilterUtils; import org.apache.commons.io.filefilter.IOFileFilter; import org.apache.commons.io.filefilter.RegexFileFilter; +import org.apache.flex.compiler.clients.problems.ProblemQuery; import org.apache.flex.compiler.codegen.js.IJSPublisher; import org.apache.flex.compiler.config.Configuration; import org.apache.flex.compiler.internal.codegen.js.JSSharedData; @@ -84,8 +85,10 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements } @Override - public void publish() throws IOException + public boolean publish(ProblemQuery problems) throws IOException { + boolean ok = true; + final String intermediateDirPath = outputFolder.getPath(); final File intermediateDir = new File(intermediateDirPath); File srcDir = new File(configuration.getTargetFile()); @@ -132,12 +135,14 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements GoogDepsWriter gdw = new GoogDepsWriter(intermediateDir, projectName, (JSGoogConfiguration) configuration); try { - String depsFileData = gdw.generateDeps(); - writeFile(depsTgtFilePath, depsFileData, false); + StringBuilder depsFileData = new StringBuilder(); + ok = gdw.generateDeps(problems, depsFileData); + writeFile(depsTgtFilePath, depsFileData.toString(), false); } catch (InterruptedException e) { e.printStackTrace(); + return false; } IOFileFilter pngSuffixFilter = FileFilterUtils.and(FileFileFilter.FILE, @@ -226,9 +231,12 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements org.apache.commons.io.FileUtils.deleteQuietly(new File(depsTgtFilePath)); } - System.out.println("The project '" + if (ok) + System.out.println("The project '" + projectName + "' has been successfully compiled and optimized."); + + return true; } private void appendExportSymbol(String path, String projectName) http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6c7fb602/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 fac47a3..566fb0e 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 @@ -13,7 +13,9 @@ import java.util.List; import java.util.Scanner; import org.apache.commons.io.FileUtils; +import org.apache.flex.compiler.clients.problems.ProblemQuery; import org.apache.flex.compiler.internal.driver.js.goog.JSGoogConfiguration; +import org.apache.flex.compiler.problems.FileNotFoundProblem; import com.google.common.io.Files; @@ -26,9 +28,11 @@ public class GoogDepsWriter { otherPaths = config.getSDKJSLib(); } + private ProblemQuery problems; private String outputFolderPath; private String mainName; private List<String> otherPaths; + private boolean problemsFound = false; private HashMap<String,GoogDep> depMap = new HashMap<String,GoogDep>(); @@ -44,8 +48,10 @@ public class GoogDepsWriter { return files; } - public String generateDeps() throws InterruptedException, FileNotFoundException + public boolean generateDeps(ProblemQuery problems, StringBuilder depsFileData) throws InterruptedException, FileNotFoundException { + problemsFound = false; + this.problems = problems; buildDB(); ArrayList<GoogDep> dps = sort(mainName); String outString = "// generated by FalconJS" + "\n"; @@ -65,7 +71,8 @@ public class GoogDepsWriter { outString += s; } } - return outString; + depsFileData.append(outString); + return !problemsFound; } private boolean isGoogClass(String className) @@ -240,6 +247,8 @@ public class GoogDepsWriter { } System.out.println("Could not find file for class: " + className); + problems.add(new FileNotFoundProblem(className)); + problemsFound = true; return ""; }