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

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).

Related

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

How to autorestart node.js application in Eclipse/Aptana Studio on source change while development?

This is not a question really, but a guide in some sense.
I did not find a better place to post it. I hope someone finds this helpful.
I was fed up with stopping and starting node.js application to pick up code changes.
So I wanted a solution without too much hassle and installation of additional plug-ins, packages or anything else. The pure solution using standard Aptana Studio 3.4 (Eclipse) features on Windows 8.1 x64 as follows:
Right-click on your project in Project Explorer > Properties > Builders
New... > Program > OK
Name: Terminate existing node.js process(es)
Location: C:\Windows\System32\taskkill.exe (${env_var:SystemRoot}\System32\taskkill.exe did not work for me, it might for you)
Working Directory: Browse Workspace... > select your project > OK
Arguments: /IM node.exe /F
Switch to Build Options tab and tick During auto builds, untick Launch in background > OK
Create another builder: New... > Program > OK
Name: Start <your-project-name>
Location: C:\Program Files\nodejs\node.exe (you can try ${env_var:ProgramFiles}\nodejs\node.exe as well)
Working directory: same as point #5
Arguments: app.js (or any other file for application entry point)
Switch to Build Options tab and tick both During auto builds and Launch in background > OK
Turn on project autobuild: Window > Preferences > General > Workspace, tick Build automatically > OK
Change default build order: Window > Preferences > General > Workspace > Build Order, untick Use default build order and remove all projects except your node.js project > OK
Restart Aptana/Eclipse (There are bugs, so sometimes preference changes are just not saved and get lost. You have to double-check.)
So if you have not changed too many default preferences in Aptana Studio 3/Eclipse by saving a file within your project should trigger its builders. First builder will kill existing instance to overcome 'port already in use' exception and start an application again. Console tab related to that process should pop up.
This works perfectly for me developing one node.js project at a time and medium size application restarts instantly. There is still space for improvements, e.g. killing just that particular instance instead of all. Suggestions are welcome (except the ones to install Nodeclipse or node.js packages, etc.)!
I hope this easy to do solution will help someone. Also I hope Aptana Studio 3 will start supporting node.js type of projects/server natively very soon.
You can use nodemon to restart node application whenever the code changes. Have a look https://github.com/remy/nodemon/
Welcome to Nodeclipse. Your solution is added to Nodeclipse Help Run page,
please edit. That is to answer "a better place to post it".
Alternatively, this question should have been broken into problem and solution part to fit stackoverflow.com Q&A format. Also constrains (like without plugin or Node.js modules) should be said in the topic as some percentage of stackoverflow.com users don't really read whole (especially long) question.
Then my answer is just use Debug View. (Actually it should be named Launch as it is both for Run and Debug) In your favorite perspective: Window -> Show View -> Others.. -> Debug. (In Nodeclipse Node perspective Debug View is visible by default)
Then you can right-click on launched application in Debug View and select Terminate and Relaunch. That is more explicit and allows to run many applications.
I also don't understand why you first say "without plugins" and don't suggest "to install Nodeclipse", but in the end add "I hope Aptana Studio 3 will start supporting". Wouldn't it be another plugin/extension? Nodeclipse as of 0.10 has code completion for base Node.js modules and improved support for black background color themes. Open an issue when ready to discuss/work together. Nodeclipse was started by developers like you who stopped hoping and waiting and just did it. One small piece at a time. Just like you did.
My two cents:
If you want to enable debugging too, you can do it by creating a Standalone V8 VM configuration and launching it with eclipse_remote_control. Steps:
Help > Install new software...
Work with: https://github.com/marook/eclipse-remote-control/raw/master/workspaces/erc/update_site
Select and install the plugin
Important: download eclipse_remote_control_client.jar form https://github.com/marook/eclipse-remote-control/raw/master/workspaces/erc/release/eclipse_remote_control_client_1.3.0.jar and place it where you later know (I placed in /Applications/eclipse/plugins/eclipse_remote_control_client_1.3.0.jar)
Restart eclipse
Once installed the new plugin, create a new debug configuration and project builder:
Run > Debug Configurations... > Right click Standalone V8 VM > New
Name: NodeV8-5858 (or whatever, remember it)
Port: 5858
Apply, Close
Project Explorer > Right click your project > Properties > Builders
New... > Program > Ok
Name: Start NodeV8
Location: /Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Contents/Home/bin/java (find your java location)
Working Directory: Browse Workspace... > select your project > OK
Arguments: -jar /Applications/eclipse/plugins/eclipse_remote_control_client_1.3.0.jar execute_command NodeV8-5858 DEBUG (replace with your .jar location and the name you selected in step 2)
Ok (then make sure that "Start NodeV8" remains the last entry in the list)
Select "Start " and click Edit...
Arguments: --debug-brk=5858 --harmony app.js (or any other file for application entry point)
Arguments: --debug=5858 --harmony app.js (if you don't want it to
wait at the beggining)
Ok and enjoy!
If you are working with mac, then to kill all node process you can create an script killallnode.sh with the following code:
#!/bin/bash
killall node
Place it somewhere you know and fill it in the location field for step 4.

Google App Engine Eclipse Launch Local Host Multiple App Conflict?

I have two GAE projects created through pydev in eclipse 4.2 (windows 7) and the first one I had no issues running the localhost:8080 but when I created a second project, I duplicated the Run Configuration for local run adn just changed the project name to the new one.
However- when I run that config the inital HelloWorld project shows up[ in my browser, I tried completely removing the first project, but then it just ocmplains it cant fint app.yaml in the old directory (because the old directory isnt where it was).
So clearly I'm missing some setting in the launch procedure where it sets the root path.
The run config is a PyDeb Google App Run, main module points to
C:\program files (x86)\google\google_appengine\dev_appserver.py
And the arguments are
${project_loc}\src
Everything else is on the default settings.
Any help would be greatly appreciated as pushing to Google (which works fine for both) for every little debug iteration is driving me a bit crazy.
Thanks!
*EDIT: Forgot to mention I have already tried to delete all runconfigs and remake.
Have you tried Run as : PyDev Google App Engine Run, to create a new runconfig?
Turns out I'm just a bit silly. In eclipse, I wasn't properly turning off (not sure on the correct term there) the LocalHost for the first project before starting the second. To fix, I needed to go Into eclipses console window, and select "display selected console" and choose the project I wanted to stop and hit the stop all button. Then it runs fine.
Hope this helps someone in the future, that is as determined as me that "It can't be my fault".
Cheers.

How can I bind a specific key to different launch configurations in 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.