public class JavaScriptCompilerImpl implements Compiler {
@Override
public boolean compile(CompilerOptions options,
CompilationListener listener) {
CeylonCompileJsTool tool = new CeylonCompileJsTool();
if(options.isVerbose())
tool.setVerbose("");
tool.setOffline(options.isOffline());
try {
tool.setRepositoryAsStrings(options.getUserRepositories());
} catch (Exception e) {
throw new RuntimeException(e);
}
tool.setSystemRepository(options.getSystemRepository());
tool.setOut(options.getOutputRepository());
tool.setSource(options.getSourcePath());
// just mix them all
List<String> moduleOrFile = new ArrayList<String>();
moduleOrFile.addAll(options.getModules());
moduleOrFile.addAll(fileToStringList(options.getFiles()));
tool.setModule(moduleOrFile);
tool.setDiagnosticListener(adapt(listener));
tool.setThrowOnError(true);
// FIXME: allow the user to capture stdout
if(!options.isVerbose()){
// make the tool shut the hell up
tool.setOut(new NullWriter());
}
try {
tool.run();
} catch (CompilerErrorException e) {
return false;
} catch (Exception e) {
throw new RuntimeException(e);
}