[英]A question about eclipse extend tool builder programming
I'd like to implement an eclipse plugin to add an shell script as an external tool builder to a project. 我想实现一个eclipse插件,以将Shell脚本作为外部工具构建器添加到项目中。 After the plugin menu is pressed, the eclipse configuration file .project would add as following.
按下插件菜单后,eclipse配置文件.project将添加如下。 And another configuration file .externalToolBuilders/lstest [Builder].launch would be generated.
然后将生成另一个配置文件.externalToolBuilders / lstest [Builder] .launch。
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value><project>/.externalToolBuilders/lstest [Builder].launch</value>
</dictionary>
</arguments>
</buildCommand>
Currently, I could add to .project using the following code. 目前,我可以使用以下代码添加到.project中。 But How could I generate .externalToolBuilders/lstest [Builder].launch ?
但是,如何生成.externalToolBuilders / lstest [Builder] .launch? Thank you very much.
非常感谢你。
org.eclipse.core.resources.ICommand command = pDesc.newCommand();
command.setBuilderName("org.eclipse.ui.externaltools.ExternalToolBuilder");
Map args = command.getArguments();
args.put("LaunchConfigHandle", "<project>;/.externalToolBuilders/lstest [Builder].launch");
args = conf.getAttributes();
command.setArguments(args);
org.eclipse.core.resources.ICommand command = BuilderUtils.commandFromLaunchConfig(projects[i],conf);
org.eclipse.core.resources.ICommand[] commands = pDesc.getBuildSpec();
org.eclipse.core.resources.ICommand[] nc = new ICommand[commands.length + 1];
System.arraycopy(commands, 0, nc, 1, commands.length);
nc[0] = command;
pDesc.setBuildSpec(nc);
projects[i].setDescription(pDesc, null);
To generate the lstest.launch in the .externalToolBuilders folder. 在.externalToolBuilders文件夹中生成lstest.launch。 Add the following lines before your codes
在代码之前添加以下行
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType antType =
launchManager.getLaunchConfigurationType(IExternalToolConstants.ID_PROGRAM_BUILDER_LAUNCH_CONFIGURATION_TYPE);
ILaunchConfigurationWorkingCopy workingCopy = antType.newInstance(BuilderUtils.getBuilderFolder(project, true), "lstest" );
workingCopy.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, false);
workingCopy.setAttribute(IExternalToolConstants.ATTR_LOCATION, "${project_loc}\\YOUR_SHELL_SCRIPT");
workingCopy.setAttribute(....);
ILaunchConfiguration ilc = workingCopy.doSave();
From menu press on "Run/External tools/External tools configurations..." there you can define ant runners, program runners. 在菜单上按“运行/外部工具/外部工具配置...”,即可定义蚂蚁运行程序,程序运行程序。 On the other hand I am not sure you can attach a shell script directly but to call it from ant.
另一方面,我不确定您是否可以直接附加shell脚本,但可以从ant调用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.