Building Raspberry Pi code on desktop with VS Code

I’d like to use VS Code + the WPILib extension to build the Raspberry Pi sample code from FRCVision-pi-gen on my computer before uploading it to the Pi. Is this possible?

If I download this sample code and run .\gradlew.bat build in the folder, I get a build failure:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':shadowJar'.
> Could not resolve all dependencies for configuration ':runtimeClasspath'.
   > Could not find :wpiutil:.
     Searched in the following locations:
       - file:/C:/Users/.../Downloads/java-multiCameraServer/java-multiCameraServer/usr/local/frc/java/wpiutil.jar
       - file:/C:/Users/.../Downloads/java-multiCameraServer/java-multiCameraServer/wpiutil.jar
     Required by:
         project :

…and many similar errors for ntcore, cscore, cameraserver, and opencv-344.

How do I properly install these dependencies on the system so that the build works?

I would recommend you download the 2019.2.1 image; the updated example fixes that problem. There is a workaround but you’re better off starting from the latest version.

Thanks! The new image’s sample code seems to work now that the jar files are included. However, I had to use the “Build Robot Code” command from the VS Code extension in order for the correct Java Home setting to be passed to gradle. (Running gradle directly from the terminal tab didn’t work.)