2025-12-13 21:44:00 -08:00
|
|
|
import org.wpilib.toolchain.NativePlatforms
|
2020-12-08 01:33:17 -05:00
|
|
|
|
2017-10-17 01:30:21 -04:00
|
|
|
apply plugin: 'java'
|
2020-11-26 14:47:35 -05:00
|
|
|
apply plugin: 'jacoco'
|
2017-10-17 01:30:21 -04:00
|
|
|
|
2018-04-29 13:29:07 -07:00
|
|
|
ext {
|
|
|
|
|
useJava = true
|
|
|
|
|
useCpp = false
|
|
|
|
|
skipDev = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
apply from: "${rootDir}/shared/opencv.gradle"
|
|
|
|
|
|
2017-10-17 01:30:21 -04:00
|
|
|
dependencies {
|
2019-11-12 17:14:04 -08:00
|
|
|
implementation project(':wpilibj')
|
2022-12-23 18:04:59 -08:00
|
|
|
implementation project(':apriltag')
|
2020-08-06 23:57:39 -07:00
|
|
|
implementation project(':wpimath')
|
2019-11-12 17:14:04 -08:00
|
|
|
implementation project(':hal')
|
|
|
|
|
implementation project(':wpiutil')
|
2022-05-07 10:54:14 -07:00
|
|
|
implementation project(':wpinet')
|
2019-11-12 17:14:04 -08:00
|
|
|
implementation project(':ntcore')
|
|
|
|
|
implementation project(':cscore')
|
|
|
|
|
implementation project(':cameraserver')
|
2025-11-07 19:55:39 -05:00
|
|
|
implementation project(':commandsv2')
|
2025-12-05 22:53:14 -08:00
|
|
|
implementation project(':commandsv3')
|
2023-09-18 22:42:10 -04:00
|
|
|
implementation project(':romiVendordep')
|
|
|
|
|
implementation project(':xrpVendordep')
|
2024-07-16 20:25:43 -04:00
|
|
|
implementation project(':epilogue-runtime')
|
|
|
|
|
annotationProcessor project(':epilogue-processor')
|
2025-12-05 22:53:14 -08:00
|
|
|
annotationProcessor project(':javacPlugin')
|
|
|
|
|
annotationProcessor project(':wpiannotations')
|
2020-11-26 14:47:35 -05:00
|
|
|
|
2026-02-20 18:31:33 -05:00
|
|
|
testImplementation libs.junit.api
|
|
|
|
|
testRuntimeOnly libs.junit.launcher
|
2020-11-26 14:47:35 -05:00
|
|
|
}
|
|
|
|
|
|
2025-10-24 01:29:32 -04:00
|
|
|
// 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)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-26 14:47:35 -05:00
|
|
|
jacoco {
|
2026-04-12 22:03:50 -07:00
|
|
|
toolVersion = "0.8.14"
|
2020-11-26 14:47:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
jacocoTestReport {
|
|
|
|
|
reports {
|
2021-09-19 17:59:14 -07:00
|
|
|
xml.required = true
|
|
|
|
|
html.required = true
|
2020-11-26 14:47:35 -05:00
|
|
|
}
|
2017-10-17 01:30:21 -04:00
|
|
|
}
|
|
|
|
|
|
2021-08-07 20:39:14 -07:00
|
|
|
if (!project.hasProperty('skipJavaFormat')) {
|
2019-06-28 14:09:10 -07:00
|
|
|
apply plugin: 'pmd'
|
|
|
|
|
|
|
|
|
|
pmd {
|
|
|
|
|
consoleOutput = true
|
|
|
|
|
reportsDir = file("$project.buildDir/reports/pmd")
|
|
|
|
|
ruleSetFiles = files(new File(rootDir, "styleguide/pmd-ruleset.xml"))
|
|
|
|
|
ruleSets = []
|
|
|
|
|
}
|
2017-10-17 01:30:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gradle.projectsEvaluated {
|
|
|
|
|
tasks.withType(JavaCompile) {
|
2019-08-04 23:35:33 -04:00
|
|
|
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" << "-Werror"
|
2017-10-17 01:30:21 -04:00
|
|
|
}
|
|
|
|
|
}
|
2017-10-21 15:33:42 -07:00
|
|
|
|
2019-12-20 13:48:26 -08:00
|
|
|
tasks.register('buildDesktopJava') {
|
|
|
|
|
it.dependsOn tasks.withType(JavaCompile)
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-21 15:33:42 -07:00
|
|
|
apply from: 'publish.gradle'
|
2018-05-24 17:08:37 -07:00
|
|
|
|
|
|
|
|
ext {
|
2025-11-07 19:56:29 -05:00
|
|
|
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")
|
2018-05-24 17:08:37 -07:00
|
|
|
}
|
|
|
|
|
|
2020-12-08 01:33:17 -05:00
|
|
|
apply plugin: 'cpp'
|
2025-12-13 21:44:00 -08:00
|
|
|
apply plugin: 'org.wpilib.NativeUtils'
|
2020-12-08 01:33:17 -05:00
|
|
|
|
|
|
|
|
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 ->
|
2022-12-23 18:04:59 -08:00
|
|
|
lib project: ':apriltag', library: 'apriltag', linkage: 'shared'
|
2024-01-08 17:51:55 +11:00
|
|
|
lib project: ':apriltag', library: 'apriltagJNIShared', linkage: 'shared'
|
2020-12-08 01:33:17 -05:00
|
|
|
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
|
2022-12-29 06:07:59 -08:00
|
|
|
lib project: ':wpimath', library: 'wpimathJNIShared', linkage: 'shared'
|
2022-10-08 10:01:31 -07:00
|
|
|
project(':ntcore').addNtcoreDependency(binary, 'shared')
|
|
|
|
|
project(':ntcore').addNtcoreJniDependency(binary)
|
2020-12-08 01:33:17 -05:00
|
|
|
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'
|
2022-12-29 06:07:59 -08:00
|
|
|
lib project: ':wpiutil', library: 'wpiutilJNIShared', linkage: 'shared'
|
2022-05-07 10:54:14 -07:00
|
|
|
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
|
2022-12-29 06:07:59 -08:00
|
|
|
lib project: ':wpinet', library: 'wpinetJNIShared', linkage: 'shared'
|
2025-01-13 11:23:54 -08:00
|
|
|
|
|
|
|
|
def systemArch = getCurrentArch()
|
|
|
|
|
if (binary.targetPlatform.name == systemArch) {
|
|
|
|
|
lib project: ":simulation:halsim_gui", library: 'halsim_gui', linkage: 'shared'
|
2020-12-08 01:33:17 -05:00
|
|
|
}
|
2025-01-13 11:23:54 -08:00
|
|
|
|
2020-12-08 01:33:17 -05:00
|
|
|
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 ->
|
2025-08-08 08:08:34 -07:00
|
|
|
run.group = "run examples"
|
2026-02-21 14:35:26 -08:00
|
|
|
run.mainClass = "org.wpilib.Executor"
|
|
|
|
|
run.args = [
|
|
|
|
|
"org.wpilib.examples." + entry.foldername + "." + entry.robotclass
|
|
|
|
|
]
|
2022-12-02 18:40:14 +02:00
|
|
|
run.classpath = sourceSets.main.runtimeClasspath
|
2020-12-08 01:33:17 -05:00
|
|
|
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']
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-02 18:40:14 +02:00
|
|
|
project.tasks.create("test${entry.foldername}", Test) { testTask ->
|
2025-08-08 08:08:34 -07:00
|
|
|
testTask.group = "verification"
|
2022-12-02 18:40:14 +02:00
|
|
|
testTask.useJUnitPlatform()
|
|
|
|
|
testTask.filter {
|
2025-11-07 19:56:29 -05:00
|
|
|
includeTestsMatching("org.wpilib.examples.${entry.foldername}.*")
|
2023-10-09 20:11:51 -07:00
|
|
|
// armsimulation regularly fails on CI Win64Debug
|
|
|
|
|
if (project.hasProperty('ciDebugOnly')) {
|
2025-11-07 19:56:29 -05:00
|
|
|
excludeTestsMatching("org.wpilib.examples.armsimulation.*")
|
2023-10-09 20:11:51 -07:00
|
|
|
}
|
2022-12-02 18:40:14 +02:00
|
|
|
setFailOnNoMatchingTests(false)
|
|
|
|
|
}
|
2023-09-18 21:03:39 +03:00
|
|
|
test.filter {
|
2025-11-07 19:56:29 -05:00
|
|
|
excludeTestsMatching("org.wpilib.examples.${entry.foldername}.*")
|
2023-09-18 21:03:39 +03:00
|
|
|
setFailOnNoMatchingTests(false)
|
|
|
|
|
}
|
2024-08-02 18:39:25 -07:00
|
|
|
testTask.testClassesDirs = sourceSets.test.output.classesDirs
|
2022-12-02 18:40:14 +02:00
|
|
|
testTask.classpath = sourceSets.test.runtimeClasspath
|
2022-12-25 17:37:10 +02:00
|
|
|
testTask.dependsOn it.tasks.install
|
|
|
|
|
|
2022-12-02 18:40:14 +02:00
|
|
|
testTask.systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true'
|
|
|
|
|
testTask.testLogging {
|
|
|
|
|
events "failed"
|
2025-08-08 08:08:34 -07:00
|
|
|
exceptionFormat = "full"
|
2022-12-02 18:40:14 +02:00
|
|
|
}
|
|
|
|
|
testTask.systemProperty 'java.library.path', filePath
|
2023-09-18 21:03:39 +03:00
|
|
|
|
2024-11-30 18:04:00 +00:00
|
|
|
if (project.hasProperty('onlylinuxathena') || project.hasProperty('onlylinuxsystemcore') || project.hasProperty('onlylinuxarm32') || project.hasProperty('onlylinuxarm64') || project.hasProperty('onlywindowsarm64')) {
|
2023-09-18 21:03:39 +03:00
|
|
|
testTask.enabled = false
|
|
|
|
|
}
|
|
|
|
|
test.dependsOn(testTask)
|
2022-12-02 18:40:14 +02:00
|
|
|
}
|
2020-12-08 01:33:17 -05:00
|
|
|
}
|
2025-04-22 14:26:26 -07:00
|
|
|
new groovy.json.JsonSlurper().parseText(snippetsFile.text).each { entry ->
|
|
|
|
|
project.tasks.create("runSnippet${entry.foldername}", JavaExec) { run ->
|
2025-08-08 08:08:34 -07:00
|
|
|
run.group = "run snippets"
|
2026-02-21 14:35:26 -08:00
|
|
|
run.mainClass = "org.wpilib.Executor"
|
|
|
|
|
run.args = [
|
|
|
|
|
"org.wpilib.snippets." + entry.foldername + "." + entry.robotclass
|
|
|
|
|
]
|
2025-04-22 14:26:26 -07:00
|
|
|
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 ->
|
2025-08-08 08:08:34 -07:00
|
|
|
testTask.group = "verification"
|
2025-04-22 14:26:26 -07:00
|
|
|
testTask.useJUnitPlatform()
|
|
|
|
|
testTask.filter {
|
2025-11-07 19:56:29 -05:00
|
|
|
includeTestsMatching("org.wpilib.snippets.${entry.foldername}.*")
|
2025-04-22 14:26:26 -07:00
|
|
|
setFailOnNoMatchingTests(false)
|
|
|
|
|
}
|
|
|
|
|
test.filter {
|
2025-11-07 19:56:29 -05:00
|
|
|
excludeTestsMatching("org.wpilib.snippets.${entry.foldername}.*")
|
2025-04-22 14:26:26 -07:00
|
|
|
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'
|
2022-12-02 18:40:14 +02:00
|
|
|
testTask.testLogging {
|
|
|
|
|
events "failed"
|
2025-08-08 08:08:34 -07:00
|
|
|
exceptionFormat = "full"
|
2022-12-02 18:40:14 +02:00
|
|
|
}
|
|
|
|
|
testTask.systemProperty 'java.library.path', filePath
|
2023-09-18 21:03:39 +03:00
|
|
|
|
|
|
|
|
if (project.hasProperty('onlylinuxathena') || project.hasProperty('onlylinuxarm32') || project.hasProperty('onlylinuxarm64') || project.hasProperty('onlywindowsarm64')) {
|
|
|
|
|
testTask.enabled = false
|
|
|
|
|
}
|
|
|
|
|
test.dependsOn(testTask)
|
2022-12-02 18:40:14 +02:00
|
|
|
}
|
2020-12-08 01:33:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
found = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 20:10:05 -07:00
|
|
|
ext {
|
|
|
|
|
isCppCommands = false
|
|
|
|
|
}
|
2018-05-24 17:08:37 -07:00
|
|
|
apply from: "${rootDir}/shared/examplecheck.gradle"
|