Files
PhotonVision/photon-server/build.gradle
Sam Freund 68fc1e7129 Make 2027 build (#2422)
This PR updates everything for 2027. This includes removing GradleRIO, simplifying our wpilib version defintion, updating APIs, updating to Java 21, and more.

Note that photonlibpy is failing because robotpy has not been fully updated yet. Examples are omitted because they need to be updated for our new PhotonPoseEstimator API and still need some changes from WPILIB. photonlib windows build is failing because we're waiting for some upstream changes. Finally, images are failing since they don't have Java 21 yet.
2026-04-11 12:23:14 -05:00

149 lines
4.9 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
]
}
node {
nodeProjectDir = file("${projectDir}/../photon-client")
}
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
}
}
}
}
}