diff --git a/build.gradle b/build.gradle index f593638b90..d6ddaeaad4 100644 --- a/build.gradle +++ b/build.gradle @@ -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" @@ -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) @@ -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() } } diff --git a/photon-lib/build.gradle b/photon-lib/build.gradle index baae8fcc7d..d99ea5804a 100644 --- a/photon-lib/build.gradle +++ b/photon-lib/build.gradle @@ -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 } } diff --git a/photon-server/build.gradle b/photon-server/build.gradle index 92b50a81b8..4a8b1691f1 100644 --- a/photon-server/build.gradle +++ b/photon-server/build.gradle @@ -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" @@ -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", ] } } @@ -143,7 +145,7 @@ task findDeployTarget { } run { - environment "PATH_PREFIX", "../" + environment "PATH_PREFIX", "../" } // task overrideToPi { @@ -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{ @@ -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' diff --git a/photonlib-cpp-examples/examples.gradle b/photonlib-cpp-examples/examples.gradle index 976440f33f..1207d05f1d 100644 --- a/photonlib-cpp-examples/examples.gradle +++ b/photonlib-cpp-examples/examples.gradle @@ -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 } diff --git a/photonlib-java-examples/aimandrange/build.gradle b/photonlib-java-examples/aimandrange/build.gradle index 7dda3b59b0..f3750f10b2 100644 --- a/photonlib-java-examples/aimandrange/build.gradle +++ b/photonlib-java-examples/aimandrange/build.gradle @@ -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 } diff --git a/photonlib-java-examples/aimattarget/build.gradle b/photonlib-java-examples/aimattarget/build.gradle index 1442f184c9..d0f6ecfecc 100644 --- a/photonlib-java-examples/aimattarget/build.gradle +++ b/photonlib-java-examples/aimattarget/build.gradle @@ -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 } diff --git a/photonlib-java-examples/examples.gradle b/photonlib-java-examples/examples.gradle index 976440f33f..1207d05f1d 100644 --- a/photonlib-java-examples/examples.gradle +++ b/photonlib-java-examples/examples.gradle @@ -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 } diff --git a/photonlib-java-examples/getinrange/build.gradle b/photonlib-java-examples/getinrange/build.gradle index 7dda3b59b0..f3750f10b2 100644 --- a/photonlib-java-examples/getinrange/build.gradle +++ b/photonlib-java-examples/getinrange/build.gradle @@ -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 } diff --git a/photonlib-java-examples/simaimandrange/build.gradle b/photonlib-java-examples/simaimandrange/build.gradle index 7dda3b59b0..f3750f10b2 100644 --- a/photonlib-java-examples/simaimandrange/build.gradle +++ b/photonlib-java-examples/simaimandrange/build.gradle @@ -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 } diff --git a/photonlib-java-examples/swervedriveposeestsim/build.gradle b/photonlib-java-examples/swervedriveposeestsim/build.gradle index d0be7323ec..a4d1b60579 100644 --- a/photonlib-java-examples/swervedriveposeestsim/build.gradle +++ b/photonlib-java-examples/swervedriveposeestsim/build.gradle @@ -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 } diff --git a/shared/common.gradle b/shared/common.gradle index cb4ce3f80b..408889d2ba 100644 --- a/shared/common.gradle +++ b/shared/common.gradle @@ -89,7 +89,7 @@ jacocoTestReport { afterEvaluate { classDirectories.setFrom(files(classDirectories.files.collect { fileTree(dir: it, - exclude: "edu/wpi/**" + exclude: "edu/wpi/**" ) })) } diff --git a/shared/config.gradle b/shared/config.gradle index 3d5f91b150..f7c7c33c6b 100644 --- a/shared/config.gradle +++ b/shared/config.gradle @@ -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 { @@ -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 } } @@ -140,7 +140,6 @@ ext.createAllCombined = { list, name, base, type, project -> } return task - } // Create the standard ZIP format for the dependencies. diff --git a/versioningHelper.gradle b/versioningHelper.gradle index 4b085f3121..e9dd6e3d0a 100644 --- a/versioningHelper.gradle +++ b/versioningHelper.gradle @@ -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 {