final Collection<File> classpath = paths.getCompilationClasspath(chunk, context.isCompilingTests(), !context.isMake());
final Collection<File> platformCp = paths.getPlatformCompilationClasspath(chunk, context.isCompilingTests(), !context.isMake());
final Map<File, Set<File>> outs = buildOutputDirectoriesMap(context, chunk);
final List<String> options = getCompilationOptions(context, chunk);
final TimestampStorage tsStorage = context.getBuildDataManager().getTimestampStorage(BUILDER_NAME);
// setup loader for instrumentation
final List<URL> urls = new ArrayList<URL>();
for (Collection<File> cp : Arrays.asList(platformCp, classpath)) {
for (File file : cp) {
urls.add(file.toURI().toURL());
}
}
final PseudoClassLoader pseudoLoader = new PseudoClassLoader(urls.toArray(new URL[urls.size()]));
PSEUDO_CLASSLOADER_KEY.set(context, pseudoLoader);
final DiagnosticSink diagnosticSink = new DiagnosticSink(context);
final OutputFilesSink outputSink = new OutputFilesSink(context);
try {
final boolean compilationOk = myJavacCompiler.compile(options, files, classpath, platformCp, outs, context, diagnosticSink, outputSink);
if (!compilationOk || diagnosticSink.getErrorCount() > 0) {
throw new ProjectBuildException("Compilation failed: errors: " + diagnosticSink.getErrorCount() + "; warnings: " + diagnosticSink.getWarningCount());
}
instrumentForms(context, pseudoLoader, forms, outs);
// todo: add notNull
return ExitCode.OK;
}
finally {
outputSink.writePendingData();
PSEUDO_CLASSLOADER_KEY.set(context, null);
for (File file : outputSink.getSuccessfullyCompiled()) {
tsStorage.saveStamp(file);
}
}
}