mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
There were 3 cases failing before. 1. An OpModeRobot with no annotation. 2. An OpModeRobot with an annotation but a parameterless constructor. 3. An OpMode with a UserControls constructor This PR solves both of these issues. The first one is solved by adding the null check before setting the user controls instance. That one will never have an opmode instance. The second one is solved by falling back to a parameterless constructor if one with a parameter is not found. The 3rd one is solved by using the annotation type rather than the instance for constructor lookup. Also fixes ExpansionHubSample's missing annotations.
293 lines
13 KiB
Groovy
293 lines
13 KiB
Groovy
import org.wpilib.toolchain.NativePlatforms
|
|
|
|
apply plugin: 'java'
|
|
apply plugin: 'jacoco'
|
|
|
|
ext {
|
|
useJava = true
|
|
useCpp = false
|
|
skipDev = true
|
|
}
|
|
|
|
apply from: "${rootDir}/shared/opencv.gradle"
|
|
|
|
dependencies {
|
|
implementation project(':wpilibj')
|
|
implementation project(':apriltag')
|
|
implementation project(':wpimath')
|
|
implementation project(':hal')
|
|
implementation project(':wpiutil')
|
|
implementation project(':wpinet')
|
|
implementation project(':ntcore')
|
|
implementation project(':cscore')
|
|
implementation project(':cameraserver')
|
|
implementation project(':commandsv2')
|
|
implementation project(':commandsv3')
|
|
implementation project(':romiVendordep')
|
|
implementation project(':xrpVendordep')
|
|
implementation project(':epilogue-runtime')
|
|
annotationProcessor project(':epilogue-processor')
|
|
annotationProcessor project(':javacPlugin')
|
|
annotationProcessor project(':wpiannotations')
|
|
|
|
testImplementation libs.junit.api
|
|
testRuntimeOnly libs.junit.launcher
|
|
}
|
|
|
|
// Prevent the eclipse compiler (used by the VS Code extension for intellisense and debugging)
|
|
// from generating bad class files from annotation processors like Epilogue
|
|
eclipse {
|
|
classpath {
|
|
containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
|
|
file.whenMerged { cp ->
|
|
def entries = cp.entries;
|
|
def src = new org.gradle.plugins.ide.eclipse.model.SourceFolder('build/generated/sources/annotationProcessor/java/main/', null)
|
|
entries.add(src)
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks.withType(JavaExec).configureEach {
|
|
// Commands v3 needs reflective access to the continuation classes
|
|
jvmArgs += [
|
|
'--add-opens',
|
|
'java.base/jdk.internal.vm=ALL-UNNAMED',
|
|
'--add-opens',
|
|
'java.base/java.lang=ALL-UNNAMED',
|
|
]
|
|
}
|
|
|
|
jacoco {
|
|
toolVersion = "0.8.14"
|
|
}
|
|
|
|
jacocoTestReport {
|
|
reports {
|
|
xml.required = true
|
|
html.required = true
|
|
}
|
|
}
|
|
|
|
if (!project.hasProperty('skipJavaFormat')) {
|
|
apply plugin: 'pmd'
|
|
|
|
pmd {
|
|
consoleOutput = true
|
|
reportsDir = file("$project.buildDir/reports/pmd")
|
|
ruleSetFiles = files(new File(rootDir, "styleguide/pmd-ruleset.xml"))
|
|
ruleSets = []
|
|
}
|
|
}
|
|
|
|
gradle.projectsEvaluated {
|
|
tasks.withType(JavaCompile) {
|
|
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" << "-Werror"
|
|
}
|
|
}
|
|
|
|
tasks.register('buildDesktopJava') {
|
|
it.dependsOn tasks.withType(JavaCompile)
|
|
}
|
|
|
|
apply from: 'publish.gradle'
|
|
|
|
ext {
|
|
templateDirectory = new File("$projectDir/src/main/java/org/wpilib/templates/")
|
|
templateFile = new File("$projectDir/src/main/java/org/wpilib/templates/templates.json")
|
|
exampleDirectory = new File("$projectDir/src/main/java/org/wpilib/examples/")
|
|
exampleFile = new File("$projectDir/src/main/java/org/wpilib/examples/examples.json")
|
|
commandDirectory = new File("$projectDir/src/main/java/org/wpilib/commands/")
|
|
commandFile = new File("$projectDir/src/main/java/org/wpilib/commands/commands.json")
|
|
snippetsDirectory = new File("$projectDir/src/main/java/org/wpilib/snippets/")
|
|
snippetsFile = new File("$projectDir/src/main/java/org/wpilib/snippets/snippets.json")
|
|
}
|
|
|
|
apply plugin: 'cpp'
|
|
apply plugin: 'org.wpilib.NativeUtils'
|
|
|
|
apply from: '../shared/config.gradle'
|
|
|
|
|
|
model {
|
|
components {
|
|
wpilibjExamplesDev(NativeExecutableSpec) {
|
|
targetBuildTypes 'debug'
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs 'src/dev/native/cpp'
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs 'src/dev/native/include'
|
|
}
|
|
}
|
|
}
|
|
binaries.all { binary ->
|
|
lib project: ':apriltag', library: 'apriltag', linkage: 'shared'
|
|
lib project: ':apriltag', library: 'apriltagJNIShared', linkage: 'shared'
|
|
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
|
|
lib project: ':wpimath', library: 'wpimathJNIShared', linkage: 'shared'
|
|
project(':ntcore').addNtcoreDependency(binary, 'shared')
|
|
project(':ntcore').addNtcoreJniDependency(binary)
|
|
lib project: ':cscore', library: 'cscore', linkage: 'shared'
|
|
lib project: ':cscore', library: 'cscoreJNIShared', linkage: 'shared'
|
|
project(':hal').addHalDependency(binary, 'shared')
|
|
project(':hal').addHalJniDependency(binary)
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
|
lib project: ':wpiutil', library: 'wpiutilJNIShared', linkage: 'shared'
|
|
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
|
|
lib project: ':wpinet', library: 'wpinetJNIShared', linkage: 'shared'
|
|
|
|
def systemArch = getCurrentArch()
|
|
if (binary.targetPlatform.name == systemArch) {
|
|
lib project: ":simulation:halsim_gui", library: 'halsim_gui', linkage: 'shared'
|
|
}
|
|
|
|
nativeUtils.useRequiredLibrary(binary, 'opencv_shared')
|
|
}
|
|
}
|
|
}
|
|
tasks {
|
|
def c = $.components
|
|
def found = false
|
|
c.each {
|
|
if (it in NativeExecutableSpec && it.name == "wpilibjExamplesDev") {
|
|
it.binaries.each {
|
|
if (!found) {
|
|
def arch = it.targetPlatform.name
|
|
if (arch == NativePlatforms.desktop) {
|
|
found = true
|
|
def filePath = it.tasks.install.installDirectory.get().toString() + File.separatorChar + 'lib'
|
|
|
|
def doFirstTask = { task ->
|
|
def extensions = ''
|
|
it.tasks.install.installDirectory.get().getAsFile().eachFileRecurse {
|
|
def name = it.name
|
|
if (!(name.endsWith('.dll') || name.endsWith('.so') || name.endsWith('.dylib'))) {
|
|
return
|
|
}
|
|
def file = it
|
|
if (name.startsWith("halsim_gui") || name.startsWith("libhalsim_gui".toString())) {
|
|
extensions += file.absolutePath + File.pathSeparator
|
|
}
|
|
}
|
|
if (extensions != '') {
|
|
task.environment 'HALSIM_EXTENSIONS', extensions
|
|
}
|
|
}
|
|
|
|
project.tasks.create("runCpp", Exec) { task ->
|
|
dependsOn it.tasks.install
|
|
commandLine it.tasks.install.runScriptFile.get().asFile.toString()
|
|
test.dependsOn it.tasks.install
|
|
test.systemProperty 'java.library.path', filePath
|
|
}
|
|
|
|
new groovy.json.JsonSlurper().parseText(exampleFile.text).each { entry ->
|
|
project.tasks.create("run${entry.foldername}", JavaExec) { run ->
|
|
run.group = "run examples"
|
|
run.mainClass = "org.wpilib.Executor"
|
|
run.args = [
|
|
"org.wpilib.examples." + entry.foldername + "." + entry.robotclass
|
|
]
|
|
run.classpath = sourceSets.main.runtimeClasspath
|
|
run.dependsOn it.tasks.install
|
|
run.systemProperty 'java.library.path', filePath
|
|
doFirst { doFirstTask(run) }
|
|
|
|
if (org.gradle.internal.os.OperatingSystem.current().isMacOsX()) {
|
|
run.jvmArgs = ['-XstartOnFirstThread']
|
|
}
|
|
}
|
|
project.tasks.create("test${entry.foldername}", Test) { testTask ->
|
|
testTask.group = "verification"
|
|
testTask.useJUnitPlatform()
|
|
testTask.filter {
|
|
includeTestsMatching("org.wpilib.examples.${entry.foldername}.*")
|
|
// armsimulation regularly fails on CI Win64Debug
|
|
if (project.hasProperty('ciDebugOnly')) {
|
|
excludeTestsMatching("org.wpilib.examples.armsimulation.*")
|
|
}
|
|
setFailOnNoMatchingTests(false)
|
|
}
|
|
test.filter {
|
|
excludeTestsMatching("org.wpilib.examples.${entry.foldername}.*")
|
|
setFailOnNoMatchingTests(false)
|
|
}
|
|
testTask.testClassesDirs = sourceSets.test.output.classesDirs
|
|
testTask.classpath = sourceSets.test.runtimeClasspath
|
|
testTask.dependsOn it.tasks.install
|
|
|
|
testTask.systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true'
|
|
testTask.testLogging {
|
|
events "failed"
|
|
exceptionFormat = "full"
|
|
}
|
|
testTask.systemProperty 'java.library.path', filePath
|
|
|
|
if (project.hasProperty('onlylinuxathena') || project.hasProperty('onlylinuxsystemcore') || project.hasProperty('onlylinuxarm32') || project.hasProperty('onlylinuxarm64') || project.hasProperty('onlywindowsarm64')) {
|
|
testTask.enabled = false
|
|
}
|
|
test.dependsOn(testTask)
|
|
}
|
|
}
|
|
new groovy.json.JsonSlurper().parseText(snippetsFile.text).each { entry ->
|
|
project.tasks.create("runSnippet${entry.foldername}", JavaExec) { run ->
|
|
run.group = "run snippets"
|
|
run.mainClass = "org.wpilib.Executor"
|
|
run.args = [
|
|
"org.wpilib.snippets." + entry.foldername + "." + entry.robotclass
|
|
]
|
|
run.classpath = sourceSets.main.runtimeClasspath
|
|
run.dependsOn it.tasks.install
|
|
run.systemProperty 'java.library.path', filePath
|
|
doFirst { doFirstTask(run) }
|
|
|
|
if (org.gradle.internal.os.OperatingSystem.current().isMacOsX()) {
|
|
run.jvmArgs = ['-XstartOnFirstThread']
|
|
}
|
|
}
|
|
project.tasks.create("testSnippet${entry.foldername}", Test) { testTask ->
|
|
testTask.group = "verification"
|
|
testTask.useJUnitPlatform()
|
|
testTask.filter {
|
|
includeTestsMatching("org.wpilib.snippets.${entry.foldername}.*")
|
|
setFailOnNoMatchingTests(false)
|
|
}
|
|
test.filter {
|
|
excludeTestsMatching("org.wpilib.snippets.${entry.foldername}.*")
|
|
setFailOnNoMatchingTests(false)
|
|
}
|
|
testTask.testClassesDirs = sourceSets.test.output.classesDirs
|
|
testTask.classpath = sourceSets.test.runtimeClasspath
|
|
testTask.dependsOn it.tasks.install
|
|
|
|
testTask.systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true'
|
|
testTask.testLogging {
|
|
events "failed"
|
|
exceptionFormat = "full"
|
|
}
|
|
testTask.systemProperty 'java.library.path', filePath
|
|
|
|
if (project.hasProperty('onlylinuxathena') || project.hasProperty('onlylinuxarm32') || project.hasProperty('onlylinuxarm64') || project.hasProperty('onlywindowsarm64')) {
|
|
testTask.enabled = false
|
|
}
|
|
test.dependsOn(testTask)
|
|
}
|
|
}
|
|
|
|
found = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
ext {
|
|
isCppCommands = false
|
|
}
|
|
apply from: "${rootDir}/shared/examplecheck.gradle"
|