Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump spotless version and update config for groovyGradle stuff #979

Merged
merged 3 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 33 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "com.diffplug.spotless" version "6.19.0"
id "com.diffplug.spotless" version "6.22.0"
id "com.github.johnrengelman.shadow" version "7.1.2"
id "com.github.node-gradle.node" version "3.1.1" apply false
id "edu.wpi.first.GradleJni" version "1.1.0"
Expand Down Expand Up @@ -49,6 +49,10 @@ wpilibTools.deps.wpilibVersion = wpilibVersion

spotless {
java {
target fileTree('.') {
include '**/*.java'
exclude '**/build/**', '**/build-*/**', "photon-core\\src\\main\\java\\org\\photonvision\\PhotonVersion.java", "photon-lib\\src\\main\\java\\org\\photonvision\\PhotonVersion.java"
}
toggleOffOn()
googleJavaFormat()
indentWithTabs(2)
Expand All @@ -57,10 +61,34 @@ spotless {
trimTrailingWhitespace()
endWithNewline()
}
java {
target "**/*.java"
targetExclude("photon-core/src/main/java/org/photonvision/PhotonVersion.java")
targetExclude("photon-lib/src/main/java/org/photonvision/PhotonVersion.java")
groovyGradle {
target fileTree('.') {
include '**/*.gradle'
exclude '**/build/**', '**/build-*/**'
}
greclipse()
indentWithSpaces(4)
trimTrailingWhitespace()
endWithNewline()
}
format 'xml', {
target fileTree('.') {
include '**/*.xml'
exclude '**/build/**', '**/build-*/**', "**/.idea/**"
}
eclipseWtp('xml')
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
format 'misc', {
target fileTree('.') {
include '**/*.md', '**/.gitignore'
exclude '**/build/**', '**/build-*/**'
}
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
}

Expand Down
14 changes: 7 additions & 7 deletions photon-lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,17 @@ task generateVendorJson() {
outputs.file photonlibFileOutput
inputs.file photonlibFileInput

println "Writing vendor JSON ${pubVersion} to $photonlibFileOutput"
println "Writing vendor JSON ${pubVersion} to $photonlibFileOutput"

if (photonlibFileOutput.exists()) {
photonlibFileOutput.delete()
}
photonlibFileOutput.parentFile.mkdirs()
if (photonlibFileOutput.exists()) {
photonlibFileOutput.delete()
}
photonlibFileOutput.parentFile.mkdirs()

def read = photonlibFileInput.text
def read = photonlibFileInput.text
.replace('${photon_version}', pubVersion)
.replace('${frc_year}', frcYear)
photonlibFileOutput.text = read
photonlibFileOutput.text = read

outputs.upToDateWhen { false }
}
Expand Down
20 changes: 11 additions & 9 deletions photon-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ dependencies {
}

shadowJar {
configurations = [project.configurations.runtimeClasspath]
configurations = [
project.configurations.runtimeClasspath
]
String name = "photonvision-${project.version}"
archiveClassifier.set(wpilibTools.platformMapper.currentPlatform.platformName)
archiveBaseName = "photonvision"
Expand Down Expand Up @@ -81,11 +83,11 @@ copyClientUIToResources.shouldRunAfter runNpmOnClient
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",
"-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",
]
}
}
Expand Down Expand Up @@ -143,7 +145,7 @@ task findDeployTarget {
}

run {
environment "PATH_PREFIX", "../"
environment "PATH_PREFIX", "../"
}

// task overrideToPi {
Expand All @@ -159,7 +161,7 @@ task deploy {
dependsOn assemble
dependsOn findDeployTarget

doLast {
doLast {
println 'Starting deployment to ' + findDeployTarget.rmt.host
println 'targetArch = ' + wpilibTools.platformMapper.currentPlatform.platformName
ssh.run{
Expand All @@ -170,7 +172,7 @@ task deploy {
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}-${wpilibTools.platformMapper.currentPlatform.platformName}.jar", into: "/tmp/photonvision.jar"
//belt-and-suspenders. Make sure the old jar is gone first.
//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'
Expand Down
16 changes: 8 additions & 8 deletions photonlib-cpp-examples/examples.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ def EXCLUDED_DIRS = ["bin", "build"]

// List all non-hidden directories not in EXCUDED_DIRS
ext.exampleFolderNames = file("${rootDir}")
.listFiles()
.findAll {
return (it.isDirectory()
&& !it.isHidden()
&& !(it.name in EXCLUDED_DIRS) && !it.name.startsWith(".")
&& it.toPath().resolve("build.gradle").toFile().exists())
}
.collect { it.name }
.listFiles()
.findAll {
return (it.isDirectory()
&& !it.isHidden()
&& !(it.name in EXCLUDED_DIRS) && !it.name.startsWith(".")
&& it.toPath().resolve("build.gradle").toFile().exists())
}
.collect { it.name }
6 changes: 5 additions & 1 deletion photonlib-java-examples/aimandrange/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ wpi.sim.addDriverstation()
// in order to make them all available at runtime. Also adding the manifest so WPILib
// knows where to look for our Robot Class.
jar {
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
from {
configurations.runtimeClasspath.collect {
it.isDirectory() ? it : zipTree(it)
}
}
manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
Expand Down
6 changes: 5 additions & 1 deletion photonlib-java-examples/aimattarget/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ wpi.sim.addDriverstation()
// in order to make them all available at runtime. Also adding the manifest so WPILib
// knows where to look for our Robot Class.
jar {
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
from {
configurations.runtimeClasspath.collect {
it.isDirectory() ? it : zipTree(it)
}
}
manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
Expand Down
16 changes: 8 additions & 8 deletions photonlib-java-examples/examples.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ def EXCLUDED_DIRS = ["bin", "build"]

// List all non-hidden directories not in EXCUDED_DIRS
ext.exampleFolderNames = file("${rootDir}")
.listFiles()
.findAll {
return (it.isDirectory()
&& !it.isHidden()
&& !(it.name in EXCLUDED_DIRS) && !it.name.startsWith(".")
&& it.toPath().resolve("build.gradle").toFile().exists())
}
.collect { it.name }
.listFiles()
.findAll {
return (it.isDirectory()
&& !it.isHidden()
&& !(it.name in EXCLUDED_DIRS) && !it.name.startsWith(".")
&& it.toPath().resolve("build.gradle").toFile().exists())
}
.collect { it.name }
6 changes: 5 additions & 1 deletion photonlib-java-examples/getinrange/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ wpi.sim.addDriverstation()
// in order to make them all available at runtime. Also adding the manifest so WPILib
// knows where to look for our Robot Class.
jar {
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
from {
configurations.runtimeClasspath.collect {
it.isDirectory() ? it : zipTree(it)
}
}
manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
Expand Down
6 changes: 5 additions & 1 deletion photonlib-java-examples/simaimandrange/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ wpi.sim.addDriverstation()
// in order to make them all available at runtime. Also adding the manifest so WPILib
// knows where to look for our Robot Class.
jar {
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
from {
configurations.runtimeClasspath.collect {
it.isDirectory() ? it : zipTree(it)
}
}
manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ wpi.sim.addDriverstation()
// in order to make them all available at runtime. Also adding the manifest so WPILib
// knows where to look for our Robot Class.
jar {
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
from {
configurations.runtimeClasspath.collect {
it.isDirectory() ? it : zipTree(it)
}
}
manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
Expand Down
2 changes: 1 addition & 1 deletion shared/common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jacocoTestReport {
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it,
exclude: "edu/wpi/**"
exclude: "edu/wpi/**"
)
}))
}
Expand Down
5 changes: 2 additions & 3 deletions shared/config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ ext.createComponentZipTasks = { components, names, base, type, project, func ->
if (it in NativeLibrarySpec && stringNames.contains(it.name)) {
it.binaries.each {
if (!it.buildable) return
def target = nativeUtils.getPublishClassifier(it)
def target = nativeUtils.getPublishClassifier(it)
if (configMap.containsKey(target)) {
configMap.get(target).add(it)
} else {
Expand Down Expand Up @@ -128,7 +128,7 @@ ext.createAllCombined = { list, name, base, type, project ->

list.each {
if (it.name.endsWith('debug')) return
from project.zipTree(it.archiveFile)
from project.zipTree(it.archiveFile)
dependsOn it
}
}
Expand All @@ -140,7 +140,6 @@ ext.createAllCombined = { list, name, base, type, project ->
}

return task

}

// Create the standard ZIP format for the dependencies.
Expand Down
3 changes: 2 additions & 1 deletion versioningHelper.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

gradle.allprojects {
ext.getCurrentVersion = { ->
ext.getCurrentVersion = {
->
def stdout = new ByteArrayOutputStream()
String tagIsh
try {
Expand Down