Search in sources :

Example 1 with ToolLoader

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();
}
Also used : ToolFactory(org.eclipse.ceylon.common.tool.ToolFactory) ArrayList(java.util.ArrayList) ToolLoader(org.eclipse.ceylon.common.tool.ToolLoader) NonFatalToolMessage(org.eclipse.ceylon.common.tool.NonFatalToolMessage) IOException(java.io.IOException) Tool(org.eclipse.ceylon.common.tool.Tool) CeylonBaseTool(org.eclipse.ceylon.common.tool.CeylonBaseTool)

Example 2 with ToolLoader

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;
}
Also used : ToolFactory(org.eclipse.ceylon.common.tool.ToolFactory) ToolLoader(org.eclipse.ceylon.common.tool.ToolLoader) NonFatalToolMessage(org.eclipse.ceylon.common.tool.NonFatalToolMessage) IOException(java.io.IOException) Tool(org.eclipse.ceylon.common.tool.Tool) CeylonBaseTool(org.eclipse.ceylon.common.tool.CeylonBaseTool)

Example 3 with ToolLoader

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();
}
Also used : ToolLoader(org.eclipse.ceylon.common.tool.ToolLoader)

Aggregations

ToolLoader (org.eclipse.ceylon.common.tool.ToolLoader)3 IOException (java.io.IOException)2 CeylonBaseTool (org.eclipse.ceylon.common.tool.CeylonBaseTool)2 NonFatalToolMessage (org.eclipse.ceylon.common.tool.NonFatalToolMessage)2 Tool (org.eclipse.ceylon.common.tool.Tool)2 ToolFactory (org.eclipse.ceylon.common.tool.ToolFactory)2 ArrayList (java.util.ArrayList)1