options.add(compileTargetDir.getAbsolutePath());
for (CompilerOptionsProvider cop : compilerOptionsProviders) {
options.addAll(cop.getOptions());
}
logger.info("Compiler options: "+options.toString());
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
if (compiler == null) throw new NullPointerException("No java compiler available! Did you start from a JDK? JRE will not work.");
StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);
final Map<String,File> files = new HashMap<String,File>();
try {
final StringWriter sw = new StringWriter();
sw.append("Compilation failed!\n");
for (String dir : sourceDirs) {
files.putAll(findFiles(new File(dir), ".java"));
}
files.putAll(findFiles(additionalSourcesDir,".java"));
if (files.size() > 0) {
final Iterable<? extends JavaFileObject> compilationUnits1 = fileManager.getJavaFileObjectsFromFiles(files.values());
final CompilationTask task = compiler.getTask(sw, fileManager, null, options, null, compilationUnits1);
if (!task.call()) {
logger.error(sw.toString());
throw new CopperRuntimeException("Compilation failed, see logfile for details");
}
}