Files
PhotonVision/shared/common.gradle
Alan Everett 5df9137256 Gradle build task improvements (#2164)
## Description

This fixes a few problems with the Gradle `build` task and subtasks.
1. Spotless was being run on `node_modules`, resulting in errors for
out-of-source files. This is now disabled.
2. All tests were running from the `build` task, resulting in unexpected
windows popping up. Now only headless tests are run.
3. Headless tests were updated to run from the same root directory as
the other tests.

## Meta

Merge checklist:
- [X] Pull Request title is [short, imperative
summary](https://cbea.ms/git-commit/) of proposed changes
- [X] The description documents the _what_ and _why_
- [ ] If this PR changes behavior or adds a feature, user documentation
is updated
- [ ] If this PR touches photon-serde, all messages have been
regenerated and hashes have not changed unexpectedly
- [ ] If this PR touches configuration, this is backwards compatible
with settings back to v2025.3.2
- [ ] If this PR touches pipeline settings or anything related to data
exchange, the frontend typing is updated
- [ ] If this PR addresses a bug, a regression test for it is added
2025-11-01 17:42:30 -04:00

106 lines
3.7 KiB
Groovy

// Plugins
apply plugin: "java"
apply plugin: "jacoco"
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
wpilibTools.deps.wpilibVersion = wpilibVersion
// Tell gradlerio what version of things to use (that we care about)
// See: https://github.com/wpilibsuite/GradleRIO/blob/main/src/main/java/edu/wpi/first/gradlerio/wpi/WPIVersionsExtension.java
wpi.getVersions().getOpencvVersion().convention(openCVversion);
wpi.getVersions().getWpilibVersion().convention(wpilibVersion);
wpi.getVersions().getWpimathVersion().convention(wpimathVersion);
dependencies {
implementation project(':photon-targeting')
implementation "io.javalin:javalin:$javalinVersion"
implementation 'org.msgpack:msgpack-core:0.9.0'
implementation 'org.msgpack:jackson-dataformat-msgpack:0.9.0'
implementation wpilibTools.deps.wpilibJava("wpiutil")
implementation wpilibTools.deps.wpilibJava("cameraserver")
implementation wpilibTools.deps.wpilibJava("cscore")
implementation wpilibTools.deps.wpilibJava("wpinet")
implementation wpilibTools.deps.wpilibJava("wpimath")
implementation wpilibTools.deps.wpilibJava("ntcore")
implementation wpilibTools.deps.wpilibJava("hal")
implementation wpilibTools.deps.wpilibJava("wpilibj")
implementation wpilibTools.deps.wpilibJava("apriltag")
implementation wpilibTools.deps.wpilibJava("wpiunits")
implementation wpilibTools.deps.wpilibOpenCvJava("frc" + openCVYear, wpi.versions.opencvVersion.get())
implementation group: "com.fasterxml.jackson.core", name: "jackson-annotations", version: wpi.versions.jacksonVersion.get()
implementation group: "com.fasterxml.jackson.core", name: "jackson-core", version: wpi.versions.jacksonVersion.get()
implementation group: "com.fasterxml.jackson.core", name: "jackson-databind", version: wpi.versions.jacksonVersion.get()
implementation group: "org.ejml", name: "ejml-simple", version: wpi.versions.ejmlVersion.get()
implementation group: "us.hebi.quickbuf", name: "quickbuf-runtime", version: wpi.versions.quickbufVersion.get();
implementation "commons-io:commons-io:2.11.0"
implementation "commons-cli:commons-cli:1.5.0"
implementation "org.apache.commons:commons-exec:1.3"
testImplementation(platform('org.junit:junit-bom:5.11.4'))
testImplementation 'org.junit.jupiter:junit-jupiter-api'
testImplementation 'org.junit.jupiter:junit-jupiter-params'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
}
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
}
workingDir = new File("${rootDir}")
finalizedBy jacocoTestReport
}
tasks.register('testHeadless', Test) {
group = "verification"
systemProperty("java.awt.headless", "true")
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
exceptionFormat = "full"
showStandardStreams = true
}
exclude '**/*BenchmarkTest*'
workingDir = new File("${rootDir}")
}
jacoco {
toolVersion = "0.8.10"
reportsDirectory = layout.buildDirectory.dir('customJacocoReportDir')
}
jacocoTestReport {
dependsOn testHeadless
reports {
xml.required = true
csv.required = false
html.outputLocation = layout.buildDirectory.dir('jacocoHtml')
}
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it,
exclude: "edu/wpi/**"
)
}))
}
}
// Only run headless tests from the build task
gradle.taskGraph.whenReady { graph ->
if (graph.hasTask(build)) {
test.enabled = false
}
}