Shuffleboard Custom Plugin Shenanigans

A couple of students on my team have expressed an interest in writing their own Shuffleboard plugins/widgets.

Normally, I’d point them towards this part of the docs and let them go wild – but in going through them myself to see if there are any bits that I’d need to spend a little time clarifying, I’ve run into an issue.

I’ve been following the docs carefully, which seem to have been updated using this post as a base.

I’ve gotten the repository on my local machine just fine, but VSCode seems convinced that the edu.first imports don’t exist.

Here’s the snippet in question,


package com.example.simplewidget;

import edu.wpi.first.shuffleboard.api.data.DataType;
import edu.wpi.first.shuffleboard.api.plugin.Description;
import edu.wpi.first.shuffleboard.api.plugin.Plugin;
import edu.wpi.first.shuffleboard.api.widget.ComponentType;
import edu.wpi.first.shuffleboard.api.widget.WidgetType;

import com.example.simplewidget.data.type.PointType;
import com.example.simplewidget.widget.SimplePointWidget;

import java.util.List;
import java.util.Map;

/**
 * An example plugin that provides a custom data type (a 2D point) and a simple widget for viewing such data.
 */
@Description(
    group = "com.example",
    name = "SimpleWidgetExample",
    version = "2019.1.1",
    summary = "An example plugin that provides a simple data type and a widget for viewing it"
)
public final class SimpleWidgetExamplePlugin extends Plugin {

  @Override
  public List<DataType> getDataTypes() {
    return List.of(
        PointType.Instance
    );
  }

  @Override
  public List<ComponentType> getComponents() {
    return List.of(
        WidgetType.forAnnotatedWidget(SimplePointWidget.class)
    );
  }

  @Override
  public Map<DataType, ComponentType> getDefaultComponents() {
    return Map.of(
        PointType.Instance, WidgetType.forAnnotatedWidget(SimplePointWidget.class)
    );
  }
}

Hovering over the first errors in the file, VSCode insists that “The import edu.wpi cannot be resolved”. That suggests it’s just an issue of making sure the project knows where to look for the file – so I tried to do some digging in the API docs only to find that the packages the repo uses… don’t seem to be a part of wpilib at present??

I figure either,

  • I’m missing something silly and/or am blind
  • Shuffleboard hasn’t been updated since all the cool kids are using Elastic now, or so I’ve been told.

… so now I’m here. Anyone have any ideas? Thanks in advance for any info!

You didn’t say how you created your project. An easy way to add libraries in VSCode is to hit the plus sign in the Referenced Libraries area. That adds to the settings.json file.
image

Thanks for the reply!


I created the project by cloning the git repository linked in the docs.

As far as adding external libraries goes, though, do you know which library I’d need to add? I’ve used the method you describe before in plenty of personal projects (for most small projects, I’ll just download the .jar files directly from Maven/wherever they’re hosted), but in this case, I’m not sure which libraries VSCode is expecting to find (and not finding).

I searched the API docs for the classes referenced in the example code, namely edu.wpi.first.shuffleboard.api.* (and the classes/members therein), but as far as the docs are concerned, those don’t seem to exist (see attached). Am I just looking in the wrong place?

Those are the API docs from WPILib. The shuffleboard plugin API is part of shuffleboard. You can get those javadocs here: JFrog

1 Like

THIS Shuffleboard.jar would seem to be what you are asking about. The source code in the repository seems to be newer than the jar. I thought I saw ShuffleBoard was slated for retirement; if true your efforts may be better directed elsewhere.

1 Like

I’m not sure why VS Code isn’t finding the api, it should be pulling it from project, and building it locally if it hasn’t been built before. shuffleboard/example-plugins/custom-data-and-widget/custom-data-and-widget.gradle at 68a14d7def8de2dc2bb77b10cf31e1b00a1df15e · wpilibsuite/shuffleboard · GitHub which references here: shuffleboard/api/src/main/java/edu/wpi/first/shuffleboard/api at main · wpilibsuite/shuffleboard · GitHub Maybe it has to do with the custom build.gradle names that shuffleboard is using that’s confusing the VS Code java plugin. It does look to work in IntelliJ for me.

1 Like