Import WPILib into a maven project

For next year’s code, I’d like to separate some of our utility code from the main robot code. To do that, I’d like to create a maven project that imports WPILib libraries.

I’d like to do this through a simple maven dependency. Is this easy/possible? I’d rather use maven than gradle in this situation but if maven is too difficult, I might move to gradle. However, if I moved to gradle I don’t want to have a robot project, I just want to create a library to use in another project that has robot code.

The wpilib dependencies are just maven dependencies, so they should be trivially usable through maven. However, you would have to handle versioning yourself. If you use gradle and GradleRIO, GradleRIO can handle wpilib versioning for you, along with adding easy access to our maven repo. GradleRIO does not have to be used for a robot project, and can in fact be trivially used to just create a library. If you take out the entire deploy block and remove the jar configuration that is in the template, you’ll be left with just the dependency definitions, which can are just the WPILib dependencies. You can remove the vendor depndencies if you want, or you can keep them.

From there, it’s possible to publish the library, but you would have to look up some tutorials on how to publish, but its pretty simple.

TLDR if you have gradlerio as a gradle plugin, you just can do compile wpi.deps.wpilib() to automatically get the java wpilib dependencies into any project. It doesn’t do anything special otherwise, theyre just normal dependencies anyway.

It sounds like it will be easier to just use gradle then. If there was a simple dependency I could copy and paste into my pom.xml, I’d use maven but I guess I’ll go with gradle for now.


If you really do want to use maven, the maven coordinates are here

with our maven repo located here

It just means you would have to manually handle version updates, and in future years we might change the coordinates and what libraries are needed, causing need for updates. If using GradleRIO, it will always be that one line to add all the wpilib dependencies, so updating for future years would be easier.

Here’s a simple build.gradle that we use for our library.

We use jitpack to publish the library, following the directions from BobTrajectory:

Thank you both for suggesting gradle. I imported the GradleRIO plugin, added some dependencies and it worked just fine without the deploy task. I’ll end up using as well. It’s super useful. Usually I use maven for stuff, but I guess gradle will work just fine as well.

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