Using IntelliJ with WPILib 2019

Hello everyone. Currently, I am working on importing the latest build of WPILib into IntelliJ, as I am sure many of you are planning to do as well. I am aware that this is not the formal option and is not the "recommended route", and I am moreso doing this to experiment and find out what the options are.

I have just successfully imported a project into IntelliJ on Linux. I will update this procudure with Windows instructions soon.

Also, if you’re looking for a ready-to-go prebuild project that you can just throw into IntelliJ, you’re free to download this one from our GitHub, and modify .wpilib/wpilib_preferences.json to support your team number in place of 2169.

Linux Instructions

  1. Download the Linux WPILib Build

  2. Extract the folder into a desired location. I put mine in my software installation directory (equivalant of Windows’ Program Files), and this worked quite well.

  3. Open the file and navigate to the "utility" folder, and run the "wpilibutility" executable file. Be sure to verify that it has execution privileges. Once it is open, select "Start New Project Generator"

  4. Follow the instructions on the UI to create your empty project. I recommend selecting Template for the project, TimedRobot for the project base, and your Workspace folder for the project location. If you leave the "create new folder" option, there is no need to create a new folder for the project, as WPILib will do that for you.

  5. Once the project is generated, we are going to go ahead and build the project through the command line to resolve the dependencies. IntelliJ has a hard time with this if you don’t build the project first. To do this, go ahead and launch a terminal window, navigate into the project, and execute the command “./gradlew build”. This will download the dependencies and get your project ready to go. Once this is done, go ahead and launch IntelliJ. Close any projects you have open to get to the small dialoge box that has the "Import Project" option.

  6. Press "Import Project" and navigate to the folder generated by WPILib. Click "Next"

  7. Select "Import Project from External Model" and select "Gradle". Click "Next"

  8. Make sure that the “Use Auto-Import” box is checked, and select the “Use ‘Gradle Wrapper’ task configuration”. This will allow the project to grab the version of gradle provided by IntelliJ. Then select whatever JDK you have set up to run JDK11. If you do not have that, you need to install it before you continue. If you have all of this completed, go ahead and click “Finished”

  9. Give the project some time to build, and when it is completed, you are good to go. You’ll need to set up some configurations to run the code, and I’ll go through this process as well.

  10. Select the "Add Configuration" button in the top right corner.

  11. Select the "+" button in the top left of the dialoge box, and select Gradle.

  12. For "Gradle Project" press the folder button on the right of the text box and select your project.

  13. For “Tasks” enter “deploy”. Once you have that, you’re good to go.

2 Likes

We are in a similar situation. We have the latest build setup with IntelliJ and Kotlin. We plan to periodically open the project in VSCode to update vendor dependencies through the GUI, but every Gradle feature works perfectly in IntelliJ (as it did in 2018) for smooth development.

1 Like

Yup, this is also how I’m doing it.

I took the 2019 GradleRIO release, removed anything in the build.gradle referencing VSCode / system level preferences, and manually added my vendor dependencies.

We’re doing it this way as well. I don’t see the point of the JSON dependency system outside of automation in VSCode. Here’s an example of how we did this. Just make sure to include the maven repositories of whatever vendor you’re using.

2 Likes

I’ll probably just work with the vendor . json files, as from what I’m told they can get rather large. But I may look into automating how they’re downloaded in the build.gradle.

Nice tutorial. Thanks!

I’ve been testing IntelliJ with the beta code, and GradleRIO works flawlessly. The vendor JSON files should work fine with an IntelliJ workflow.

I’ve written up some notes: