diff --git a/shared/examplecheck.gradle b/shared/examplecheck.gradle index 64a83c75c6..ba6d581359 100644 --- a/shared/examplecheck.gradle +++ b/shared/examplecheck.gradle @@ -1,5 +1,5 @@ -def fileCheck = { file, folder -> - def folderNames = new groovy.json.JsonSlurper().parseText(file.text).collect { it.foldername } +def fileCheck = { parsedJson, folder -> + def folderNames = parsedJson.collect { it.foldername } def folders = [] folder.eachDir { folders << it.name @@ -26,19 +26,55 @@ def fileCheck = { file, folder -> task checkTemplates(type: Task) { doLast { - fileCheck(templateFile, templateDirectory) + 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 + if (it.gradlebase == 'java') { + assert it.mainclass != null + } + } } } task checkExamples(type: Task) { doLast { - fileCheck(exampleFile, exampleDirectory) + 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.foldername != null + assert it.gradlebase != null + if (it.gradlebase == 'java') { + assert it.mainclass != null + } + } } } task checkCommands(type: Task) { doLast { - fileCheck(commandFile, commandDirectory) + 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 + if (project.isCppCommands) { + assert it.headers != null + assert !it.headers.isEmpty() + assert it.source != null + assert !it.source.isEmpty() + } + } } } diff --git a/wpilibcExamples/build.gradle b/wpilibcExamples/build.gradle index 04a74bd624..c7f6ecb4a7 100644 --- a/wpilibcExamples/build.gradle +++ b/wpilibcExamples/build.gradle @@ -234,4 +234,7 @@ ext { commandFile = new File("$projectDir/src/main/cpp/commands/commands.json") } +ext { + isCppCommands = true +} apply from: "${rootDir}/shared/examplecheck.gradle" diff --git a/wpilibcExamples/src/main/cpp/examples/examples.json b/wpilibcExamples/src/main/cpp/examples/examples.json index 864ea1dc3e..38f27bbe5b 100644 --- a/wpilibcExamples/src/main/cpp/examples/examples.json +++ b/wpilibcExamples/src/main/cpp/examples/examples.json @@ -357,7 +357,7 @@ "gradlebase": "cpp" }, { - "name:": "RamseteCommand", + "name": "RamseteCommand", "description": "An example command-based robot demonstrating the use of a RamseteCommand to follow a pregenerated trajectory.", "tags": [ "RamseteCommand", diff --git a/wpilibjExamples/build.gradle b/wpilibjExamples/build.gradle index 7b65086ab1..846c5bf771 100644 --- a/wpilibjExamples/build.gradle +++ b/wpilibjExamples/build.gradle @@ -48,4 +48,7 @@ ext { commandFile = new File("$projectDir/src/main/java/edu/wpi/first/wpilibj/commands/commands.json") } +ext { + isCppCommands = false +} apply from: "${rootDir}/shared/examplecheck.gradle" diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/examples.json b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/examples.json index 39840f7c1c..af1b54ab60 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/examples.json +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/examples.json @@ -381,7 +381,7 @@ "mainclass": "Main" }, { - "name:": "RamseteCommand", + "name": "RamseteCommand", "description": "An example command-based robot demonstrating the use of a RamseteCommand to follow a pregenerated trajectory.", "tags": [ "RamseteCommand",