0

我正在为 Eclipse 开发一个小插件,以编程方式(重新)启动 LaunchConfigurations。

我可以启动配置,但我想增强以下代码以在启动之前首先关闭所有正在运行的具有给定名称的配置。

public void restartLaunchConfiguration(String configurationName) throws Exception {
    final ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();             

    for(final ILaunchConfiguration cfg : manager.getLaunchConfigurations()){
        final String cfgName = cfg.getName();

        if(!configurationName.equals(cfgName)) continue;
        cfg.launch("debug", null);  

        break;
    }
}

如何获得所有正在运行的配置?

如何停止正在运行的配置?

4

1 回答 1

6

我无法对此进行测试,但您可以获取所有正在使用的 ILaunchConfigurations 的列表。

ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
ILaunch[] runningLaunches = manager.getLaunches();

然后,ILaunch 具有您可以使用的方法,例如 .getProcesses()。从那里您可以终止与启动相关的进程。

于 2011-02-16T16:02:35.980 回答