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,
            Map<String, String> customDefaultOptions, CompilationProgress compilationProgress) 

Source Link

Usage

From source file:com.wavemaker.tools.compiler.WaveMakerJavaCompiler.java

License:Open Source License

@Override
public int run(InputStream in, OutputStream out, OutputStream err, String... arguments) {
    Main compiler = new Main(createPrintWriter(out), createPrintWriter(err), true, null, null);
    boolean succeed = compiler.compile(arguments);
    return succeed ? 0 : -1;
}

From source file:io.gige.compiler.internal.CompilationTaskImpl.java

License:Apache License

protected Main parseOptions(PrintWriter out, Iterable<String> argv,
        Iterable<? extends JavaFileObject> compilationUnits) {
    Map<String, String> defaults = new HashMap<>();
    defaults.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_8);
    defaults.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_8);
    defaults.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_8);

    Stream<String> files = Stream.concat(stream(argv.spliterator(), false),
            stream(compilationUnits.spliterator(), false).map(JavaFileObject::toUri)
                    .map(uri -> new File(uri).getAbsolutePath()));

    Main main = new Main(out, out, false, defaults, null);
    main.configure(files.toArray(String[]::new));
    return main;// w  w w .  ja va 2s  .c  om
}

From source file:org.bonitasoft.engine.business.data.generator.compiler.JDTCompiler.java

License:Open Source License

private void doCompilation(final String[] commandLine, final PrintWriter outWriter,
        final ByteArrayOutputStream errorStream, final PrintWriter errorWriter) throws CompilationException {
    final Main mainCompiler = new Main(outWriter, errorWriter, false /* systemExit */, null /* options */,
            new DummyCompilationProgress()) {

        @Override//from ww  w .ja v a  2 s .co  m
        public FileSystem getLibraryAccess() {
            final ClassLoader contextClassLoader = classLoader;
            return new ClassLoaderEnvironment(contextClassLoader);
        }
    };
    final boolean succeeded = mainCompiler.compile(commandLine);
    if (!succeeded) {
        throw new CompilationException(new String(errorStream.toByteArray()));
    }
}

From source file:org.bonitasoft.engine.compiler.JDTCompiler.java

License:Open Source License

private void doCompilation(final String[] commandLine, final PrintWriter outWriter,
        final ByteArrayOutputStream errorStream, final PrintWriter errorWriter) throws CompilationException {

    Main mainCompiler = new Main(outWriter, errorWriter, false /* systemExit */, null /* options */,
            new DummyCompilationProgress()) {

        @Override//ww  w . j av a 2  s .c  om
        public FileSystem getLibraryAccess() {
            ClassLoader contextClassLoader = classLoader;
            return new ClassLoaderEnvironment(contextClassLoader);
        }
    };
    final boolean succeeded = mainCompiler.compile(commandLine);
    if (!succeeded) {
        throw new CompilationException(new String(errorStream.toByteArray()));
    }
}

From source file:org.codehaus.groovy.eclipse.compiler.GroovyEclipseCompiler.java

License:Open Source License

@SuppressWarnings("rawtypes")
public List compile(CompilerConfiguration config) throws CompilerException {

    String[] args = createCommandLine(config);
    if (args.length == 0) {
        getLogger().info("Nothing to compile - all classes are up to date");
        return Collections.emptyList();
    }//from   www.ja  v a2s .  c  o  m

    List<CompilerError> messages;
    if (config.isFork()) {
        String executable = config.getExecutable();

        if (StringUtils.isEmpty(executable)) {
            try {
                executable = getJavaExecutable();
            } catch (IOException e) {
                getLogger().warn("Unable to autodetect 'java' path, using 'java' from the environment.");
                executable = "java";
            }
        }

        String groovyEclipseLocation = getGroovyEclipseBatchLocation();
        messages = compileOutOfProcess(config, executable, groovyEclipseLocation, args);
    } else {
        Progress progress = new Progress();
        Main main = new Main(new PrintWriter(System.out), new PrintWriter(System.err), false/* systemExit */,
                null/* options */, progress);
        boolean result = main.compile(args);

        messages = formatResult(main, result);
    }
    return messages;
}

From source file:org.eclipse.objectteams.otdt.tests.compiler.TestBase.java

License:Open Source License

public void compileFile(String fname, String[] classpath, Map options) {
    System.out.println("*************************** " + this.getClass().getName() + " " + this.getName()
            + " ***************************");
    _logFileName = fname;/*from  w ww.j av  a  2  s.  co  m*/

    try {
        String missing;
        if ((missing = missingClasspathEntry()) != null) {
            throw new FileNotFoundException("Missing library " + missing);
        }

        String[] args = (classpath == null) ? createClassPath(fname) : classpath;

        File javaFile = new File(_workingDir.getAbsolutePath() + File.separator + fname + JAVA_FILE_EXTENSION);

        if (!javaFile.exists()) {
            throw new FileNotFoundException("File to compile was not found!: " + _logFileName);
        }

        _compiler = new Main(
                new PrintWriter(new FileOutputStream(
                        PROJECT_PATH + File.separator + _logFileName + LOG_FILE_EXTENSION)),
                new PrintWriter(new FileOutputStream(
                        PROJECT_PATH + File.separator + _logFileName + LOG_FILE_EXTENSION)),
                false, options, null);

        _compiler.compile(args);
    } catch (FileNotFoundException ex) {
        handleException(ex);
    }
}