Eclipse ant任务“sshexec”,如何在控制台中打印远程消息?
我在eclipse中开发了一个插件,这个插件应该调用ant任务sshexec。问题是如何在eclipse控制台中打印远程消息 我的代码如下:Eclipse ant任务“sshexec”,如何在控制台中打印远程消息?,eclipse,ant,eclipse-plugin,console,Eclipse,Ant,Eclipse Plugin,Console,我在eclipse中开发了一个插件,这个插件应该调用ant任务sshexec。问题是如何在eclipse控制台中打印远程消息 我的代码如下: Project p = new Project(); MessageConsole console = new MessageConsole("building", null); IConsoleManager manager = (IConsoleManager) ConsolePlugin.getDefault().getConsoleMa
Project p = new Project();
MessageConsole console = new MessageConsole("building", null);
IConsoleManager manager = (IConsoleManager) ConsolePlugin.getDefault().getConsoleManager();
manager.addConsoles(new IConsole[] { console });
manager.showConsoleView(console);
MessageConsoleStream cs = console.newMessageStream();
cs.setColor(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));
PrintStream ps = new PrintStream(cs);
final DefaultLogger consoleLogger = new DefaultLogger();
consoleLogger.setErrorPrintStream(ps);
consoleLogger.setOutputPrintStream(ps);
consoleLogger.setMessageOutputLevel(Project.MSG_INFO);
p.init();
p.addBuildListener(consoleLogger);
ProjectHelper helper = ProjectHelper.getProjectHelper();
helper.parse(p, buildFile);
p.executeTarget(p.getDefaultTarget());
当执行sshexec目标进行编译时,我总是得到如下输出消息
[sshexec] cd ...; ls ...; ....
它只打印我编写的命令,但远程计算机的编译消息无法在控制台中打印。一旦编译过程中出现错误,它仍然成功地返回build。
如何在控制台中打印远程消息并获得错误结果?好的,我用另一种方法解决这个问题。
我使用process=Runtime.getRuntime.execjava-jar ant-launcher.jar-f build.xml来执行ant任务。但是请记住启动两个线程来读取process.getInputStream和process.getErrorStream。好的,我只是用另一种方法来解决这个问题。 我使用process=Runtime.getRuntime.execjava-jar ant-launcher.jar-f build.xml来执行ant任务。但是记住启动两个线程来读取process.getInputStream和process.getErrorStream