I just want to inform the user who uses my plugin about a running process. This process is a running Runtime.exec(cmd) command that runs some tests with maven.
Thank you but thats not quite the thing that I want.
I want to make a console output like the maven plugin, but I don't get how this could be done.
something like this:
[WARNING] [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. [WARNING] [WARNING] For this reason, future Maven versions might no longer support building such malformed projects. [WARNING] [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building messaging 1.3.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ messaging --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 5 resources [INFO] [INFO] --- maven-dependency-plugin:2.7:copy (copy) @ messaging ---
Then you probably need to implement your own toolwindow for displaying the output (or use the existing Messages toolwindow managed by the MessageView service).
In general, if you want to do something exactly like what another plugin does, the best thing you can do is look at the source of the plugin and see how it's implemented.
Calling ConsoleView.attachToProcess() removes the need to do manual input reading. Please do consider looking at the existing code implementing similar functionality.
I am trying to implement a very similar feature these days. I have tried your method there is no output on the console. I dont know why... Have you figured out the problem? Thank you so much!
Thank you so much for your quick reply! The approach really helps me a lot! I think I got the same problem as you that is I was trying to use "Runtime.getRuntime().exec(command, null, envDir)" method to create a new process and print the results on the console and event log. But output are printed after the process finishing running. Did you figure it out as well? Thanks!
What I wanted to do is to run a JUnit Test programmatically and to print the test output in a console.
I achieved this by creating a runconfiguration programmatically with the testclasses in it. The ProgrammRunnerUtil class is able to execute these runcofiguration and prints the output automatically in a console.
In what console? There is no such thing as the user console.
I just want to inform the user who uses my plugin about a running process.
This process is a running Runtime.exec(cmd) command that runs some tests with maven.
Try showing a notification. http://confluence.jetbrains.com/display/IDEADEV/IntelliJ+IDEA+Notifications
Thank you but thats not quite the thing that I want.
I want to make a console output like the maven plugin, but I don't get how this could be done.
something like this:
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building messaging 1.3.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ messaging ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO]
[INFO] --- maven-dependency-plugin:2.7:copy (copy) @ messaging ---
Then you probably need to implement your own toolwindow for displaying the output (or use the existing Messages toolwindow managed by the MessageView service).
In general, if you want to do something exactly like what another plugin does, the best thing you can do is look at the source of the plugin and see how it's implemented.
Now I've got my own ToolWindow and I read in this thread http://devnet.jetbrains.com/message/5224984#5224984
that it is possible to add a ConsoleView to the ToolWindow, but how can this be done?
And how can I access the console later?
I got a solution, but theres a little problem.
I've done it like this:
And the output of the process is printed like this:
The problem is, that the text in the console appears only when the process has stoped running.
Did I miss something?
Calling ConsoleView.attachToProcess() removes the need to do manual input reading. Please do consider looking at the existing code implementing similar functionality.
Thats exactly what I try to do, but I just can't get an output.
Doesn't attachToProcess() work for you?
Here is what I tried:
and the ConsoleView ist attached to the ToolWindow like above.
I used processHandler.notifyTextAvailable() too but the text only appears if the process terminates.
But this approach does not work, I don't get an output in the ConsoleView.
You need to call startNotify() on the process handler before calling attachToProcess().
Thank you very much, now it works.
There is only one porblem left. The output is printed if the process has finished running but I think this is a problem with my ToolWindow.
Hi Markus,
I am trying to implement a very similar feature these days. I have tried your method there is no output on the console. I dont know why... Have you figured out the problem? Thank you so much!
Best,
Luke
Maybe this approach help you a bit more :)
https://devnet.jetbrains.com/message/5284831#5284831
Markus
Thank you so much for your quick reply! The approach really helps me a lot! I think I got the same problem as you that is I was trying to use "Runtime.getRuntime().exec(command, null, envDir)" method to create a new process and print the results on the console and event log. But output are printed after the process finishing running. Did you figure it out as well? Thanks!
What I wanted to do is to run a JUnit Test programmatically and to print the test output in a console.
I achieved this by creating a runconfiguration programmatically with the testclasses in it.
The ProgrammRunnerUtil class is able to execute these runcofiguration and prints the output automatically in a console.
Markus