mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-21 01:01:41 +00:00
Cleanup project-wide gradle configuration.
removes native dependencies from java only projects
increases readability
Pass generated headers in setup instead of modifying model
80 lines
2.2 KiB
Groovy
80 lines
2.2 KiB
Groovy
plugins {
|
|
id 'edu.wpi.first.WpilibTools' version '1.3.0'
|
|
}
|
|
|
|
apply plugin: "edu.wpi.first.NativeUtils"
|
|
|
|
import java.nio.file.Path
|
|
|
|
ext {
|
|
nativeName = "photonlib"
|
|
includePhotonTargeting = true
|
|
// Include the generated Version file
|
|
generatedHeaders = "src/generate/native/include"
|
|
}
|
|
|
|
apply from: "${rootDir}/shared/javacpp/setupBuild.gradle"
|
|
apply from: "${rootDir}/versioningHelper.gradle"
|
|
|
|
// Include the version file in the distributed sources
|
|
cppHeadersZip {
|
|
from('src/generate/native/include') {
|
|
into '/'
|
|
}
|
|
}
|
|
|
|
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
|
|
|
|
println "Writing vendor JSON ${pubVersion} to $photonlibFileOutput"
|
|
|
|
if (photonlibFileOutput.exists()) {
|
|
photonlibFileOutput.delete()
|
|
}
|
|
photonlibFileOutput.parentFile.mkdirs()
|
|
|
|
def read = photonlibFileInput.text
|
|
.replace('${photon_version}', pubVersion)
|
|
.replace('${frc_year}', frcYear)
|
|
photonlibFileOutput.text = read
|
|
|
|
outputs.upToDateWhen { false }
|
|
}
|
|
|
|
build.mustRunAfter generateVendorJson
|
|
|
|
task writeCurrentVersion {
|
|
def versionFileIn = file("${rootDir}/shared/PhotonVersion.java.in")
|
|
writePhotonVersionFile(versionFileIn, Path.of("$projectDir", "src", "main", "java", "org", "photonvision", "PhotonVersion.java"),
|
|
versionString)
|
|
versionFileIn = file("${rootDir}/shared/PhotonVersion.h.in")
|
|
writePhotonVersionFile(versionFileIn, Path.of("$projectDir", "src", "generate", "native", "include", "PhotonVersion.h"),
|
|
versionString)
|
|
}
|
|
|
|
build.mustRunAfter writeCurrentVersion
|
|
|
|
def vendorJson = artifacts.add('archives', file("$photonlibFileOutput"))
|
|
|
|
model {
|
|
// Publish the vendordep json
|
|
publishing {
|
|
publications {
|
|
vendorjson(MavenPublication) {
|
|
artifact vendorJson
|
|
|
|
artifactId = "${nativeName}-json"
|
|
groupId = "org.photonvision"
|
|
version "1.0"
|
|
}
|
|
}
|
|
}
|
|
}
|