开发者

Eclipse: IProcess output on console [closed]

Closed. This question needs debugging details. It is not currently accepting answers.

Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.

Closed 7 years ago.

Improve this question

I have a problem when I try to write to the console.

In the plugin project i have developed a custom build which could be called through the menus using commands i developed. Originally the build was called inside the launch method of my class which implements ILaunchConfigurationDelegate.

...
        String[] commandLine = (String[]) compilerArgs.toArray(new String[compilerArgs.size()]);
        Process compilerProcess = DebugPlugin.exec(commandLine, new File(project.getLocation().toString()));

        @SuppressWarnings("rawtypes")
        Map processAttributes = new HashMap();
        processAttributes.put(IProcess.ATTR_PROCESS_TYPE, "XVR");
        IProcess dbgProcess = DebugPlugin.newProcess(launch, compilerProcess, "XVR Compiler", processAttributes);

        try {
            compilerProcess.waitFor();
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        if(compilerProcess.exitValue() != 0) return false;
        launch.removeProcess(dbgProcess); 

When a build was performed, the output of the process is printed on the console and parsed with a class which implements IConsoleLineTracker to highlights the errors.

I moved the build method outside the class which implements ILaunchConfigurationDelegate and the console is not printed anymore. The only difference between the two cases is how the object iLaunch is provided. The new build method follows

   ...
String[] commandLine = (String[]) compilerArgs.toArray(new String[compilerArgs.size()]);
    Process compilerProcess = DebugPlugin.exec(commandLine, new File(prj.getLocation().toString()));

    ILaunch xvrLaunch = XVRUtils.getXVRLaunch();
    Map<String, String> processAttributes = new HashMap<String, String>();
    processAttributes.put(IProcess.ATTR_PROCESS_TYPE, "XVR");

    IProcess dbgProcess = DebugPlugin.newProcess(xvrLaunch, compilerProcess, "XVR Compiler", processAttributes);

    try {
        compilerProcess.waitFor();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    if(compilerProcess.exitValue() != 0)
        return false;
    xvrLaunch.removeProcess(dbgProcess);

the launch is provided with the following function

public static ILaunch getXVRLaunh(){
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunch[] launches = manager.getLaunches();
    if(launches.length > 0){
        for (ILaunch launch : launches) {
            ILaunchConfiguration conf = launch.getLaunchConfiguration();
            try {
                if(conf.getType().equals(manager.getLaunchConfigurationType(ApplicationLaunchConfigurationDelegate.XVR_LAUNCH_CONFIGU开发者_开发技巧RATION_ID)))
                    return launch;
            } catch (CoreException e) {
                e.printStackTrace();
            }
        }

    }
    ILaunchConfiguration config = getXVRLaunchConfiguration();
    Launch l = new Launch(config, "run, debug", null);
    l.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, null);
    try {
        if (l.getSourceLocator() == null) {
            String type;
            type = config.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, (String)null);

            if (type == null) {
                type = config.getType().getSourceLocatorId();
            }
            if (type != null) {
                IPersistableSourceLocator locator = manager.newSourceLocator(type);
                String memento = config.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String)null);
                if (memento == null) {
                    locator.initializeDefaults(config);
                } else {
                    if(locator instanceof IPersistableSourceLocator2)
                        ((IPersistableSourceLocator2)locator).initializeFromMemento(memento, config);
                    else
                        locator.initializeFromMemento(memento);
                }
                l.setSourceLocator(locator);
            }
        }
    } catch (CoreException e) {
        e.printStackTrace();
    }
    return l;
}

Why the process does not print on the console anymore?

thanks!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜