Files
PhotonVision/photon-server/build.gradle
Alan Everett 0525e762b4 Switch from FasterXML Jackson to Avaje Jsonb (#2503)
## Description

WPILib switched from FasterXML Jackson to Avaje Jsonb for speed reasons
in https://github.com/wpilibsuite/allwpilib/pull/8721. This does the
same for PhotonVision. Some temporary Jackson adapters are present to
allow compatibility with alpha-4 ahead of updating Photon's WPILib
version. A few old backwards compatibility migrations were also dropped
if they were difficult to port to Avaje Jsonb or otherwise complicated
the code.

## 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_, including events
that led to this PR
- [ ] 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 all settings going back to the previous seasons's last release
(seasons end after champs ends)
- [ ] 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
- [ ] If this PR adds a dependency, the license has been checked for
compatibility and steps taken to follow it

---------

Co-authored-by: samfreund <samf.236@proton.me>
Co-authored-by: Matt Morley <matthew.morley.ca@gmail.com>
2026-05-24 17:05:10 +00:00

151 lines
5.0 KiB
Groovy

import org.wpilib.deployutils.deploy.artifact.*
import org.wpilib.deployutils.deploy.target.RemoteTarget
import org.wpilib.deployutils.deploy.target.location.SshDeployLocation
apply plugin: "com.github.node-gradle.node"
apply plugin: 'com.gradleup.shadow'
apply plugin: "application"
apply plugin: 'org.wpilib.DeployUtils'
apply from: "${rootDir}/shared/common.gradle"
dependencies {
implementation project(':photon-core')
// Zip
implementation 'org.zeroturnaround:zt-zip:1.14'
// Needed for Javalin Runtime Logging
implementation "org.slf4j:slf4j-simple:2.0.7"
}
group = 'org.photonvision'
version = versionString + (project.hasProperty('pionly') ? "-raspi" : "")
application {
mainClass = 'org.photonvision.Main'
}
jar {
from file("$rootDir/LICENSE")
}
shadowJar {
dependsOn 'buildAndCopyUI'
archiveBaseName = "photonvision"
archiveVersion = project.version as String
archiveClassifier.set(wpilibTools.currentPlatform.platformName)
configurations = [
project.configurations.runtimeClasspath
]
mergeServiceFiles()
}
node {
nodeProjectDir = file("${projectDir}/../photon-client")
pnpmVersion = "11.0.9"
}
tasks.register('copyClientUIToResources', Copy) {
from "${projectDir}/../photon-client/dist/"
into "${projectDir}/src/main/resources/web/"
}
tasks.register('buildClient', PnpmTask) {
inputs.dir fileTree(dir: "${projectDir}/../photon-client", exclude: "dist/")
outputs.dir file("${projectDir}/../photon-client/dist")
args = ["build"]
dependsOn "pnpmInstall"
}
tasks.register('buildAndCopyUI') {
dependsOn "buildClient"
finalizedBy "copyClientUIToResources"
}
processResources {
dependsOn copyClientUIToResources
}
run {
environment "PATH_PREFIX", "../"
if (project.hasProperty("profile")) {
jvmArgs=[
"-Dcom.sun.management.jmxremote=true",
"-Dcom.sun.management.jmxremote.ssl=false",
"-Dcom.sun.management.jmxremote.authenticate=false",
"-Dcom.sun.management.jmxremote.port=5000",
"-Djava.rmi.server.hostname=0.0.0.0",
]
}
}
deploy {
targets {
pi(RemoteTarget) {
// Can't login as root, so deploy our file to /tmp, which is owned by pi
directory = '/tmp'
locations {
ssh(SshDeployLocation) {
if (project.hasProperty('tgtIP')) {
address = tgtIP
} else {
address = "photonvision.local"
}
if (project.hasProperty('tgtUser')) {
user = tgtUser
} else {
user = "photon"
}
if (project.hasProperty('tgtPw')) {
password = tgtPw
} else {
password = "vision"
}
}
}
artifacts {
stop(CommandArtifact) {
predeploy << {
println 'Starting deployment to ' + deploy.targets.pi.locations.ssh.address
println 'targetArch = ' + wpilibTools.platformMapper.currentPlatform.platformName
}
//Stop photonvision before manipulating its files
command = "sudo systemctl stop photonvision.service"
}
sleep(CommandArtifact) {
// gerth2 - I was having issues with the .jar being in use still - waiting a tiny bit here seems to get rid of it on a pi4
command = "sleep 3"
dependsOn artifacts.stop.deployTask
}
photonvisionJar(JavaArtifact) {
jarTask = shadowJar
filename = "photonvision.jar"
dependsOn artifacts.sleep.deployTask
}
moveJar(CommandArtifact) {
//belt-and-suspenders. Make sure the old jar is gone first before moving in the new .jar
command = "sudo rm -f /opt/photonvision/photonvision.jar && sudo mv /tmp/photonvision.jar /opt/photonvision/photonvision.jar"
dependsOn artifacts.photonvisionJar.deployTask
}
chmodJar(CommandArtifact) {
//Make sure it's executable
command = "sudo chmod +x /opt/photonvision/photonvision.jar"
dependsOn artifacts.moveJar.deployTask
}
start(CommandArtifact) {
//Fire up photonvision again
command = "sudo systemctl start photonvision.service"
dependsOn artifacts.chmodJar.deployTask
}
cleanUp(CommandArtifact) {
command = 'sudo rm -f /tmp/photonvision.jar'
dependsOn artifacts.moveJar.deployTask
}
}
}
}
}