How can I bind a specific key to different launch configurations in Eclipse? - eclipse

I have several launch configurations for the code I work on.
One configuration (#1) means "run the unit tests for the file in the frontmost editor (i.e. selected resource)". I would really like to be able to always make this be bound to a key.
Another configuration (#2) means "run the server that I am working on (in the frontmost project) so I can test it interactively".
Yet another (#3) means "run some automated acceptance tests against the server".
I always want to have #1 close at hand, easy to run from a single keystroke. Plus, I want to be able to run #2, watch it start up in a console, and when it's ready (since it's not entirely trivial to automate this) hit the key for #3.
This is possibly similar to the question for binding a key to a specific build configuration, but the answers there look very specific to builds, and as I'm using PyDev, I don't have a "build" step at all.
Also, given that I'm using PyDev, an answer in the form of a pyedit_* script would be appreciated just as much as a "native" answer for eclipse.

Maybe Eclipse Runner plugin could make it easier for someone to handle launch configurations. It doesn't allow to assign key binding to launch configurations currently but I opened a feature request Key bindings for launch configurations

Not to a specific launch Configuration , but you can bind a key to run Last run Configuration ,
Windows->preferences->General->Keys->Run last launched external Tool

You can do the following (for #2 and #3), after having those run configurations created:
Go to Run > Run Configuration > Select the run configuration you want > Common > Display in Favorites Menu > Check Run/Debug. This will make it always appear as the first on the menu.
This will make it appear in the menu in Run > History and Run > Debug History, then, you can access it through Alt+R, T, 1 (and 2 and 3) to run your configurations or Alt+R, H, 1 (and 2 and 3) to debug.
And for #1, as Piotr Dobrogost said, you can just use Ctrl+F9 in the current editor and choose which test-cases you want to run (if you select a unit-test -- usually with Ctrl+Shift+Up or Ctrl+Shift+Down -- it'll be pre-selected for you) -- then, if you configured to always relaunch the last launch, as explained in http://www.pydev.org/manual_101_run.html, you can use Ctrl+F11 to relaunch the last launch.

Related

Is there a macro facility for NetBeans commands?

I have a very common workflow in NetBeans:
Shutdown a Tomcat server
Do a clean and build
Launch a J2EE application (and Tomcat) in DEBUG mode.
Theree are a number of variants to this I use, but basically I'd like to be able to click on one button and have all this done in sequence -- which also requires that the previous operation complete before the next operation is initiated.
The "record macro" facility doesn't seem to do this -- it seems to be specific to editor commands.
In the Run Menu, there is Repeat option (Ctrl-F11), I guess that is close to what you want.

Eclipse: what's the good way of launching an application with arguments?

I've been using Eclipse for years, and I'm quite familiar with it, but this still bothers me, I want to know if I'm missing something.
Suppose I want to run my runnable MyClass.java from the IDE. The standard way is, with the source selected
Right Click -> Run-As -> Java Application
or, equivalently through the Menu -> Run -> Run-As -> Java Application
Now, suppose I want to run it with some arguments, or some special setting (output redirection, alternate JRE, etc). In Eclipse, that's managed via Launch Configurations. In my case, I'd do Right Click -> Run-As -> Run Configurations... to access the stored Configurations, find the one (perhaps several) corresponding to MyClass, edit the settings and run it.
Now, here's my little problem. If I wanted to run MyClass with arguments straight away... it seems that I need to go through this two-step procedure: 1) run it for a first time without arguments so that Eclipse (under the hood, rather misteriously) creates a blank Launch Config, and 2) invoke Run As... so that the LaunchConfig editor is opened? It looks cumbersome and unnatural to me.
I'd wish to do "Run as Java, let me edit the configuration first".
Of course, I can go Right Click -> Run-As -> Run Configurations... and create manually the configuration, but this is not ideal : Eclipse does not autofill the Java source from which I triggered the creation, nor even can guess the application type (Java in this case), I must do this myself (that's why I resign to the 2-step procedure mentioned above, it's more direct).
Notice that this is not specific to running Java apps.
Am I missing something?
You may add variables to the Run config and prompt the user to enter the value when you run the application.
I have attached an example -
Next time when you run the application it will directly prompt you to enter the value.
Hope that helps !

Can a "run configuration" ensure another app is running?

When working with Mule ESB, we need to have (in our case) ActiveMQ running (in a terminal) or it won't work. That's fine, but I sometimes forget to start ActiveMQ, which caused me to wonder...
Can I somehow explain to my "Run configuration" that it should start an external program in conjunction with starting the run|debug session? And if so, can it be configured to only start it if it's not already running?
I am not sure whether you can run the external application using your project run configurations. But from mule studio you can start the external application using Run--> External tools. Refer the below kink for details
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Ftasks%2Ftasks-exttools-running.htm
Eclipse CDT contains a useful type of launch configuration called a Launch Group. With a launch group you can set up different launches to run and what order. You can optionally add delays between launches (to allow for your service to start) or wait for a set up launch to terminate before running the next one.
To install the launch groups you can add "C/C++ Development Tools" to your installation.
Once installed, you should have a new launch type called a launch group.
Here is an example of one that may address your first question:
Launch Group Example
As my example shows, you don't need to have any CDT launches to be able to use Launch Groups.
As for your second part. This is in active development. Eclipse EASE is adding full scriptability to Eclipse and as it turns out I have just written a post about adding launching capabilities to the scripting. You can follow that work on bugzilla: Bug 478397

Convenient way to run eclipse plugin

I have recently started developing an Eclipse plugin (which is basic stuff for now) and I am struggling with "default" way to run Eclipse plugin ("Run as Eclipse application").
The Eclipse is starting another instance with my plugin already installed in it (this is default behaviour).
The problem is that when I want to re-run my plugin project and I press "run" button again (or Ctrl + F11) (and the another Eclipse instance still running) I get following message:
"Could not launch the application because the associated workspace is currently in use by another Eclipse application".
The error makes sense, and when I close "testing" Eclipse instance I am able to run my plugin again.
The question is - "is it normal routine for plugin development?". Maybe I am missing something, e.g. special arguments for Eclipse?
This seems all pretty normal. The error message is since the run configuration is specifing a workspace and when you start a second instance using the same workspace it is locked and considered in use.
What I usually do when testing a plugin is to create a run configuration (click "Run...") where I disable all the plugins I wont need when testing. This makes sure that the test starts up a couple of seconds quicker. Make sure you save that run configuration as a *.launch file aswell, that makes it quicker to test the next time. Or it can be used to share the configuration.
There's a lot you can configure in the run configuration, such as eclipse arguments, vm argument, if you want environment variables set, etc. So be sure to experiment a little.
In your run configuration. Main tab->Workspace Data ->Location text box add this:
${workspace_loc}/../runtime-EclipseApplication${current_date:yyyyMMdd_HHmmss}
Note the suffix ${current_date:yyyyMMdd_HHmmss} by this every time you launch your application new workspace will be created. So you will not get any error message saying workspace is locked.
But be careful as the folder .metadata will be different for different instances as their work-spaces are different. Thus preferences stored/retrieved by different instances are NOT in sync.
You are probably missing one important point: Eclipse supports the Java hot code replacement. Therefore in many cases you can modify your Java code while your application Eclipse instance is running, save the code and continue without restarting.
If hot code replacement is not possible, Eclipse will tell you, so you always know whether the editing changes are applied to the running instance.
This works best with more recent versions of the JVM, so consider upgrading to the latest Java 7 version, even if you write code to be compliant with Java 1.5 or 6.

Eclipse/PyDev/GAE: How do I add command line options to my Run As->PyDev Google App Run

I am using Eclipse/PyDev to develop a Google App Engine project called GAEServer. One of my common operations is to right click on the project and select Debug As->1 PyDev: Google App Run. Which kicks of a debug session for my application.
I would like to change the command line arguments executed when this command is invoked (to relocate where GAE local server looks for its database). This requires me to add arguments to the executed command.
If I select from the main menu: Run->Debug Configurations... there is an expandable item called PyDev Google App Run which contains a list of items:
PyDev Google App Run
GAEServer GAEServer
GAEServer GAEServer (1)
GAEServer GAEServer (2)
...
At the moment I have 19 of these which is a little surprising. If I select the first one then there is a tab where you appear to be able to add arguments (x)= Arguments but if I edit this and try to debug as again, it does not invoke GAE with the additional options, instead it creates another GAEServer GAEServer (n) with the default settings.
It may be that I have set up my project in some odd way, that I'm not understanding how this is supposed to work or that I have uncovered a bug. Can anyone help me figure out which?
Thanks in advance
Jules
The run as will really create a new run configuration... Just erase the bunch of configurations you have, run it once and edit that one.
Later ( if you followed the suggestion on http://pydev.org/manual_101_run.html ), you should be able to Ctrl+F11 to rerun the last launch done (or choose it from the menu: run > run history > previous launches: can be accessed through Alt+R, T, number of config).