@GwtIncompatible(value="Unnecessary") public class CommandLineRunner extends AbstractCommandLineRunner<Compiler,CompilerOptions>
class MyCommandLineRunner extends CommandLineRunner {
MyCommandLineRunner(String[] args) {
super(args);
}
@Override
protected CompilerOptions createOptions() {
CompilerOptions options = super.createOptions();
addMyCrazyCompilerPassThatOutputsAnExtraFile(options);
return options;
}
public static void main(String[] args) {
MyCommandLineRunner runner = new MyCommandLineRunner(args);
if (runner.shouldRunCompiler()) {
runner.run();
}
if (runner.hasErrors()) {
System.exit(-1);
}
}
}
This class is totally not thread-safe.Modifier and Type | Class and Description |
---|---|
private static class |
CommandLineRunner.Flags |
private static class |
CommandLineRunner.FormattingOption
Set of options that can be used with the --formatting flag.
|
AbstractCommandLineRunner.CommandLineConfig, AbstractCommandLineRunner.FlagEntry<T>, AbstractCommandLineRunner.FlagUsageException, AbstractCommandLineRunner.JsModuleSpec, AbstractCommandLineRunner.JsSourceType
Modifier and Type | Field and Description |
---|---|
private boolean |
errors |
private java.io.PrintStream |
errorStream
Cached error stream to avoid passing it as a parameter to helper
functions.
|
private static Pattern |
extraModuleNameChars |
private CommandLineRunner.Flags |
flags |
static java.lang.String |
OUTPUT_MARKER |
private boolean |
runCompiler |
static int |
UTF8_BOM_CODE |
CONFLICTING_DUPLICATE_ZIP_CONTENTS, INVALID_MODULE_SOURCEMAP_PATTERN, NO_TREE_GENERATED_ERROR, OUTPUT_SAME_AS_INPUT_ERROR, WAITING_FOR_INPUT_WARNING
Modifier | Constructor and Description |
---|---|
protected |
CommandLineRunner(java.lang.String[] args)
Create a new command-line runner.
|
protected |
CommandLineRunner(java.lang.String[] args,
java.io.InputStream in,
java.io.PrintStream out,
java.io.PrintStream err) |
protected |
CommandLineRunner(java.lang.String[] args,
java.io.PrintStream out,
java.io.PrintStream err) |
Modifier and Type | Method and Description |
---|---|
protected void |
addWhitelistWarningsGuard(CompilerOptions options,
File whitelistFile) |
protected void |
checkModuleName(java.lang.String name)
Validates the module name.
|
protected Compiler |
createCompiler()
Returns the instance of the Compiler to use when
AbstractCommandLineRunner.run() is
called. |
protected java.util.List<SourceFile> |
createExterns(CompilerOptions options) |
protected CompilerOptions |
createOptions()
Returns the instance of the Options to use when
AbstractCommandLineRunner.run() is called. |
static java.util.List<java.lang.String> |
findJsFiles(java.util.Collection<java.lang.String> patterns)
Returns all the JavaScript files from the set of patterns.
|
private static java.util.List<java.lang.String> |
findJsFiles(java.util.Collection<java.lang.String> patterns,
boolean sortAlphabetically)
Returns all the JavaScript files from the set of patterns.
|
static java.util.List<SourceFile> |
getDefaultExterns()
Deprecated.
|
boolean |
hasErrors() |
private void |
initConfigFromFlags(java.lang.String[] args,
java.io.PrintStream out,
java.io.PrintStream err) |
private static ConformanceConfig |
loadConformanceConfig(java.lang.String configFile) |
private com.google.common.collect.ImmutableList<ConformanceConfig> |
loadConformanceConfigs(java.util.List<java.lang.String> configPaths) |
static void |
main(java.lang.String[] args)
Runs the Compiler.
|
private static void |
matchPaths(java.lang.String pattern,
java.util.Set<java.lang.String> allJsInputs,
java.util.Set<java.lang.String> excludes) |
private static java.util.List<java.lang.String> |
processArgs(java.lang.String[] args) |
private void |
processFlagFile() |
private void |
reportError(java.lang.String message) |
boolean |
shouldRunCompiler() |
createDefineOrTweakReplacements, createDependencyOptions, createInputs, createInputs, createInputs, createJsModules, createJsonFile, doRun, enableTestMode, expandSourceMapPath, filenameToOutputStream, getBuiltinExterns, getCommandLineConfig, getCompiler, getDiagnosticGroups, getErrorPrintStream, getJavascriptEscaper, isInTestMode, outputJsonStream, outputSingleBinary, parseJsonFilesFromInputStream, parseModuleWrappers, printBundleTo, printModuleGraphJsonTo, printModuleGraphManifestOrBundleTo, processResults, removeDuplicateZipEntries, run, setRunOptions, writeModuleOutput, writeOutput
public static final java.lang.String OUTPUT_MARKER
public static final int UTF8_BOM_CODE
private static final Pattern extraModuleNameChars
private final CommandLineRunner.Flags flags
private boolean errors
private boolean runCompiler
private java.io.PrintStream errorStream
protected CommandLineRunner(java.lang.String[] args)
protected CommandLineRunner(java.lang.String[] args, java.io.PrintStream out, java.io.PrintStream err)
protected CommandLineRunner(java.lang.String[] args, java.io.InputStream in, java.io.PrintStream out, java.io.PrintStream err)
private static java.util.List<java.lang.String> processArgs(java.lang.String[] args)
private void reportError(java.lang.String message)
private void processFlagFile() throws org.kohsuke.args4j.CmdLineException, java.io.IOException
org.kohsuke.args4j.CmdLineException
java.io.IOException
private void initConfigFromFlags(java.lang.String[] args, java.io.PrintStream out, java.io.PrintStream err)
protected void addWhitelistWarningsGuard(CompilerOptions options, File whitelistFile)
addWhitelistWarningsGuard
in class AbstractCommandLineRunner<Compiler,CompilerOptions>
protected void checkModuleName(java.lang.String name)
AbstractCommandLineRunner
checkModuleName
in class AbstractCommandLineRunner<Compiler,CompilerOptions>
name
- The module nameprotected CompilerOptions createOptions()
AbstractCommandLineRunner
AbstractCommandLineRunner.run()
is called.
createCompiler() is called before createOptions(), so getCompiler()
will not return null when createOptions() is called.createOptions
in class AbstractCommandLineRunner<Compiler,CompilerOptions>
protected Compiler createCompiler()
AbstractCommandLineRunner
AbstractCommandLineRunner.run()
is
called.createCompiler
in class AbstractCommandLineRunner<Compiler,CompilerOptions>
protected java.util.List<SourceFile> createExterns(CompilerOptions options) throws java.io.IOException
createExterns
in class AbstractCommandLineRunner<Compiler,CompilerOptions>
java.io.IOException
private com.google.common.collect.ImmutableList<ConformanceConfig> loadConformanceConfigs(java.util.List<java.lang.String> configPaths)
private static ConformanceConfig loadConformanceConfig(java.lang.String configFile) throws java.io.IOException
java.io.IOException
@Deprecated public static java.util.List<SourceFile> getDefaultExterns() throws java.io.IOException
java.io.IOException
public static java.util.List<java.lang.String> findJsFiles(java.util.Collection<java.lang.String> patterns) throws java.io.IOException
java.io.IOException
private static java.util.List<java.lang.String> findJsFiles(java.util.Collection<java.lang.String> patterns, boolean sortAlphabetically) throws java.io.IOException
patterns
- A collection of filename patterns.sortAlphabetically
- Whether the output filenames should be in alphabetical order.java.io.IOException
private static void matchPaths(java.lang.String pattern, java.util.Set<java.lang.String> allJsInputs, java.util.Set<java.lang.String> excludes) throws java.io.IOException
java.io.IOException
public boolean shouldRunCompiler()
public boolean hasErrors()
public static void main(java.lang.String[] args)