Hello,
I’m attempting to build a Network Tables client (in Java) to run on a desktop host, but cannot figure out how to get gradle to load the dependencies. The program is currently reduced to the trivial:
package test5;
import edu.wpi.first.networktables.NetworkTable;
import edu.wpi.first.networktables.NetworkTableInstance;
public class App {
NetworkTable nt;
public String getGreeting() {
return "Hello World!";
}
public static void main(String[] args) {
NetworkTableInstance inst = NetworkTableInstance.getDefault();
System.out.println(new App().getGreeting());
}
}
and my build.gradle:
plugins {
// Apply the application plugin to add support for building a CLI application in Java.
id ‘application’
id “edu.wpi.first.GradleRIO” version “2022.4.1”
}
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}
dependencies {
implementation wpi.java.deps.wpilib()
implementation wpi.java.vendor.java()
// Use JUnit Jupiter for testing.
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.2'
// This dependency is used by the application.
implementation 'com.google.guava:guava:30.1.1-jre'
}
application {
// Define the main class for the application.
mainClass = ‘test5.App’
}
tasks.named(‘test’) {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}
The result:
- VS Code flags th imports as errors
- VS Code does not recognize the Network Table data types
- ./gradle build runs with out complaint (seems strange…)
- Attempting to run the program fails (hardly surprising) with:
Exception in thread “main” java.lang.Error: Unresolved compilation problems:
NetworkTableInstance cannot be resolved to a type
NetworkTableInstance cannot be resolved
I’m assuming that my build.gradle is not correctly resolving the dependencies. Any suggestions?