|
| 1 | +plugins { |
| 2 | + // Apply the application plugin to add support for building a CLI application in Java. |
| 3 | + id 'application' |
| 4 | +} |
| 5 | + |
| 6 | +repositories { |
| 7 | + // Use Maven Central for resolving dependencies. |
| 8 | + mavenCentral() |
| 9 | + maven { |
| 10 | + url = uri("https://frcmaven.wpi.edu/artifactory/release") |
| 11 | + } |
| 12 | +} |
| 13 | + |
| 14 | +dependencies { |
| 15 | + implementation 'edu.wpi.first.cameraserver:cameraserver-java:2025.2.1' |
| 16 | + implementation 'edu.wpi.first.cscore:cscore-java:2025.2.1' |
| 17 | + implementation 'edu.wpi.first.wpilibj:wpilibj-java:2025.2.1' |
| 18 | + implementation 'org.openpnp:opencv:4.6.0-0' // available for download up to 4.9.0 but APT only goes up to 4.6 |
| 19 | + implementation 'edu.wpi.first.ntcore:ntcore-java:2024.3.2' |
| 20 | + implementation 'edu.wpi.first.wpiutil:wpiutil-java:2024.3.2' |
| 21 | + implementation 'edu.wpi.first.wpinet:wpinet-java:2024.3.2' |
| 22 | + implementation 'edu.wpi.first.wpimath:wpimath-java:2024.3.2' |
| 23 | + implementation 'com.google.code.gson:gson:2.11.0' |
| 24 | + |
| 25 | +// runtimeOnly 'edu.wpi.first.cscore:cscorejni:2025.2.1:linuxx86-64' |
| 26 | + runtimeOnly 'edu.wpi.first.wpiunits:wpiunits-java:2024.3.2' // needed for wpimath |
| 27 | + runtimeOnly 'edu.wpi.first.ntcore:ntcore-jni:2024.3.2:linuxarm64' // needed for ntcore |
| 28 | + runtimeOnly 'edu.wpi.first.wpiutil:wpiutil-jni:2024.3.2:linuxarm64' // needed for ntcore |
| 29 | + runtimeOnly 'edu.wpi.first.wpinet:wpinet-jni:2024.3.2:linuxarm64' |
| 30 | + runtimeOnly 'edu.wpi.first.ntcore:ntcore-jni:2024.3.2:linuxx86-64' // needed for ntcore |
| 31 | + runtimeOnly 'edu.wpi.first.wpiutil:wpiutil-jni:2024.3.2:linuxx86-64' // needed for ntcore |
| 32 | + runtimeOnly 'edu.wpi.first.wpinet:wpinet-jni:2024.3.2:linuxx86-64' |
| 33 | + runtimeOnly 'edu.wpi.first.cscore:cscore-jni:2025.2.1:linuxx86-64' |
| 34 | + runtimeOnly 'com.fasterxml.jackson.core:jackson-core:2.18.0' // needed so wpiutil doesn't get upset |
| 35 | + runtimeOnly 'us.hebi.quickbuf:quickbuf-runtime:1.4' // needed so wpimath doesn't get upset |
| 36 | + runtimeOnly 'org.ejml:ejml-core:0.43.1' // needed for wpimath |
| 37 | +} |
| 38 | + |
| 39 | +// Apply a specific Java toolchain to ease working on different environments. |
| 40 | +java { |
| 41 | + toolchain { |
| 42 | + languageVersion = JavaLanguageVersion.of(17) |
| 43 | + } |
| 44 | +} |
| 45 | + |
| 46 | +application { |
| 47 | + // Define the main class for the application. |
| 48 | + mainClass = 'frc.drivercam.DrivercamMain' |
| 49 | + // Look, this is supposed to just make you able to attach JDB but for some reason I can't reproduce the crash when it's enabled |
| 50 | + // When disabled, there problems in the RectVisionLibrary, somewhere near or within the call to Imgproc.findContours call |
| 51 | + // There are segfaults, and we get errors directly from malloc and free-- it seems to be corrupting the allocation header |
| 52 | + // If anyone else wants to find out what caused this, good luck. |
| 53 | + applicationDefaultJvmArgs = ['-agentlib:jdwp=transport=dt_socket,server=y,suspend=n'] |
| 54 | +} |
| 55 | + |
| 56 | +tasks.register("setupRunScript") { |
| 57 | + dependsOn "compileJava" |
| 58 | + mkdir "$buildDir" |
| 59 | + def path = sourceSets.main.runtimeClasspath.asPath |
| 60 | + def f = file("$buildDir/run.sh") |
| 61 | + f.setText("#!/bin/sh\nexport CLASSPATH=\"$path\"\nexport LD_PRELOAD=\"\$(find \"\${NATIVECACHE:-\$HOME/.wpilib/nativecache}\" -name '*wpiutil*' | paste -sd :)\"\njava -agentlib:jdwp=transport=dt_socket,server=y,suspend=n frc.drivercam.DrivercamMain \"\$@\"") |
| 62 | + f.setExecutable(true) |
| 63 | +} |
| 64 | + |
| 65 | +tasks.named("build") { |
| 66 | + dependsOn "setupRunScript" |
| 67 | +} |
| 68 | + |
| 69 | +tasks.withType(JavaCompile) {} |
| 70 | + |
| 71 | +tasks.withType(JavaExec) { |
| 72 | + def found = fileTree(dir: System.properties["user.home"] + "/.wpilib/nativecache", include: "**/*wpiutil*").join ":" |
| 73 | + environment "LD_PRELOAD", found |
| 74 | +} |
0 commit comments