forked from wpilibsuite/allwpilib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexamplecheck.gradle
148 lines (135 loc) · 4.88 KB
/
examplecheck.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
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",
/* --- 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) {
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
check.dependsOn checkSnippets