use of com.google.devtools.build.java.turbine.javac.JavacTurbineCompileResult.Status in project bazel by bazelbuild.
the class JavacTurbineCompiler method compile.
static JavacTurbineCompileResult compile(JavacTurbineCompileRequest request) throws IOException {
Map<String, OutputFileObject> files = new LinkedHashMap<>();
Status status;
StringWriter sw = new StringWriter();
Context context = new Context();
try (PrintWriter pw = new PrintWriter(sw)) {
setupContext(context, request.strictJavaDepsPlugin());
CacheFSInfo.preRegister(context);
try (ZipOutputFileManager fm = new ZipOutputFileManager(files)) {
JavacTask task = JavacTool.create().getTask(pw, fm, null, /*diagnostics*/
request.javacOptions(), ImmutableList.of(), /*classes*/
fm.getJavaFileObjectsFromPaths(request.sources()), context);
fm.setContext(context);
fm.setLocationFromPaths(StandardLocation.SOURCE_PATH, Collections.<Path>emptyList());
fm.setLocationFromPaths(StandardLocation.CLASS_PATH, request.classPath());
fm.setLocationFromPaths(StandardLocation.PLATFORM_CLASS_PATH, request.bootClassPath());
fm.setLocationFromPaths(StandardLocation.ANNOTATION_PROCESSOR_PATH, request.processorClassPath());
status = task.call() ? Status.OK : Status.ERROR;
} catch (Throwable t) {
t.printStackTrace(pw);
status = Status.ERROR;
}
}
return new JavacTurbineCompileResult(ImmutableMap.copyOf(files), status, sw, context);
}
Aggregations