mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
#8626 needs to switch to using reflection to load the robot class. Do that with this PR so it's separate. Also, remove the duplicated main files from the template, and instead fixup vscode to handle this properly.
154 lines
5.1 KiB
Groovy
154 lines
5.1 KiB
Groovy
def fileCheck = { parsedJson, folder ->
|
|
def folderNames = parsedJson.collect { it.foldername }
|
|
def folders = []
|
|
folder.eachDir {
|
|
folders << it.name
|
|
}
|
|
def disjunct = (folders + folderNames) - folders.intersect(folderNames)
|
|
def missingFromFolders = folderNames.intersect(disjunct)
|
|
def missingFromJson = folders.intersect(disjunct)
|
|
|
|
if (!missingFromFolders.empty || !missingFromJson.empty) {
|
|
StringBuilder missingString = new StringBuilder();
|
|
missingString.append("Missing From Folders\n")
|
|
for (String symbol : missingFromFolders) {
|
|
missingString.append(symbol);
|
|
missingString.append('\n');
|
|
}
|
|
missingString.append("\nMissing from JSON\n")
|
|
for (String symbol : missingFromJson) {
|
|
missingString.append(symbol);
|
|
missingString.append('\n');
|
|
}
|
|
throw new GradleException("Found missing items\n" + missingString.toString());
|
|
}
|
|
}
|
|
|
|
def tagList = [
|
|
/* --- Categories --- */
|
|
// On-RIO image processing
|
|
"Vision", "AprilTags",
|
|
// Command-based
|
|
"Commandv2", "Commandv3",
|
|
// Romi
|
|
"Romi",
|
|
// XRP
|
|
"XRP",
|
|
// Extremely simple programs showcasing a single hardware API
|
|
"Hardware",
|
|
// Full robot, with multiple mechanisms
|
|
"Complete Robot",
|
|
// A single mechanism in the Robot class
|
|
"Basic Robot",
|
|
|
|
/* --- Mechanisms --- */
|
|
"Intake", "Flywheel", "Elevator", "Arm", "Differential Drive", "Mecanum Drive",
|
|
"Swerve Drive",
|
|
|
|
/* --- Telemetry --- */
|
|
"SmartDashboard", "Shuffleboard", "Sendable", "DataLog",
|
|
|
|
/* --- Controls --- */
|
|
"Exponential Profile", "PID", "State-Space", "LTVUnicycleController", "Path Following",
|
|
"Trajectory", "SysId", "Simulation", "Trapezoid Profile", "Profiled PID", "Odometry",
|
|
"LQR", "Pose Estimator",
|
|
|
|
/* --- Hardware --- */
|
|
"Analog", "Gyro", "Pneumatics", "I2C", "Duty Cycle", "PDP",
|
|
"AddressableLEDs", "HAL", "Encoder", "Smart Motor Controller", "Digital Input",
|
|
"Digital Output", "Accelerometer", "IMU",
|
|
|
|
/* --- HID --- */
|
|
"Gamepad", "Joystick",
|
|
|
|
/* --- RobotBase --- */
|
|
"Timed", "Timeslice", "RobotBase", "Educational", "OpMode",
|
|
|
|
/* --- Misc --- */
|
|
/* (try to keep this section minimal) */
|
|
"EventLoop", "Mechanism2d", "Preferences", "Skeleton"
|
|
]
|
|
|
|
task checkTemplates(type: Task) {
|
|
doLast {
|
|
def parsedJson = new groovy.json.JsonSlurper().parseText(templateFile.text)
|
|
fileCheck(parsedJson, templateDirectory)
|
|
parsedJson.each {
|
|
assert it.name != null
|
|
assert it.description != null
|
|
assert it.tags != null
|
|
assert it.tags.findAll { !tagList.contains(it) }.empty
|
|
assert it.foldername != null
|
|
assert it.gradlebase != null
|
|
assert it.commandversion != null
|
|
if (it.gradlebase == 'java') {
|
|
assert it.robotclass != null
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
task checkExamples(type: Task) {
|
|
doLast {
|
|
def parsedJson = new groovy.json.JsonSlurper().parseText(exampleFile.text)
|
|
fileCheck(parsedJson, exampleDirectory)
|
|
parsedJson.each {
|
|
assert it.name != null
|
|
assert it.description != null
|
|
assert it.tags != null
|
|
assert it.tags.findAll { !tagList.contains(it) }.empty
|
|
assert it.foldername != null
|
|
assert it.gradlebase != null
|
|
assert it.commandversion != null
|
|
if (it.gradlebase == 'java') {
|
|
assert it.robotclass != null
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
task checkSnippets(type: Task) {
|
|
doLast {
|
|
def parsedJson = new groovy.json.JsonSlurper().parseText(snippetsFile.text)
|
|
fileCheck(parsedJson, snippetsDirectory)
|
|
parsedJson.each {
|
|
assert it.name != null
|
|
assert it.description != null
|
|
assert it.tags != null
|
|
assert it.tags.findAll { !tagList.contains(it) }.empty
|
|
assert it.foldername != null
|
|
assert it.gradlebase != null
|
|
if (it.gradlebase == 'java') {
|
|
assert it.robotclass != null
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
task checkCommands(type: Task) {
|
|
def isCppCommands = project.isCppCommands;
|
|
doLast {
|
|
def parsedJson = new groovy.json.JsonSlurper().parseText(commandFile.text)
|
|
fileCheck(parsedJson, commandDirectory)
|
|
parsedJson.each {
|
|
assert it.name != null
|
|
assert it.description != null
|
|
assert it.tags != null
|
|
assert it.foldername != null
|
|
assert it.replacename != null
|
|
assert it.commandversion != null
|
|
if (isCppCommands) {
|
|
assert it.headers != null
|
|
assert !it.headers.isEmpty()
|
|
assert it.source != null
|
|
assert !it.source.isEmpty()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
check.dependsOn checkTemplates
|
|
check.dependsOn checkExamples
|
|
check.dependsOn checkCommands
|
|
check.dependsOn checkSnippets
|