Example usage for org.eclipse.jdt.internal.compiler.batch Main Main

List of usage examples for org.eclipse.jdt.internal.compiler.batch Main Main

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.batch Main Main.

Prototype

public Main(PrintWriter outWriter, PrintWriter errWriter, boolean systemExitWhenFinished) 

Source Link

Usage

From source file:com.runwaysdk.business.generation.EclipseCompiler.java

License:Open Source License

/**
 * Calls the ECJ and wraps any errors in a {@link CompilerException}
 * /*from  ww  w.ja  v a  2s.  c  o  m*/
 * @param args Arguments for the compiler
 * @throws CompilerException if compilation fails
 */
private void callECJ(String args[]) {
    Log log = LogFactory.getLog(COMPILER_LOG);
    log.trace(Arrays.deepToString(args));

    StringWriter output = new StringWriter();
    StringWriter errors = new StringWriter();
    Main compiler = new Main(new PrintWriter(output), new PrintWriter(errors), false);

    compiler.compile(args);

    String message = errors.toString();

    if (message.length() > 0) {
        String error = "Errors found during compilation:\n" + message;
        throw new CompilerException(error, message);
    }
}