在 Eclipse 中的 Java 项目中,我们有几个构建配置,因为我们有一个引擎,当运行时,它会根据它获取的参数为特定项目构建安装 jar,因此每个构建配置运行相同的构建并使用不同的参数来构建安装对于一个特定的项目。
目前,我必须转到工具栏中的 Run Configuration 下拉按钮来启动引擎,并且我需要从列表中选择构建配置才能使用所需的参数运行(或调试)引擎。
如果按钮运行而不是从下拉菜单中选择,我已将 Eclipse 配置为运行最后一次运行执行,但我真的希望在工具栏中为每个构建配置(或我最喜欢的配置)设置单独的按钮,并且更好的是,有一个键盘快捷键来运行(或调试)特定的构建配置。那可能吗?
最佳答案
我能够根据 splintor 的线程将特定步骤放在一起并使其正常工作(我还在顶部添加了一个循环,该循环可以找到任何具有相同名称的现有启动并终止它,从而有效地使其成为“重新启动”宏):
要将键盘快捷键分配给特定的 Eclipse 启动配置,请执行以下步骤:
可以通过 Help->Software Updates 在 Eclipse 内部:
http://puremvcnotificationviewer.googlecode.com/svn/trunk/PracticallyMacroGoogleUpdateSite
名为“实际宏选项”的部分,展开该部分。
选择它然后点击“添加->”
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.ui.DebugUITools;
try
{
// Terminate process if it already exists from a previous launch
org.eclipse.debug.core.ILaunch[] allLaunches=DebugPlugin.getDefault().getLaunchManager().getLaunches();
for (ILaunch l : allLaunches)
{
if (l.getLaunchConfiguration().getName().equals("YOUR CONFIG NAME HERE"))
{
console.write("terminating launch: " );
console.writeln(l.getLaunchConfiguration().getName());
l.terminate();
break;
}
}
org.eclipse.debug.core.ILaunchConfiguration[] allConfigurations=DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations();
for (ILaunchConfiguration config : allConfigurations) {
if (config.getName().equals("YOUR CONFIG NAME HERE"))
{
DebugUITools.launch(config, "debug");
break;
}
}
} catch (CoreException e) {
e.printStackTrace();
}
finally{}
关于eclipse - 为特定的 Eclipse 构建配置分配键盘快捷键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1437323/