use of org.eclipse.ceylon.common.tool.ToolLoader 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.ToolLoader 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;
}
use of org.eclipse.ceylon.common.tool.ToolLoader in project ceylon by eclipse.
the class SubtoolVisitor method accept.
protected void accept(ToolModel<?> parent, SubtoolModel<?> subtoolModel) {
ancestors.push(new ToolModelAndSubtoolModel(parent, subtoolModel));
ToolLoader subtoolLoader = subtoolModel.getToolLoader();
for (String toolName : subtoolLoader.getToolNames()) {
ToolModel<?> model = subtoolLoader.loadToolModel(toolName);
visit(model, subtoolModel);
if (model.getSubtoolModel() != null) {
accept(model, model.getSubtoolModel());
}
}
ancestors.pop();
}
Aggregations