Vendordep template

Has anyone played around with the vendor-template on wpilib. I’m looking at experimenting creating our own team library. I’m not sure where to start to make a Java library. I have the template loaded, but where do I start making files.

The vendor template is made for vendors to make drivers for their hardware projects. It’s done in a way that’s not conducive for a team to use for their own libraries.

We currently don’t have a recommendation for how to do this properly.

Okay. Any way to create my own code library and use wpilib functions. I have a blank Java library created but want to import wpilib functionality into it.

It is still possible, though. Definitely not the best choice, though, it took me a lot of work to get it usable

Our team made a vendordep (albeit in c++) here. We host the maven repository and the vendordep json using GitHub pages.

You might want to start by deleting the directories that contain the driver and native code since you are a java team and reading the

Our team recently spent some time creating a common Java library and got good results. We referenced our common library from other projects by adding it as a Git submodule in the root directory of the outer project. In order for the build to work we needed to add a couple of lines to build.gradle and settings.gradle of the outer project according to Gradle’s docs on multi-project builds. Here’s our common library as well as an external project that depends on it for reference.

Creating the common library project itself was kind of a hassle because we didn’t use any of WPILib’s project templates. Instead, we used the gradle init command to make a fresh Java library project and manually added the GradleRIO plugin and the WPILib dependency to the build.gradle. It took quite a bit of troubleshooting with Gradle scripts in order to get the build working, but I don’t know if a better method exists.

I have one solution in mind (mind you, we’re a C++ team and gradle is not my strong suit). What if you gradle init a new gradle project, add the wpilib dependencies to the project (using implementation x instead of vendordeps) and then host the maven packaged build output and use that as a dependency?

In other words, have github actions build your common library and host the maven output on github pages. Then, add the url to the maven repository in your build.gradle under the repositories structure and then add an implementation yourLibrary in the dependencies struct.

I’m assuming you mean to add these implementations to a gradle java library


would I have to have the WPINew Commands vendor dep in this library.

I tried without and the following after blank build

Could not get unknown property wpi for the object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultdependencyHandler

Should I add other dependencies or plugins to the gradle file?

so I added “edu.wpi.first.GradleRIO” version “2023.4.3” to the plugins.

Successful build, but I don’t have access to WPILIB methods in my Java Library file. Or at least auto complete isn’t acquiring them.

If you’ll push your code to a GitHub repo, I’ll try to play with it with you. I’m actually very curious about how we can get this to work.

There’s an example of adding java dependencies to the build here

Essentially, the strings after the keyword implementation indicate a package and its version that you want to depend on. Gradle will then go to search for that package in one of the repositories you provide.

This is the vendordep example of providing a repository

Please Note: You are going to want to build in release mode.

The wpilibRepositories.addAlReleaseRepositories line will add repositories for Gradle to search through (notably here )

So, in theory, once you’ve added your repositories, you can add dependencies like the new commands

dependencies {
    implementation 'edu.wpi.first.wpilibNewCommands:wpilibNewCommands-java:2023+'

And gradle will do the java equivalant of downloading and linking the dependency which it will find here. Notice how the path matches the package name and version

Okay started with a blank library.

No code yet. Just added the lines in the previous response to my gradle file.

It won’t build in release mode or regular mode.

error at line 20. could not get unknown property wpilibRepositories for project :lib of type org.gradle.api.Project

It’s kinda hard to diagnose issues without the whole project. Could you please push it to GitHub and send me the link?

Sorry about that.

No worries. Thanks!

Looks like you got it.


I suppose the next step is to test whether or not the library works when you try to use it in another project