FRC using VS Code and Eclipse together for WPILIb programming

I’ve tried using VS Code. I enjoy uisng it for things like JavaScript, Python and Markdown. With Java, I feel like I’m hitting my head against the wall. I’m too used to a “full powered IDE” so an editor makes me aware of what I rely on. (I tried IntelliJ as well and that felt productive easily.)

The nice thing is that 2019 FRC projects are “just” gradle projects. So there is no reason I can’t use both VS Code and Eclipse together! VS Code for creation a new project and deploying. Eclipse for virtually everything else.

Creating a project from VS Code

Just like when I was first trying VS Code, creating a WPILib project is easy. Just like the screensteps say!

  1. Click “W” icon in top right
  2. Choose template for a new project
  3. Choose Java
  4. Choose command based project (or whatever you prefer)
  5. Enter directory – this can be the same directory for all projects since they each get their own folder.
  6. Enter project name
  7. Enter team number
  8. Click generate project

Importing the Project in Eclipse

Since the project is just a Gradle project, you can import it into Eclipse

  • File > Import
  • Existing Gradle Project
  • Enter the root directory that the project is in. For example suppose your directory was “frc” and project name was “NewRobotProject”. Then the root directory would be “…/git/frc/NewRobotProject”. In other words, the directory with your build.gradle file.
  • Click Finish
  • Wait a minute or two. The bottom right will say “Synching Gradle project workspace”. It will show the percentage as the import occurs.

Editing in Multiple IDEs/Editors

At this point, you have a normal Eclipse project.   All the features and keyboard shortcuts from Eclipse are there. For example, open a command and click on the super class name (Command.) Press F3 and it takes you right to the source code. Eclipse knows where it is because Gradle told it.

If you edit in multiple tools, you just need to know how to refresh from disk in each one.

In Eclipse, right click the project and choose refresh. (Or click F5)

In VS Code,mouse over the project name and choose the circle refresh arrow.

Deploying the Project from VS Code

Since the VS Code and Eclipse projects are pointing at the same directory, you only have one project. This means you can simply:

  1. Click “W” icon in top right
  2. Choose “Deploy Robot Code” from the menu

 

Leave a Reply

Your email address will not be published. Required fields are marked *