mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-19 00:41:41 +00:00
116 lines
3.4 KiB
Groovy
116 lines
3.4 KiB
Groovy
import java.nio.file.Path
|
|
|
|
apply plugin: "cpp"
|
|
apply plugin: "java"
|
|
apply plugin: "google-test-test-suite"
|
|
apply plugin: "edu.wpi.first.NativeUtils"
|
|
|
|
apply from: "${rootDir}/shared/config.gradle"
|
|
apply from: "${rootDir}/versioningHelper.gradle"
|
|
|
|
test {
|
|
useJUnitPlatform()
|
|
}
|
|
|
|
// Apply Java configuration
|
|
dependencies {
|
|
implementation project(":photon-targeting")
|
|
|
|
// WPILib non-JNI dependencies
|
|
implementation "edu.wpi.first.cscore:cscore-java:$wpilibVersion"
|
|
implementation "edu.wpi.first.cameraserver:cameraserver-java:$wpilibVersion"
|
|
implementation "edu.wpi.first.wpilibj:wpilibj-java:$wpilibVersion"
|
|
implementation "edu.wpi.first.wpiutil:wpiutil-java:$wpilibVersion"
|
|
implementation "edu.wpi.first.wpimath:wpimath-java:$wpilibVersion"
|
|
implementation "edu.wpi.first.thirdparty.frc2022.opencv:opencv-java:$opencvVersion"
|
|
|
|
// NTCore
|
|
implementation "edu.wpi.first.ntcore:ntcore-java:$wpilibVersion"
|
|
jniPlatforms.each { implementation "edu.wpi.first.ntcore:ntcore-jni:$wpilibVersion:$it" }
|
|
|
|
// HAL
|
|
implementation "edu.wpi.first.hal:hal-java:$wpilibVersion"
|
|
jniPlatforms.each { implementation "edu.wpi.first.hal:hal-jni:$wpilibVersion:$it"}
|
|
|
|
// Junit
|
|
testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.2")
|
|
testImplementation("org.junit.jupiter:junit-jupiter-params:5.6.2")
|
|
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.6.2")
|
|
}
|
|
|
|
// Set up exports properly
|
|
nativeUtils {
|
|
exportsConfigs {
|
|
// Main library is just default empty. This will export everything
|
|
Photon {
|
|
}
|
|
}
|
|
}
|
|
|
|
model {
|
|
components {
|
|
Photon(NativeLibrarySpec) {
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs "src/main/native/cpp"
|
|
include "**/*.cpp"
|
|
}
|
|
exportedHeaders {
|
|
srcDirs "src/main/native/include"
|
|
}
|
|
}
|
|
}
|
|
nativeUtils.useRequiredLibrary(it, "wpilib_shared")
|
|
}
|
|
}
|
|
testSuites {
|
|
cppTest(GoogleTestTestSuiteSpec) {
|
|
testing $.components.Photon
|
|
|
|
sources.cpp {
|
|
source {
|
|
srcDir "src/test/native/cpp"
|
|
include "**/*.cpp"
|
|
}
|
|
}
|
|
|
|
nativeUtils.useRequiredLibrary(it, "wpilib_executable_shared")
|
|
nativeUtils.useRequiredLibrary(it, "googletest_static")
|
|
}
|
|
}
|
|
}
|
|
|
|
def photonlibFileInput = file("src/generate/photonlib.json.in")
|
|
ext.photonlibFileOutput = file("$buildDir/generated/vendordeps/photonlib.json")
|
|
|
|
task generateVendorJson() {
|
|
description = "Generates the vendor JSON file"
|
|
group = "PhotonVision"
|
|
|
|
outputs.file photonlibFileOutput
|
|
inputs.file photonlibFileInput
|
|
|
|
doLast {
|
|
println "Writing version ${pubVersion} to $photonlibFileOutput"
|
|
|
|
if (photonlibFileOutput.exists()) {
|
|
photonlibFileOutput.delete()
|
|
}
|
|
def read = photonlibFileInput.text.replace('${photon_version}', pubVersion)
|
|
photonlibFileOutput.write(read)
|
|
}
|
|
}
|
|
|
|
build.dependsOn generateVendorJson
|
|
|
|
|
|
task writeCurrentVersionJava {
|
|
writePhotonVersionFile(Path.of("$projectDir", "src", "main", "java", "org", "photonvision", "PhotonVersion.java"),
|
|
versionString)
|
|
}
|
|
|
|
build.dependsOn writeCurrentVersionJava
|
|
|
|
apply from: "publish.gradle"
|