Skip to content

Commit 793b0a3

Browse files
authored
[build] Migrate to Gradle version catalogs (#8524)
Also fixes the google compile-testing library to 0.23.0 (the latest available at time of writing) instead of a wildcard Jackson versions were inconsistent across projects; most were on 2.19.2, but the fields subproject was on 2.15.2. All projects are now on 2.19.2 for consistency
1 parent 8f9fc4d commit 793b0a3

File tree

18 files changed

+102
-44
lines changed

18 files changed

+102
-44
lines changed

benchmark/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ dependencies {
5757
implementation project(':wpiunits')
5858
implementation project(':wpiutil')
5959
annotationProcessor project(':epilogue-processor')
60-
implementation "org.openjdk.jmh:jmh-core:1.37"
61-
annotationProcessor "org.openjdk.jmh:jmh-generator-annprocess:1.37"
60+
implementation libs.jmh.core
61+
annotationProcessor libs.jmh.annotationprocessor
6262
}
6363

6464
tasks.withType(com.github.spotbugs.snom.SpotBugsTask).configureEach {

build.gradle

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,23 @@ buildscript {
1010

1111
plugins {
1212
id 'base'
13-
id 'org.wpilib.WPILibVersioningPlugin' version '2027.0.1'
14-
id 'org.wpilib.WPILibRepositoriesPlugin' version '2027.0.0'
15-
id 'org.wpilib.NativeUtils' apply false
16-
id 'org.wpilib.GradleJni' version '2027.0.0'
17-
id 'org.wpilib.GradleVsCode'
1813
id 'idea'
1914
id 'visual-studio'
20-
id 'net.ltgt.errorprone' version '4.3.0' apply false
21-
id 'com.gradleup.shadow' version '9.1.0' apply false
22-
id 'com.diffplug.spotless' version '8.0.0' apply false
23-
id 'com.github.spotbugs' version '6.4.2' apply false
15+
16+
alias(libs.plugins.wpilib.versioning)
17+
alias(libs.plugins.wpilib.repositories)
18+
// NativeUtils and GradleVsCode are on the classpath for buildSrc, which doesn't carry version information.
19+
// We're forced to use the string-based syntax here instead.
20+
id 'org.wpilib.NativeUtils' apply false
21+
id 'org.wpilib.GradleVsCode' apply false
22+
// alias(libs.plugins.wpilib.native.utils) apply false
23+
// alias(libs.plugins.wpilib.gradle.vscode)
24+
alias(libs.plugins.wpilib.gradle.jni)
25+
26+
alias(libs.plugins.build.shadow) apply false
27+
alias(libs.plugins.lint.errorprone) apply false
28+
alias(libs.plugins.lint.spotbugs) apply false
29+
alias(libs.plugins.lint.spotless) apply false
2430
}
2531

2632
wpilibVersioning.buildServerMode = project.hasProperty('buildServer')

buildSrc/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ repositories {
88
url = "https://plugins.gradle.org/m2/"
99
}
1010
}
11+
1112
dependencies {
12-
implementation "org.wpilib:native-utils:2027.1.1"
13+
implementation libs.wpilib.native.utils
14+
implementation libs.wpilib.gradle.vscode
1315
}

buildSrc/settings.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
dependencyResolutionManagement {
2+
versionCatalogs {
3+
create("libs") {
4+
from(files("../gradle/libs.versions.toml"))
5+
}
6+
}
7+
}

cameraserver/multiCameraServer/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ repositories {
3131
}
3232

3333
dependencies {
34-
implementation 'com.google.code.gson:gson:2.13.1'
34+
implementation libs.gson
3535

3636
implementation project(':wpiutil')
3737
implementation project(':wpinet')

commandsv2/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ dependencies {
2323
implementation project(':wpilibj')
2424
implementation project(':wpiannotations')
2525
api project(':datalog')
26-
testImplementation 'org.mockito:mockito-core:4.1.0'
26+
testImplementation libs.bundles.mockito
2727
annotationProcessor project(':javacPlugin')
2828
testAnnotationProcessor project(':javacPlugin')
2929
}

commandsv3/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ dependencies {
2525
implementation project(':hal')
2626
implementation project(':wpimath')
2727
implementation project(':wpilibj')
28-
api("us.hebi.quickbuf:quickbuf-runtime:1.4")
28+
api(libs.quickbuf.runtime)
2929
testAnnotationProcessor project(':javacPlugin')
3030
testAnnotationProcessor project(':epilogue-processor')
31-
testImplementation 'org.mockito:mockito-core:4.1.0'
31+
testImplementation(libs.bundles.mockito)
3232
testImplementation project(':epilogue-runtime')
3333
}
3434

epilogue-processor/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ dependencies {
1313
implementation(project(':epilogue-runtime'))
1414
api project(':commandsv2')
1515

16-
testImplementation 'com.google.testing.compile:compile-testing:+'
16+
testImplementation libs.compile.testing
1717
}

fields/build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ if (OperatingSystem.current().isWindows()) {
1414
}
1515

1616
dependencies {
17-
implementation "com.fasterxml.jackson.core:jackson-annotations:2.15.2"
18-
implementation "com.fasterxml.jackson.core:jackson-core:2.15.2"
19-
implementation "com.fasterxml.jackson.core:jackson-databind:2.15.2"
17+
implementation libs.bundles.jackson
2018
}
2119

2220
ext {

gradle/libs.versions.toml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
[versions]
2+
ejml = "0.44.0"
3+
jackson = "2.19.2"
4+
jmh = "1.37"
5+
opencv = "4.10.0-3"
6+
thirdparty-year = "frc2025" # Note: this also appears in the opencv module name in the libraries section
7+
quickbuf = "1.4"
8+
9+
[libraries]
10+
# General runtime dependencies
11+
ejml-simple = { module = "org.ejml:ejml-simple", version.ref = "ejml" } # also pulls in other EJML modules as transitive dependencies
12+
gson = { module = "com.google.code.gson:gson", version = "2.13.1" }
13+
jackson-annotations = { module = "com.fasterxml.jackson.core:jackson-annotations", version.ref = "jackson" }
14+
jackson-core = { module = "com.fasterxml.jackson.core:jackson-core", version.ref = "jackson" }
15+
jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "jackson" }
16+
quickbuf-runtime = { module = "us.hebi.quickbuf:quickbuf-runtime", version.ref = "quickbuf" }
17+
thirdparty-opencv = { module = "edu.wpi.first.thirdparty.frc2025.opencv:opencv-java", version.ref = "opencv" }
18+
19+
# General test dependencies
20+
compile-testing = { module = "com.google.testing.compile:compile-testing", version = "0.23.0" }
21+
jmh-annotationprocessor = { module = "org.openjdk.jmh:jmh-generator-annprocess", version.ref = "jmh" }
22+
jmh-core = { module = "org.openjdk.jmh:jmh-core", version.ref = "jmh" }
23+
junit-api = { module = "org.junit.jupiter:junit-jupiter", version = "5.13.4" }
24+
junit-launcher = { module = "org.junit.platform:junit-platform-launcher", version = "1.10.1" }
25+
mockito-core = { module = "org.mockito:mockito-core", version = "4.1.0" }
26+
27+
# buildsrc dependencies
28+
# Note that these are also Gradle plugins and cannot be used with the plugin specification
29+
# due to their presence on the classpath without version information.
30+
wpilib-gradle-vscode = { module = "org.wpilib:gradle-cpp-vscode", version = "2027.0.0" }
31+
wpilib-native-utils = { module = "org.wpilib:native-utils", version = "2027.1.1" }
32+
33+
[bundles]
34+
ejml = ["ejml-simple"]
35+
jackson = ["jackson-annotations", "jackson-core", "jackson-databind"]
36+
mockito = ["mockito-core"]
37+
# junit api and launcher artifacts are different dependency types (implementation and runtime, respectively),
38+
# so it doesn't make sense to bundle them in a single "junit" bundle
39+
# Similar logic applies for JMH
40+
41+
[plugins]
42+
build-shadow = { id = "com.gradleup.shadow", version = "9.1.0" }
43+
lint-errorprone = { id = "net.ltgt.errorprone", version = "4.3.0" }
44+
lint-spotbugs = { id = "com.github.spotbugs", version = "6.4.2" }
45+
lint-spotless = { id = "com.diffplug.spotless", version = "8.0.0" }
46+
47+
wpilib-gradle-jni = { id = "org.wpilib.GradleJni", version = "2027.0.0" }
48+
# Note: these plugins can't be used. Their JARs are on the classpath for buildSrc,
49+
# which doesn't retain version information.
50+
# wpilib-gradle-vscode = { id = "org.wpilib.GradleVsCode", version = "2027.0.0" }
51+
# wpilib-native-utils = { id = "org.wpilib.NativeUtils", version = "2027.1.1" }
52+
wpilib-repositories = { id = "org.wpilib.WPILibRepositoriesPlugin", version = "2027.0.0" }
53+
wpilib-versioning = { id = "org.wpilib.WPILibVersioningPlugin", version = "2027.0.1" }

0 commit comments

Comments
 (0)