Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 10 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
plugins {
id "java"
id "com.diffplug.spotless" version "6.20.0"
id "net.ltgt.errorprone" version "4.0.1"
id "edu.wpi.first.GradleRIO" version "2025.3.2"
alias(libs.plugins.spotless)
alias(libs.plugins.errorprone)
alias(libs.plugins.wpilib)
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

def getProjectBooleanProperty(String name, boolean defaultValue = false) {
Expand Down Expand Up @@ -65,7 +66,8 @@ def includeDesktopSupport = true
// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
// Also defines JUnit 5.
dependencies {
compileOnly group: "com.google.errorprone", name: "error_prone_annotations", version: "2.28.0"
errorprone libs.errorprone.core
compileOnly libs.errorprone.annotations

annotationProcessor wpi.java.deps.wpilibAnnotations()
implementation wpi.java.deps.wpilib()
Expand All @@ -85,10 +87,8 @@ dependencies {
nativeRelease wpi.java.vendor.jniRelease(wpi.platforms.desktop)
simulationRelease wpi.sim.enableRelease()

testImplementation 'org.junit.jupiter:junit-jupiter:5.10.1'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

errorprone group: "com.google.errorprone", name: "error_prone_core", version: "2.28.0"
testImplementation libs.junit.jupiter
testRuntimeOnly libs.junit.platform.launcher
}

test {
Expand Down
73 changes: 37 additions & 36 deletions buildinfo.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import java.net.InetAddress;

task writeBuildInfo {
def hasGit = { ->
try {
exec {
executable 'git'
delegate.args '--version'
standardOutput = OutputStream.nullOutputStream()
}
} catch (Exception e) {
return false
}
return true
}
def hasGit = { ->
try {
def result = exec {
executable 'git'
args '--version'
standardOutput = OutputStream.nullOutputStream()
ignoreExitValue = true
}
return result.exitValue == 0
} catch (Exception e) {
return false
}
}

def addGitOutput = { PrintStream output, String name, String... args ->
output.println("### $name (git ${String.join(' ', args)})")
Expand All @@ -39,30 +40,30 @@ task writeBuildInfo {
return path
}

doLast {
try (PrintStream output = new PrintStream('src/main/deploy/build-info.txt')) {
output.println("### Host name (InetAddress.localHost.hostName)")
output.println(InetAddress.localHost.hostName)
output.println("### Project path (convertPath(projectDir.path))")
output.println(convertPath(projectDir.path))
if (!hasGit()) {
// ANSI escape codes
def WARNINGFMT = "\033[43;30m"
def CLEAR = "\033[m"
println("${WARNINGFMT}WARNING: Could not find git! Git info will not be sent to the robot.${CLEAR}")
output.println("### <could not run git>")
} else {
addGitOutput(output, 'Commit hash', 'log', '-1', '--format=%H')
addGitOutput(output, 'Refs to latest commit', 'log', '-1', '--format=%D')
addGitOutput(output, 'Commit time', 'log', '-1', '--format=%ad')
addGitOutput(output, 'Commit message', 'log', '-1', '--format=%B')
addGitOutput(output, 'Remotes', 'remote', '-v')
addGitOutput(output, 'Changed files', 'diff-index', '--name-only', 'HEAD', '--')
addGitOutput(output, 'Untracked files', 'ls-files', '--exclude-standard', '--others')
}
output.println('### (END)')
}
}
doLast {
new PrintStream('src/main/deploy/build-info.txt').withStream { output ->
output.println("### Host name (InetAddress.localHost.hostName)")
output.println(InetAddress.localHost.hostName)
output.println("### Project path (convertPath(projectDir.path))")
output.println(convertPath(projectDir.path))
if (!hasGit()) {
// ANSI escape codes
def WARNINGFMT = "\033[43;30m"
def CLEAR = "\033[m"
println("${WARNINGFMT}WARNING: Could not find git! Git info will not be sent to the robot.${CLEAR}")
output.println("### <could not run git>")
} else {
addGitOutput(output, 'Commit hash', 'log', '-1', '--format=%H')
addGitOutput(output, 'Refs to latest commit', 'log', '-1', '--format=%D')
addGitOutput(output, 'Commit time', 'log', '-1', '--format=%ad')
addGitOutput(output, 'Commit message', 'log', '-1', '--format=%B')
addGitOutput(output, 'Remotes', 'remote', '-v')
addGitOutput(output, 'Changed files', 'diff-index', '--name-only', 'HEAD', '--')
addGitOutput(output, 'Untracked files', 'ls-files', '--exclude-standard', '--others')
}
output.println('### (END)')
}
}
}
if (getProjectBooleanProperty('jarWriteBuildInfo', true)) {
jar.dependsOn(writeBuildInfo)
Expand Down
6 changes: 6 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Enable build caching
org.gradle.caching=true
# Enable parallel execution
org.gradle.parallel=true
# Configure JVM memory
org.gradle.jvmargs=-Xmx2g
24 changes: 24 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[versions]
wpilib = "2025.3.2"
spotless = "6.20.0"
errorpronePlugin = "4.0.1"
errorproneCore = "2.28.0"
errorproneAnnotations = "2.28.0"
junit = "5.10.1"
junitPlatform = "1.10.1"

[libraries]
wpilib-java = { module = "edu.wpi.first.gradle:edu.wpi.first.gradle.gradle.plugin", version.ref = "wpilib" }
spotless-plugin = { module = "com.diffplug.spotless:spotless-plugin-gradle", version.ref = "spotless" }
errorprone-plugin = { module = "net.ltgt.gradle:gradle-errorprone-plugin", version.ref = "errorpronePlugin" }

errorprone-annotations = { module = "com.google.errorprone:error_prone_annotations", version.ref = "errorproneAnnotations" }
errorprone-core = { module = "com.google.errorprone:error_prone_core", version.ref = "errorproneCore" }

junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit" }
junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher", version.ref = "junitPlatform" }

[plugins]
wpilib = { id = "edu.wpi.first.GradleRIO", version.ref = "wpilib" }
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
errorprone = { id = "net.ltgt.errorprone", version.ref = "errorpronePlugin" }
4 changes: 4 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,9 @@ pluginManagement {
}
}

plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
}

Properties props = System.getProperties();
props.setProperty("org.gradle.internal.native.headers.unresolved.dependencies.ignore", "true");