use of scala.collection.mutable.ListBuffer in project navajo by Dexels.
the class ScalaCompiler method compileScript.
@Override
protected Set<String> compileScript(File scriptFile, String script, String packagePath, List<Dependency> dependencies, String tenant, boolean hasTenantSpecificFile, boolean forceTenant) throws CompilationException {
final Set<String> packages = new HashSet<>();
for (String pkg : standardPackages) {
packages.add(pkg);
}
PackageReportingClassLoader prc = new PackageReportingClassLoader(navajoScriptClassLoader);
prc.addPackageListener(name -> {
if (whitelist.contains(name)) {
packages.add(name);
}
});
File targetDir = new File(navajoIOConfig.getCompiledScriptPath(), packagePath + File.separator + script);
targetDir.mkdirs();
Settings settings = new Settings();
settings.outputDirs().setSingleOutput(targetDir.getAbsolutePath());
ConsoleReporter reporter = new ConsoleReporter(settings);
ReflectGlobal g = new ReflectGlobal(settings, reporter, prc);
Global.Run compiler = g.new Run();
ListBuffer<String> files = new ListBuffer<>();
String file = scriptFile.getAbsolutePath();
addScalaCommon(files);
files.$plus$eq(file);
try {
compiler.compile(files.toList());
} catch (Exception e) {
logger.error("Exception on getting scala code! {}", e);
}
logger.debug("finished compiling scala for the following files: {}", compiler.compiledFiles());
return packages;
}
Aggregations