| 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()); |
| } |
| } |
| |
| 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.foldername != null |
| assert it.gradlebase != null |
| assert it.commandversion != null |
| if (it.gradlebase == 'java') { |
| assert it.mainclass != null |
| } |
| } |
| } |
| } |
| |
| def tagList = [ |
| /* --- Categories --- */ |
| // On-RIO image processing |
| "Vision", |
| // Command-based |
| "Command-based", |
| // 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", "Ramsete", "Path Following", "Trajectory", |
| "SysId", "Simulation", "Trapezoid Profile", "Profiled PID", "Odometry", "LQR", |
| "Pose Estimator", |
| |
| /* --- Hardware --- */ |
| "Analog", "Ultrasonic", "Gyro", "Pneumatics", "I2C", "Duty Cycle", "PDP", "DMA", "Relay", |
| "AddressableLEDs", "HAL", "Encoder", "Smart Motor Controller", "Digital Input", |
| "Digital Output", |
| |
| /* --- HID --- */ |
| "XboxController", "PS4Controller", "PS5Controller", "Joystick", |
| |
| /* --- Misc --- */ |
| /* (try to keep this section minimal) */ |
| "EventLoop", "AprilTags", "Mechanism2d", "Preferences", |
| ] |
| |
| 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.mainclass != null |
| } |
| } |
| } |
| } |
| |
| task checkCommands(type: Task) { |
| 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 (project.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 |