Class CommandLineRunner


  • @GwtIncompatible("Unnecessary")
    public class CommandLineRunner
    extends AbstractCommandLineRunner<Compiler,​CompilerOptions>
    CommandLineRunner translates flags into Java API calls on the Compiler.

    This class may be extended and used to create other Java classes that behave the same as running the Compiler from the command line. If you want to run the compiler in-process in Java, you should look at this class for hints on what API calls to make, but you should not use this class directly.

    Example:

     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.