How can i integrate Wpilibj(2) into a gradle project?

I’m trying to make an offseason Java library to simplify some of the processes that are done during competition season, how can I integrate Wpilib into my project. More precisely i’m wondering how I can import things from wpilibj2, I’ve figured out how I can add wpi.java.deps.wpilib() as a dependency and wpi.java.vendor.java(), but I still can’t import things like subsystems and commands from wpilib2. For reference, here is my current build.gradle file:

plugins {
    id 'java'
    id 'java-library'    
    id 'edu.wpi.first.GradleRIO' version '2023.2.1'
}

sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11

repositories {
    mavenCentral()
}

dependencies {
    implementation wpi.java.deps.wpilib()
    implementation wpi.java.vendor.java()
}

It would also be helpful if someone could explain to me how I can import vendor dependencies from here, such as the CTRE or Photonlib vendor dependencies.

I’m new to using Gradle and Maven in general so any advice even unrelated to the topic would be helpful.

Have you created a vendordeps folder with the WPILibNewCommands.json vendordep in it, like a regular robot project?

Where should the folder be placed, do I need to change anything inside of my build.gradle or settings.gradle?

A vendordeps/ folder in the project root.
The wpi.java.vendor.java() line loads dependencies from that folder.

I tried that, still cant import anything in wpilibj2

Here is what the project currently looks like.
image_2023-05-31_163733191

Where’s the root build.gradle?
The vendordeps folder needs to be in the same directory as the build.gradle has the wpi.java.vendor.java() line.

So what I was initially doing was actually correct, I initially had them in the same directory but I had moved it in my earlier screenshot but what actually fixed the issue was far simpler. Reloading all Gradle projects :upside_down_face:. It only took me 2 weeks to figure it out of course.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.