use of org.eclipse.ceylon.common.tool.ToolFactory in project ceylon by eclipse.
the class RepoUsingTool method getSourceDirsForCompiler.
/**
* Use in subclasses that accept compilation before run
*/
protected List<File> getSourceDirsForCompiler(ModuleQuery.Type type) {
List<String> args = new ArrayList<String>(compilerArguments.size() + 1);
args.addAll(compilerArguments);
ToolFactory pluginFactory = new ToolFactory();
ToolLoader pluginLoader = new CeylonToolLoader();
String toolName;
if (type == ModuleQuery.Type.JVM) {
toolName = "compile";
} else if (type == ModuleQuery.Type.JS) {
toolName = "compile-js";
} else if (type == ModuleQuery.Type.DART) {
toolName = "compile-dart";
} else {
throw new IllegalArgumentException("Unknown compile flags passed");
}
try {
ToolModel<Tool> model = pluginLoader.loadToolModel(toolName);
Tool tool = pluginFactory.bindArguments(model, pluginLoader.<CeylonTool>instance("", null), args);
if (tool instanceof RepoUsingTool)
return ((RepoUsingTool) tool).getSourceDirs();
} catch (NonFatalToolMessage m) {
m.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return DefaultToolOptions.getCompilerSourceDirs();
}
use of org.eclipse.ceylon.common.tool.ToolFactory in project ceylon by eclipse.
the class RepoUsingTool method runCompiler.
private boolean runCompiler(RepositoryManager repoMgr, String name, ModuleQuery.Type type, String compileFlags) {
List<String> args = getCompilerArguments();
if (compileFlags != null) {
args.add("--include-dependencies=" + compileFlags);
}
if (!compileFlags.contains(COMPILE_FORCE) && type == ModuleQuery.Type.JVM) {
args.add("--incremental");
}
args.add(name);
ToolFactory pluginFactory = new ToolFactory();
ToolLoader pluginLoader = new CeylonToolLoader();
String toolName;
if (type == ModuleQuery.Type.JVM) {
toolName = "compile";
} else if (type == ModuleQuery.Type.JS) {
toolName = "compile-js";
} else if (type == ModuleQuery.Type.DART) {
toolName = "compile-dart";
} else {
throw new IllegalArgumentException("Unknown compile flags passed");
}
try {
ToolModel<Tool> model = pluginLoader.loadToolModel(toolName);
Tool tool = pluginFactory.bindArguments(model, pluginLoader.<CeylonTool>instance("", null), args);
msg("compiling", name).newline();
tool.run();
// Make sure we can find the newly created module
repoMgr.refresh(false);
if (repoMgr == rm) {
rm = null;
}
} catch (NonFatalToolMessage m) {
} catch (Exception e) {
return false;
}
return true;
}
Aggregations