Files
allwpilib/shared/examplecheck.gradle
Tyler Veness 5fd9e1e72a [build] Fix Gradle Task.project deprecation warning (#8167)
```
> Task :wpilibcExamples:checkCommands
Script '/home/tav/frc/wpilib/allwpilib/shared/examplecheck.gradle': line 135
Invocation of Task.project at execution time has been deprecated. This will fail with an error in Gradle 10.0. This API is incompatible with the configuration cache, which will become the only mode supported by Gradle in a future release. Consult the upgrading guide for further information: https://docs.gradle.org/8.14.3/userguide/upgrading_version_7.html#task_project
        at examplecheck_4wsg1s37eigy9vs5arzst20ga$_run_closure5$_closure16$_closure17.doCall$original(/home/tav/frc/wpilib/allwpilib/shared/examplecheck.gradle:135)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
```

Moving the project access outside the doLast block makes it occur at
confguration time instead.
2025-08-08 22:48:11 -07:00

150 lines
4.9 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());
}
}
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", "LTVUnicycleController", "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", "Accelerometer",
/* --- 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 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.mainclass != 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