I use Eclipse launch configurations at work and coding at home all the time. It never occurred to me to mention them to the team until last week. A student asked “is there a way to use a keyboard shortcut to deploy.”
Before
For those not familiar with FRC (FIRST Robotics Challenge), the deployment procedure is:
- Select the project in your workspace.
- Click “Run”
- Mouse over “Run As”
- Click “WPILib Java Deploy”
This kicks off the Ant build to do the deploy. Certainly not a terrible process. But when you do this dozens of times and in a rush, it can feel tedious. I think that’s why I never suggested it. At the lab, I ensure the students always drive at the keyboard. So I never have to click four things to deploy and it doesn’t feel tedious. Whereas when I’m coding myself, I feel it and optimize my time/clicking.
Setting up a launch configuration
The first thing I did was show how to set up and favorite a launch configuration.
The initial setup:
- Run a build the “long way”
- “Run” > “External Tools” > “External Tools Configuration…”
- Click build.xml or build.xml (1) or whatever you see in the list. Confirm it is for this year’s robot. (You may find it easier to select all the build.* configurations, delete them and then run one new build.)
- Change the name to one that you like. For example, “2018 Robot”
- Click the “Common” tab
- Click “Display in Favorites Menu”
- Click “Apply”
Then to run it, you just click the triangle next to the launcher and it is stickied first in the list. (Be sure to click the triangle next to the green arrow with the red box. There’s also one without the red box which is used for running Java command line programs.)
This gets us down to two mouse clicks. But it is still not a keyboard shortcut; the initial request.
Keyboard shortcut
I had to look this up, but you can provide a keyboard shortcut. Sort of. I couldn’t figure out how to create a keyboard mapping to a specific run configuration. But that doesn’t matter here. We want to map to the last run configuration.
- Open the Eclipse preferences. (The Eclipse menu on a Mac and the Window menu otherwise)
- “General” > “Editor” > “Keys”
- Type “Run last” in the filter to find the matching entry
- Setup a binding. I chose command F + command R. (The beginning of spelling out FRC), but you can choose anything.
- note that the contest/when is “in windows”. This means the shortcut is avilable when you have any file open. Just when you want when looking at or making robot code better.