using eclipse launch configurations to deploy FRC robot code faster in eclipse

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:

  1. Select the project in your workspace.
  2. Click “Run”
  3. Mouse over “Run As”
  4. 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:

  1. Run a build the “long way”
  2. “Run” > “External Tools” > “External Tools Configuration…”
  3. 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.)
  4. Change the name to one that you like. For example, “2018 Robot”
  5. Click the “Common” tab
  6. Click “Display in Favorites Menu”
  7. 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.

  1. Open the Eclipse preferences. (The Eclipse menu on a Mac and the Window menu otherwise)
  2. “General” > “Editor” > “Keys”
  3. Type “Run last” in the filter to find the matching entry
  4. Setup a binding. I chose command F + command R. (The beginning of spelling out FRC), but you can choose anything.
  5. 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.