Files
PhotonVision/photon-server/build.gradle

272 lines
9.4 KiB
Groovy
Raw Normal View History

2020-03-18 01:51:30 -04:00
plugins {
id 'java'
Bootup sprint (#18) * Did some stuff * Fix gradle, start implementing mjpeg frame consumer * Did some stuff * bade changes * rename camera config to USBCameraConfiguration, add name * unrename cameraconfiguration * Add pub/sub framework * Add setResolution to mjpeg frame consumer * add NTDataConsumer * Add some totally broken hsv hacks * Start refactoring UI data * Update index.js * Commit and push, he says * Fix up some errors * Fix input tab * Fix fps * Update index.js * Add pipeline field setting, update PipelineManager, fix nullpointers and USBCameraSettables * Change v-model to point to data() * update hsv to use mutations * Work on saving, fix hsv * Rename shouldErode/shouldDilate to erode and dilate * Hook all the tabs up to the Store * Change handleData to handlePipelineData * camera quirk redo, add ICCSub to SocketHandler * Fix some property names * Fixed tons of naming in UI, fix backend for multi-val PSCs, fix PSC enums * change pipeline type to an int in store * Fix mutation naming * Attempt threshold fix * Update SocketHandler.java * Add truthy data sending * Start adding logging support * [UI] Add delay to slider input boxes (#1) * [UI] [Backend] potentially fix camera settings, various logging tweaks * Don't release raw input mat * add setVideoModeIndex to vision settables * Implement pipeline index in socket handler, add framework for renaming/changing pipes * (ish) get pipeline change working * Create index.html * Cleanups, fix pipeline index bug, fix stream res for MJPG, add dashboard stream (unused) * Refactor UI to use mutatePipeline, send pipeline results * Update NetworkConfig.java * Change double to number * Run spotless * Fix reversal of large/small comparators * Fix left/right * Fix pitch/yaw calculation bug, fix area bug * Use Vue.set instead of assignment This fixes {{ }} * Update App.vue * run spotless * Actually add pipelines and reassign indecies * Delete old pipeline configs Fixes duplication on renaming pipeline * Start working on deleting pipes * Fix camera nickname change * run spotless * Fix some test stuff * Update VisionModuleManagerTest.java * vision source manager test is still broken * Fix VisionSourceManager test * Apply spotless 2 electric boogaloo Co-authored-by: Banks Troutman <btrout.dhrs@gmail.com> Co-authored-by: Declan Freeman-Gleason <declanfreemangleason@gmail.com> Co-authored-by: Aaryan Agrawal <54345060+13Ducks@users.noreply.github.com>
2020-07-07 01:01:58 -07:00
id 'application'
2020-03-18 01:51:30 -04:00
id 'com.github.johnrengelman.shadow' version '5.2.0'
id "com.diffplug.gradle.spotless" version "3.28.0"
id 'org.hidetake.ssh' version '2.10.1'
id "jacoco"
2020-03-18 01:51:30 -04:00
}
apply from: 'versioningHelper.gradle'
Bootup sprint (#18) * Did some stuff * Fix gradle, start implementing mjpeg frame consumer * Did some stuff * bade changes * rename camera config to USBCameraConfiguration, add name * unrename cameraconfiguration * Add pub/sub framework * Add setResolution to mjpeg frame consumer * add NTDataConsumer * Add some totally broken hsv hacks * Start refactoring UI data * Update index.js * Commit and push, he says * Fix up some errors * Fix input tab * Fix fps * Update index.js * Add pipeline field setting, update PipelineManager, fix nullpointers and USBCameraSettables * Change v-model to point to data() * update hsv to use mutations * Work on saving, fix hsv * Rename shouldErode/shouldDilate to erode and dilate * Hook all the tabs up to the Store * Change handleData to handlePipelineData * camera quirk redo, add ICCSub to SocketHandler * Fix some property names * Fixed tons of naming in UI, fix backend for multi-val PSCs, fix PSC enums * change pipeline type to an int in store * Fix mutation naming * Attempt threshold fix * Update SocketHandler.java * Add truthy data sending * Start adding logging support * [UI] Add delay to slider input boxes (#1) * [UI] [Backend] potentially fix camera settings, various logging tweaks * Don't release raw input mat * add setVideoModeIndex to vision settables * Implement pipeline index in socket handler, add framework for renaming/changing pipes * (ish) get pipeline change working * Create index.html * Cleanups, fix pipeline index bug, fix stream res for MJPG, add dashboard stream (unused) * Refactor UI to use mutatePipeline, send pipeline results * Update NetworkConfig.java * Change double to number * Run spotless * Fix reversal of large/small comparators * Fix left/right * Fix pitch/yaw calculation bug, fix area bug * Use Vue.set instead of assignment This fixes {{ }} * Update App.vue * run spotless * Actually add pipelines and reassign indecies * Delete old pipeline configs Fixes duplication on renaming pipeline * Start working on deleting pipes * Fix camera nickname change * run spotless * Fix some test stuff * Update VisionModuleManagerTest.java * vision source manager test is still broken * Fix VisionSourceManager test * Apply spotless 2 electric boogaloo Co-authored-by: Banks Troutman <btrout.dhrs@gmail.com> Co-authored-by: Declan Freeman-Gleason <declanfreemangleason@gmail.com> Co-authored-by: Aaryan Agrawal <54345060+13Ducks@users.noreply.github.com>
2020-07-07 01:01:58 -07:00
mainClassName = 'org.photonvision.Main'
group 'org.photonvision'
version versionString
2020-03-28 19:08:03 -04:00
2020-03-18 01:51:30 -04:00
sourceCompatibility = 11
repositories {
jcenter()
2020-03-18 01:51:30 -04:00
mavenCentral()
Add GPU Acceleration on the Raspberry Pi (#140) * Add native stuff * use runtimeloader * add more native methods * more stuff * Switch JNI methods to static * Remove non-java classes from the picam jni * Add gradle task for JNI generation * Migrate my previous GPU accel work * Initial work on defining JNI interface * Change libpicam to a symlink for now * Initial work on adding no-copy OMX GPU accel on the pi * Make DIRECT_OMX GPU accel mode not crash * Clean up OMX changes (still not getting valid data back) * Re-add GPU unit test * A couple debugging tweaks/notes * Add temporary special cases to get RGB out of ProcessingMode.NONE * Code clarity improvements; fix possible VBO bug * Get DIRECT_OMX working * Remove some debugging switches in GPUAccelerator * Pipe in VCSM stuff to read out pixels FAST * Apply Spotless * Revert versioningHelper changes * Add missing import * Convert to MMAL and move everything to native * Re-add shared object * Rework to use MMAL and do everything natively * Condense pipeline settings classes * Add OutputStreamPipeline * Apply spotless * Fix duplicate variable inits and add more video modes * Integrate color frames and latency measurements for GPU * Fix camera detection on pi and other platforms * Add proper color copy disabling and camera settings calls * Fix things that were broken by rebase * Fix spotless issues and remove uneeded prints * Remove libpicam symlink * Fix stream resolution limiting * Remove testing code in GPUAcceleratedHSVPipe * Make profiling options general to all computers * Make PicamJNI load from resources * run spotlessApply * Address review comments * Update Maven repo for JOGL * Fix release race condition * Only run GPU accel test on the pi * Lint fix and merge conflict accident fixes * Make Jackson ignore extra fields when unmarshalling HardwareConfig * Fix Mat releasing data race * Spotless apply * Remove broken header generation task * Fix shared library loading typo * Add a ZeroCopyPicam quirk to allow setting gain with the MMAL backend * Make sure that exposure/brightness/gain get set after res changes * Make rawInputMat properly local * Remove bogus set of shouldRun flag * Clean up small GPUHSVPipe print * Add in some things that missed the ZeroCopyPiCameraSource rename * Fix incorrect scoping introduced in past rebase * Don't filter out too-low resolutions * Only show latency when GPU accel is enabled * Don't free Mats in stream thread before we use them * Fix use-after-free and latency caluclation bugs on USB camera source * Update libpicam * Remove unwanted print * Add libpicam forceLoad in unit test * Fix streaming during camera calibration * Fix zerocopy Picam calculation * Use logger trace method instead of raw prints * Fix calibration and driver mode pipes with the Picam Co-authored-by: Matt <matthew.morley.ca@gmail.com> Co-authored-by: Banks Troutman <btrout.dhrs@gmail.com>
2020-12-08 02:34:21 -05:00
maven {
url = "https://maven.photonvision.org/repository/internal/"
}
2020-03-18 01:51:30 -04:00
maven {
url = 'https://frcmaven.wpi.edu:443/artifactory/development'
2020-03-18 01:51:30 -04:00
}
}
2020-03-18 01:51:30 -04:00
ext {
wpilibVersion = '2020.3.2-99-g9f4de91'
Add GPU Acceleration on the Raspberry Pi (#140) * Add native stuff * use runtimeloader * add more native methods * more stuff * Switch JNI methods to static * Remove non-java classes from the picam jni * Add gradle task for JNI generation * Migrate my previous GPU accel work * Initial work on defining JNI interface * Change libpicam to a symlink for now * Initial work on adding no-copy OMX GPU accel on the pi * Make DIRECT_OMX GPU accel mode not crash * Clean up OMX changes (still not getting valid data back) * Re-add GPU unit test * A couple debugging tweaks/notes * Add temporary special cases to get RGB out of ProcessingMode.NONE * Code clarity improvements; fix possible VBO bug * Get DIRECT_OMX working * Remove some debugging switches in GPUAccelerator * Pipe in VCSM stuff to read out pixels FAST * Apply Spotless * Revert versioningHelper changes * Add missing import * Convert to MMAL and move everything to native * Re-add shared object * Rework to use MMAL and do everything natively * Condense pipeline settings classes * Add OutputStreamPipeline * Apply spotless * Fix duplicate variable inits and add more video modes * Integrate color frames and latency measurements for GPU * Fix camera detection on pi and other platforms * Add proper color copy disabling and camera settings calls * Fix things that were broken by rebase * Fix spotless issues and remove uneeded prints * Remove libpicam symlink * Fix stream resolution limiting * Remove testing code in GPUAcceleratedHSVPipe * Make profiling options general to all computers * Make PicamJNI load from resources * run spotlessApply * Address review comments * Update Maven repo for JOGL * Fix release race condition * Only run GPU accel test on the pi * Lint fix and merge conflict accident fixes * Make Jackson ignore extra fields when unmarshalling HardwareConfig * Fix Mat releasing data race * Spotless apply * Remove broken header generation task * Fix shared library loading typo * Add a ZeroCopyPicam quirk to allow setting gain with the MMAL backend * Make sure that exposure/brightness/gain get set after res changes * Make rawInputMat properly local * Remove bogus set of shouldRun flag * Clean up small GPUHSVPipe print * Add in some things that missed the ZeroCopyPiCameraSource rename * Fix incorrect scoping introduced in past rebase * Don't filter out too-low resolutions * Only show latency when GPU accel is enabled * Don't free Mats in stream thread before we use them * Fix use-after-free and latency caluclation bugs on USB camera source * Update libpicam * Remove unwanted print * Add libpicam forceLoad in unit test * Fix streaming during camera calibration * Fix zerocopy Picam calculation * Use logger trace method instead of raw prints * Fix calibration and driver mode pipes with the Picam Co-authored-by: Matt <matthew.morley.ca@gmail.com> Co-authored-by: Banks Troutman <btrout.dhrs@gmail.com>
2020-12-08 02:34:21 -05:00
joglVersion = '2.4.0-rc-20200307'
2020-03-18 01:51:30 -04:00
openCVVersion = '3.4.7-2'
}
dependencies {
implementation "io.javalin:javalin:3.7.0"
implementation "com.fasterxml.jackson.core:jackson-annotations:2.10.0"
implementation "com.fasterxml.jackson.core:jackson-core:2.10.0"
implementation "com.fasterxml.jackson.core:jackson-databind:2.10.0"
implementation "org.msgpack:msgpack-core:0.8.20"
implementation "org.msgpack:jackson-dataformat-msgpack:0.8.20"
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.9'
implementation "org.apache.commons:commons-math3:3.6.1"
implementation group: 'commons-io', name: 'commons-io', version: '2.6'
implementation group: 'commons-cli', name: 'commons-cli', version: '1.4'
2020-03-18 01:51:30 -04:00
implementation "org.apache.commons:commons-collections4:4.4"
implementation "org.apache.commons:commons-exec:1.3"
Add GPU Acceleration on the Raspberry Pi (#140) * Add native stuff * use runtimeloader * add more native methods * more stuff * Switch JNI methods to static * Remove non-java classes from the picam jni * Add gradle task for JNI generation * Migrate my previous GPU accel work * Initial work on defining JNI interface * Change libpicam to a symlink for now * Initial work on adding no-copy OMX GPU accel on the pi * Make DIRECT_OMX GPU accel mode not crash * Clean up OMX changes (still not getting valid data back) * Re-add GPU unit test * A couple debugging tweaks/notes * Add temporary special cases to get RGB out of ProcessingMode.NONE * Code clarity improvements; fix possible VBO bug * Get DIRECT_OMX working * Remove some debugging switches in GPUAccelerator * Pipe in VCSM stuff to read out pixels FAST * Apply Spotless * Revert versioningHelper changes * Add missing import * Convert to MMAL and move everything to native * Re-add shared object * Rework to use MMAL and do everything natively * Condense pipeline settings classes * Add OutputStreamPipeline * Apply spotless * Fix duplicate variable inits and add more video modes * Integrate color frames and latency measurements for GPU * Fix camera detection on pi and other platforms * Add proper color copy disabling and camera settings calls * Fix things that were broken by rebase * Fix spotless issues and remove uneeded prints * Remove libpicam symlink * Fix stream resolution limiting * Remove testing code in GPUAcceleratedHSVPipe * Make profiling options general to all computers * Make PicamJNI load from resources * run spotlessApply * Address review comments * Update Maven repo for JOGL * Fix release race condition * Only run GPU accel test on the pi * Lint fix and merge conflict accident fixes * Make Jackson ignore extra fields when unmarshalling HardwareConfig * Fix Mat releasing data race * Spotless apply * Remove broken header generation task * Fix shared library loading typo * Add a ZeroCopyPicam quirk to allow setting gain with the MMAL backend * Make sure that exposure/brightness/gain get set after res changes * Make rawInputMat properly local * Remove bogus set of shouldRun flag * Clean up small GPUHSVPipe print * Add in some things that missed the ZeroCopyPiCameraSource rename * Fix incorrect scoping introduced in past rebase * Don't filter out too-low resolutions * Only show latency when GPU accel is enabled * Don't free Mats in stream thread before we use them * Fix use-after-free and latency caluclation bugs on USB camera source * Update libpicam * Remove unwanted print * Add libpicam forceLoad in unit test * Fix streaming during camera calibration * Fix zerocopy Picam calculation * Use logger trace method instead of raw prints * Fix calibration and driver mode pipes with the Picam Co-authored-by: Matt <matthew.morley.ca@gmail.com> Co-authored-by: Banks Troutman <btrout.dhrs@gmail.com>
2020-12-08 02:34:21 -05:00
// JOGL stuff (currently we only distribute for aarch64, which is Pi 4)
implementation "org.jogamp.gluegen:gluegen-rt:$joglVersion"
implementation "org.jogamp.jogl:jogl-all:$joglVersion"
// implementation "org.jogamp.gluegen:gluegen-rt:$joglVersion:natives-linux-amd64"
// implementation "org.jogamp.gluegen:gluegen-rt:$joglVersion:natives-linux-armv6hf"
implementation "org.jogamp.gluegen:gluegen-rt:$joglVersion:natives-linux-aarch64"
// implementation "org.jogamp.gluegen:gluegen-rt:$joglVersion:natives-macosx-universal"
// implementation "org.jogamp.gluegen:gluegen-rt:$joglVersion:natives-windows-amd64"
// implementation "org.jogamp.jogl:jogl-all:$joglVersion:natives-linux-amd64"
// implementation "org.jogamp.jogl:jogl-all:$joglVersion:natives-linux-armv6hf"
implementation "org.jogamp.jogl:jogl-all:$joglVersion:natives-linux-aarch64"
// implementation "org.jogamp.jogl:jogl-all:$joglVersion:natives-macosx-universal"
// implementation "org.jogamp.jogl:jogl-all:$joglVersion:natives-windows-amd64"
// WPILib stuff
implementation "edu.wpi.first.wpiutil:wpiutil-java:$wpilibVersion"
implementation "edu.wpi.first.cameraserver:cameraserver-java:$wpilibVersion"
implementation "edu.wpi.first.cscore:cscore-java:$wpilibVersion"
compile "edu.wpi.first.cscore:cscore-jni:$wpilibVersion:linuxaarch64bionic"
compile "edu.wpi.first.cscore:cscore-jni:$wpilibVersion:linuxraspbian"
compile "edu.wpi.first.cscore:cscore-jni:$wpilibVersion:linuxx86-64"
compile "edu.wpi.first.cscore:cscore-jni:$wpilibVersion:osxx86-64"
compile "edu.wpi.first.cscore:cscore-jni:$wpilibVersion:windowsx86-64"
implementation "edu.wpi.first.ntcore:ntcore-java:$wpilibVersion"
compile "edu.wpi.first.ntcore:ntcore-jni:$wpilibVersion:linuxaarch64bionic"
compile "edu.wpi.first.ntcore:ntcore-jni:$wpilibVersion:linuxraspbian"
compile "edu.wpi.first.ntcore:ntcore-jni:$wpilibVersion:linuxx86-64"
compile "edu.wpi.first.ntcore:ntcore-jni:$wpilibVersion:osxx86-64"
compile "edu.wpi.first.ntcore:ntcore-jni:$wpilibVersion:windowsx86-64"
implementation "edu.wpi.first.thirdparty.frc2020.opencv:opencv-java:$openCVVersion"
compile "edu.wpi.first.thirdparty.frc2020.opencv:opencv-jni:$openCVVersion:linuxaarch64bionic"
compile "edu.wpi.first.thirdparty.frc2020.opencv:opencv-jni:$openCVVersion:linuxraspbian"
compile "edu.wpi.first.thirdparty.frc2020.opencv:opencv-jni:$openCVVersion:linuxx86-64"
compile "edu.wpi.first.thirdparty.frc2020.opencv:opencv-jni:$openCVVersion:osxx86-64"
compile "edu.wpi.first.thirdparty.frc2020.opencv:opencv-jni:$openCVVersion:windowsx86-64"
compile "org.slf4j:slf4j-simple:1.8.0-beta4"
Pipeline Bringup (#94) * Refactor package structure, various cleanups * Add pipeline classes, settings, separate enums * updated Largest ContourSortMode and added centermost * Add DriverPipeline classes, apply spotless * Add crosshair to DriverMode, cleanups * Add FrameStaticProperties as member in Frame Add FrameStaticProperties as member in Frame * Finish ReflectivePipeline, various tweaks * Apply Spotless * Move test images * add Releasable interface, implement in classes * add TestUtils class, move testimages * Refactor CVPipeline, add ReflectivePipelineTest * Fix ConcurrentModificationException bug in group contours pipe with potential targets * Resolve memory leaks due to unnecessary instantiation of Points * Apply spotless * Add CVMat, ReflectionUtils to help track rogue Mats * various cleanups, add DummyFrameConsumer * Add logback * Add slv4j logger to replace the current debugLogger I'm waiting on stuff to be less skeletoned to add more * Add perimeter, MatOfPoint2f getters to Contour * Create CornerDetectionPipe based on old solvePNPPipe * Add ContourShape class for approxPolyDp Start on ColoredShape tracking * Add point detection, fix convex hull calculation in Contour * Make Draw2dContours pipe respect showMultiple * Update Contour.java * Clean up draw 3d, fix convex hull bug in corner detection * Update geometry classes * Add lifecam calibration data * Implement solvePNP, bounding box top and bottom * Fix JSON mat bug and lifecam default calibration for tests, fix 3d drawing * run spotless * Refactor calibration into `common.calibration` * Update .gitignore * Add offset method to get2020Target * Various cleanups, add PipelineType enum * Apply spotless Co-authored-by: ori agranat <oriagranat9@gmail.com> Co-authored-by: Matt <matthew.morley.ca@gmail.com>
2020-04-12 18:37:14 -04:00
// Zip
compile "org.zeroturnaround:zt-zip:1.14"
2020-03-18 01:51:30 -04:00
// test stuff
testImplementation('org.junit.jupiter:junit-jupiter:5.6.0')
}
shadowJar {
configurations = [project.configurations.runtimeClasspath]
archiveFileName.set("photonvision-${project.version}.jar")
}
2020-03-18 01:51:30 -04:00
test {
2020-06-12 04:36:19 -04:00
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
}
}
2020-06-12 04:36:19 -04:00
task testHeadless(type: Test) {
group = 'verification'
2020-06-12 04:36:19 -04:00
systemProperty("java.awt.headless", "true")
useJUnitPlatform()
}
task runNpmOnClient(type: Exec) {
workingDir "${projectDir}/../photon-client"
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
commandLine 'cmd', '/c', 'npm run build'
} else {
commandLine 'npm', 'run', 'build'
}
}
task copyClientUIToResources(type: Copy) {
from "${projectDir}/../photon-client/dist/"
into "${projectDir}/src/main/resources/web/"
}
task buildAndCopyUI {}
buildAndCopyUI.dependsOn copyClientUIToResources
copyClientUIToResources.dependsOn runNpmOnClient
copyClientUIToResources.shouldRunAfter runNpmOnClient
task generateJavaDocs(type: Javadoc) {
source = sourceSets.main.allJava
classpath = sourceSets.main.compileClasspath
destinationDir = file("${projectDir}/build/docs")
}
spotless {
java {
googleJavaFormat()
paddedCell()
indentWithTabs(2)
indentWithSpaces(4)
removeUnusedImports()
}
java {
target "src/*/java/org/**/*.java"
licenseHeaderFile "$rootDir/LicenseHeader.txt"
targetExclude("src/main/java/org/photonvision/PhotonVersion.java")
}
}
Add GPU Acceleration on the Raspberry Pi (#140) * Add native stuff * use runtimeloader * add more native methods * more stuff * Switch JNI methods to static * Remove non-java classes from the picam jni * Add gradle task for JNI generation * Migrate my previous GPU accel work * Initial work on defining JNI interface * Change libpicam to a symlink for now * Initial work on adding no-copy OMX GPU accel on the pi * Make DIRECT_OMX GPU accel mode not crash * Clean up OMX changes (still not getting valid data back) * Re-add GPU unit test * A couple debugging tweaks/notes * Add temporary special cases to get RGB out of ProcessingMode.NONE * Code clarity improvements; fix possible VBO bug * Get DIRECT_OMX working * Remove some debugging switches in GPUAccelerator * Pipe in VCSM stuff to read out pixels FAST * Apply Spotless * Revert versioningHelper changes * Add missing import * Convert to MMAL and move everything to native * Re-add shared object * Rework to use MMAL and do everything natively * Condense pipeline settings classes * Add OutputStreamPipeline * Apply spotless * Fix duplicate variable inits and add more video modes * Integrate color frames and latency measurements for GPU * Fix camera detection on pi and other platforms * Add proper color copy disabling and camera settings calls * Fix things that were broken by rebase * Fix spotless issues and remove uneeded prints * Remove libpicam symlink * Fix stream resolution limiting * Remove testing code in GPUAcceleratedHSVPipe * Make profiling options general to all computers * Make PicamJNI load from resources * run spotlessApply * Address review comments * Update Maven repo for JOGL * Fix release race condition * Only run GPU accel test on the pi * Lint fix and merge conflict accident fixes * Make Jackson ignore extra fields when unmarshalling HardwareConfig * Fix Mat releasing data race * Spotless apply * Remove broken header generation task * Fix shared library loading typo * Add a ZeroCopyPicam quirk to allow setting gain with the MMAL backend * Make sure that exposure/brightness/gain get set after res changes * Make rawInputMat properly local * Remove bogus set of shouldRun flag * Clean up small GPUHSVPipe print * Add in some things that missed the ZeroCopyPiCameraSource rename * Fix incorrect scoping introduced in past rebase * Don't filter out too-low resolutions * Only show latency when GPU accel is enabled * Don't free Mats in stream thread before we use them * Fix use-after-free and latency caluclation bugs on USB camera source * Update libpicam * Remove unwanted print * Add libpicam forceLoad in unit test * Fix streaming during camera calibration * Fix zerocopy Picam calculation * Use logger trace method instead of raw prints * Fix calibration and driver mode pipes with the Picam Co-authored-by: Matt <matthew.morley.ca@gmail.com> Co-authored-by: Banks Troutman <btrout.dhrs@gmail.com>
2020-12-08 02:34:21 -05:00
run {
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",
]
}
}
jacocoTestReport {
dependsOn test // Tests are required to run before generating the report
reports {
xml.enabled true
}
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it,
exclude: 'edu/wpi/**'
)
}))
}
}
remotes {
pi {
host = 'photonvision.local'
user = 'pi'
password = 'raspberry'
knownHosts = allowAnyHosts
}
gloworm {
host = 'gloworm.local'
user = 'pi'
password = 'raspberry'
knownHosts = allowAnyHosts
}
}
import java.io.*;
import java.net.*;
task findDeployTarget {
doLast {
if(project.hasProperty('tgtIP')){
//If user specificed IP, default to using the PI profile
// but adjust hostname to match the provided IP address
findDeployTarget.ext.rmt = remotes.pi
findDeployTarget.ext.rmt.host=tgtIP
} else {
findDeployTarget.ext.rmt = null
for(testRmt in remotes){
println "Checking for " + testRmt.host
boolean canContact = false;
try {
InetAddress testAddr = InetAddress.getByName(testRmt.host)
canContact = testAddr.isReachable(5000)
} catch(UnknownHostException e) {
canContact = false;
}
if(canContact){
println "Found!"
findDeployTarget.ext.rmt = testRmt
break
} else {
println "Not Found."
}
}
if(findDeployTarget.ext.rmt == null ){
throw new GradleException("Could not find a supported target for deployment!")
}
}
}
}
task deploy {
dependsOn assemble
dependsOn findDeployTarget
doLast {
println 'Starting deployment to ' + findDeployTarget.rmt.host
ssh.run{
session(findDeployTarget.rmt) {
//Stop photonvision before manipulating its files
execute 'sudo systemctl stop photonvision.service'
// 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
execute 'sleep 3'
// Copy into a folder owned by PI. Mostly because, as far as I can tell, the put command doesn't support sudo.
put from: "${projectDir}/build/libs/photonvision-${project.version}.jar", into: "/tmp/photonvision.jar"
//belt-and-suspenders. Make sure the old jar is gone first.
execute 'sudo rm -f /opt/photonvision/photonvision.jar'
//Copy in the new .jar and make sure it's executable
execute 'sudo mv /tmp/photonvision.jar /opt/photonvision/photonvision.jar'
execute 'sudo chmod +x /opt/photonvision/photonvision.jar'
//Fire up photonvision again
execute 'sudo systemctl start photonvision.service'
//Cleanup
execute 'sudo rm -f /tmp/photonvision.jar'
}
}
}
}