mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[build] Upgrade to Java 21 (#7547)
Signed-off-by: Jade Turner <spacey-sooty@proton.me> Co-authored-by: sciencewhiz <sciencewhiz@users.noreply.github.com>
This commit is contained in:
8
.bazelrc
8
.bazelrc
@@ -10,10 +10,10 @@ common --enable_workspace
|
||||
build --experimental_cc_static_library
|
||||
build --experimental_cc_shared_library
|
||||
|
||||
build --java_language_version=17
|
||||
build --java_runtime_version=roboriojdk_17
|
||||
build --tool_java_language_version=17
|
||||
build --tool_java_runtime_version=remotejdk_17
|
||||
build --java_language_version=21
|
||||
build --java_runtime_version=remotejdk_21
|
||||
build --tool_java_language_version=21
|
||||
build --tool_java_runtime_version=remotejdk_21
|
||||
|
||||
test --test_output=errors
|
||||
test --test_verbose_timeout_warnings
|
||||
|
||||
11
.github/workflows/bazel.yml
vendored
11
.github/workflows/bazel.yml
vendored
@@ -22,8 +22,8 @@ jobs:
|
||||
with: { fetch-depth: 0 }
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: 17
|
||||
distribution: 'temurin'
|
||||
java-version: 21
|
||||
architecture: x64
|
||||
|
||||
- id: Setup_build_buddy
|
||||
@@ -42,6 +42,11 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
with: { fetch-depth: 0 }
|
||||
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 21
|
||||
|
||||
- id: Setup_build_buddy
|
||||
uses: ./.github/actions/setup-build-buddy
|
||||
with:
|
||||
@@ -56,7 +61,7 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { name: "Linux", os: ubuntu-24.04, container: "wpilib/ubuntu-base:24.04", action: "test", config: "", }
|
||||
- { name: "Linux", os: ubuntu-24.04, container: "wpilib/systemcore-cross-ubuntu:2027-24.04", action: "test", config: "", }
|
||||
name: "${{ matrix.name }}"
|
||||
runs-on: ${{ matrix.os }}
|
||||
container: ${{ matrix.container }}
|
||||
|
||||
2
.github/workflows/cmake-android.yml
vendored
2
.github/workflows/cmake-android.yml
vendored
@@ -36,7 +36,7 @@ jobs:
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
java-version: 21
|
||||
|
||||
- name: Install sccache
|
||||
uses: mozilla-actions/sccache-action@v0.0.9
|
||||
|
||||
2
.github/workflows/cmake.yml
vendored
2
.github/workflows/cmake.yml
vendored
@@ -18,7 +18,7 @@ jobs:
|
||||
include:
|
||||
- os: ubuntu-24.04
|
||||
name: Linux
|
||||
container: wpilib/roborio-cross-ubuntu:2025-24.04
|
||||
container: wpilib/systemcore-cross-ubuntu:2027-24.04
|
||||
flags: "--preset with-java-and-sccache -DCMAKE_BUILD_TYPE=Release -DWITH_EXAMPLES=ON"
|
||||
- os: macOS-14
|
||||
name: macOS
|
||||
|
||||
2
.github/workflows/documentation.yml
vendored
2
.github/workflows/documentation.yml
vendored
@@ -24,7 +24,7 @@ jobs:
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
java-version: 21
|
||||
- name: Set environment variables (Development)
|
||||
run: |
|
||||
echo "BRANCH=development" >> $GITHUB_ENV
|
||||
|
||||
14
.github/workflows/gradle.yml
vendored
14
.github/workflows/gradle.yml
vendored
@@ -19,16 +19,16 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- container: wpilib/systemcore-cross-ubuntu:2025-24.04
|
||||
- container: wpilib/systemcore-cross-ubuntu:2027-24.04
|
||||
artifact-name: SystemCore
|
||||
build-options: "-Ponlylinuxsystemcore"
|
||||
- container: wpilib/raspbian-cross-ubuntu:bookworm-24.04
|
||||
- container: wpilib/raspbian-cross-ubuntu:2027-bookworm-24.04
|
||||
artifact-name: Arm32
|
||||
build-options: "-Ponlylinuxarm32"
|
||||
- container: wpilib/aarch64-cross-ubuntu:bookworm-24.04
|
||||
- container: wpilib/aarch64-cross-ubuntu:2027-bookworm-24.04
|
||||
artifact-name: Arm64
|
||||
build-options: "-Ponlylinuxarm64"
|
||||
- container: wpilib/ubuntu-base:24.04
|
||||
- container: wpilib/systemcore-cross-ubuntu:2027-24.04
|
||||
artifact-name: Linux
|
||||
build-options: "-Ponlylinuxx86-64"
|
||||
name: "Build - ${{ matrix.artifact-name }}"
|
||||
@@ -119,7 +119,7 @@ jobs:
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
java-version: 21
|
||||
architecture: ${{ matrix.architecture }}
|
||||
- name: Import Developer ID Certificate
|
||||
uses: wpilibsuite/import-signing-certificate@v2
|
||||
@@ -189,7 +189,7 @@ jobs:
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
java-version: 21
|
||||
- name: Set release environment variable
|
||||
run: echo "EXTRA_GRADLE_ARGS=-PreleaseMode" >> $GITHUB_ENV
|
||||
if: startsWith(github.ref, 'refs/tags/v2027')
|
||||
@@ -251,7 +251,7 @@ jobs:
|
||||
(github.ref == 'refs/heads/2027' || startsWith(github.ref, 'refs/tags/v2027'))
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
java-version: 21
|
||||
- name: Combine (2027)
|
||||
if: |
|
||||
github.repository == 'wpilibsuite/allwpilib' &&
|
||||
|
||||
2
.github/workflows/lint-format.yml
vendored
2
.github/workflows/lint-format.yml
vendored
@@ -94,7 +94,7 @@ jobs:
|
||||
name: "Java format"
|
||||
runs-on: ubuntu-24.04
|
||||
needs: [validation]
|
||||
container: wpilib/ubuntu-base:24.04
|
||||
container: wpilib/systemcore-cross-ubuntu:2027-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
|
||||
14
.github/workflows/sentinel-build.yml
vendored
14
.github/workflows/sentinel-build.yml
vendored
@@ -23,16 +23,16 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- container: wpilib/roborio-cross-ubuntu:2025-24.04
|
||||
artifact-name: Athena
|
||||
build-options: "-Ponlylinuxathena"
|
||||
- container: wpilib/raspbian-cross-ubuntu:bookworm-24.04
|
||||
- container: wpilib/systemcore-cross-ubuntu:2027-24.04
|
||||
artifact-name: SystemCore
|
||||
build-options: "-Ponlylinuxsystemcore"
|
||||
- container: wpilib/raspbian-cross-ubuntu:2027-bookworm-24.04
|
||||
artifact-name: Arm32
|
||||
build-options: "-Ponlylinuxarm32"
|
||||
- container: wpilib/aarch64-cross-ubuntu:bookworm-24.04
|
||||
- container: wpilib/aarch64-cross-ubuntu:2027-bookworm-24.04
|
||||
artifact-name: Arm64
|
||||
build-options: "-Ponlylinuxarm64"
|
||||
- container: wpilib/ubuntu-base:24.04
|
||||
- container: wpilib/systemcore-cross-ubuntu:2027-24.04
|
||||
artifact-name: Linux
|
||||
build-options: "-Ponlylinuxx86-64"
|
||||
name: "Build - ${{ matrix.artifact-name }}"
|
||||
@@ -112,7 +112,7 @@ jobs:
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
java-version: 21
|
||||
architecture: ${{ matrix.architecture }}
|
||||
- name: Import Developer ID Certificate
|
||||
uses: wpilibsuite/import-signing-certificate@v2
|
||||
|
||||
@@ -35,7 +35,7 @@ The protobuf library and compiler are needed for protobuf generation.
|
||||
|
||||
OpenCV needs to be findable by CMake. On systems like the Jetson, this is installed by default. Otherwise, you will need to build OpenCV from source and install it.
|
||||
|
||||
If you want JNI and Java, you will need a JDK of at least version 17 installed. In addition, you need a `JAVA_HOME` environment variable set properly and set to the JDK directory.
|
||||
If you want JNI and Java, you will need a JDK of at least version 21 installed. In addition, you need a `JAVA_HOME` environment variable set properly and set to the JDK directory.
|
||||
|
||||
If you are building with unit tests or simulation modules, you will also need an Internet connection for the initial setup process, as CMake will clone google-test and imgui from GitHub.
|
||||
|
||||
|
||||
@@ -42,11 +42,11 @@ Using Gradle makes building WPILib very straightforward. It only has a few depen
|
||||
|
||||
## Requirements
|
||||
|
||||
- [JDK 17](https://adoptium.net/temurin/releases/?version=17)
|
||||
- [JDK 21](https://adoptium.net/temurin/releases/?version=21)
|
||||
- Note that the JRE is insufficient; the full JDK is required
|
||||
- On Ubuntu, run `sudo apt install openjdk-17-jdk`
|
||||
- On Windows, install the JDK 17 .msi from the link above
|
||||
- On macOS, install the JDK 17 .pkg from the link above
|
||||
- On Ubuntu, run `sudo apt install openjdk-21-jdk`
|
||||
- On Windows, install the JDK 21 .msi from the link above
|
||||
- On macOS, install the JDK 21 .pkg from the link above
|
||||
- C++ compiler
|
||||
- On Linux, install GCC 11 or greater
|
||||
- On Windows, install [Visual Studio Community 2022](https://visualstudio.microsoft.com/vs/community/) and select the C++ programming language during installation (Gradle can't use the build tools for Visual Studio)
|
||||
|
||||
@@ -20,7 +20,7 @@ plugins {
|
||||
id 'net.ltgt.errorprone' version '3.1.0' apply false
|
||||
id 'com.gradleup.shadow' version '8.3.4' apply false
|
||||
id 'com.diffplug.spotless' version '6.20.0' apply false
|
||||
id 'com.github.spotbugs' version '6.0.2' apply false
|
||||
id 'com.github.spotbugs' version '6.1.13' apply false
|
||||
}
|
||||
|
||||
wpilibVersioning.buildServerMode = project.hasProperty('buildServer')
|
||||
@@ -111,8 +111,8 @@ subprojects {
|
||||
|
||||
plugins.withType(JavaPlugin) {
|
||||
java {
|
||||
sourceCompatibility = 17
|
||||
targetCompatibility = 17
|
||||
sourceCompatibility = 21
|
||||
targetCompatibility = 21
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ public class VisionRunner<P extends VisionPipeline> {
|
||||
public void runOnce() {
|
||||
Long id = CameraServerSharedStore.getCameraServerShared().getRobotMainThreadId();
|
||||
|
||||
if (id != null && Thread.currentThread().getId() == id) {
|
||||
if (id != null && Thread.currentThread().threadId() == id) {
|
||||
throw new IllegalStateException(
|
||||
"VisionRunner.runOnce() cannot be called from the main robot thread");
|
||||
}
|
||||
@@ -106,7 +106,7 @@ public class VisionRunner<P extends VisionPipeline> {
|
||||
public void runForever() {
|
||||
Long id = CameraServerSharedStore.getCameraServerShared().getRobotMainThreadId();
|
||||
|
||||
if (id != null && Thread.currentThread().getId() == id) {
|
||||
if (id != null && Thread.currentThread().threadId() == id) {
|
||||
throw new IllegalStateException(
|
||||
"VisionRunner.runForever() cannot be called from the main robot thread");
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ configurations {
|
||||
|
||||
task generateJavaDocs(type: Javadoc) {
|
||||
classpath += project(":wpilibj").sourceSets.main.compileClasspath
|
||||
options.links("https://docs.oracle.com/en/java/javase/17/docs/api/")
|
||||
options.links("https://docs.oracle.com/en/java/javase/21/docs/api/")
|
||||
options.links("https://docs.opencv.org/4.x/javadoc/")
|
||||
options.addStringOption("tag", "pre:a:Pre-Condition")
|
||||
options.addBooleanOption("Xdoclint/package:" +
|
||||
|
||||
@@ -40,7 +40,7 @@ import javax.tools.Diagnostic;
|
||||
"edu.wpi.first.epilogue.CustomLoggerFor",
|
||||
"edu.wpi.first.epilogue.Logged"
|
||||
})
|
||||
@SupportedSourceVersion(SourceVersion.RELEASE_17)
|
||||
@SupportedSourceVersion(SourceVersion.RELEASE_21)
|
||||
public class AnnotationProcessor extends AbstractProcessor {
|
||||
private static final String kCustomLoggerFqn = "edu.wpi.first.epilogue.CustomLoggerFor";
|
||||
private static final String kClassSpecificLoggerFqn =
|
||||
|
||||
@@ -103,7 +103,7 @@ configurations {
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.compilerArgs = [
|
||||
'--release',
|
||||
'17',
|
||||
'21',
|
||||
'-encoding',
|
||||
'UTF8',
|
||||
"-Werror",
|
||||
|
||||
@@ -5,7 +5,7 @@ if (project.hasProperty('skipJavaFormat')) {
|
||||
apply plugin: 'checkstyle'
|
||||
|
||||
checkstyle {
|
||||
toolVersion = "10.12.2"
|
||||
toolVersion = "10.26.1"
|
||||
configDirectory = file("${project.rootDir}/styleguide")
|
||||
config = resources.text.fromFile(new File(configDirectory.get().getAsFile(), "checkstyle.xml"))
|
||||
}
|
||||
|
||||
@@ -16,4 +16,6 @@ suppressions PUBLIC "-//Puppy Crawl//DTD Suppressions 1.1//EN"
|
||||
checks="MethodName" />
|
||||
<!-- Disable checkstyle for generated unit files -->
|
||||
<suppress files="wpiunits[/\\]src[/\\]generated.*" checks=".*"/>
|
||||
<suppress files="wpilibj[/\\]src[/\\]main[/\\]java[/\\]edu[/\\]wpi[/\\]first[/\\]wpilibj[/\\]I2C.java"
|
||||
checks="OverloadMethodsDeclarationOrder" />
|
||||
</suppressions>
|
||||
|
||||
@@ -37,20 +37,12 @@
|
||||
<Bug pattern="IS2_INCONSISTENT_SYNC" />
|
||||
<Source name="MechanismLigament2d.java" />
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="MS_CANNOT_BE_FINAL" />
|
||||
<Class name="edu.wpi.first.wpilibj.examples.pacgoat.Robot" />
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="MS_EXPOSE_REP" />
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="MS_MUTABLE_ARRAY" />
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="NM_CLASS_NAMING_CONVENTION" />
|
||||
<Source name="FRCNetComm.java" />
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="NS_DANGEROUS_NON_SHORT_CIRCUIT" />
|
||||
<Source name="ParallelCommandGroup.java" />
|
||||
@@ -156,4 +148,12 @@
|
||||
<Bug pattern="UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD" />
|
||||
<Class name="edu.wpi.first.epilogue.EpilogueConfiguration" />
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="SING_SINGLETON_HAS_NONPRIVATE_CONSTRUCTOR" />
|
||||
<Class name="edu.wpi.first.wpilibj2.command.CommandScheduler" />
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="SING_SINGLETON_HAS_NONPRIVATE_CONSTRUCTOR" />
|
||||
<Class name="~edu.wpi.first.math.geometry.Coordinate\w+" />
|
||||
</Match>
|
||||
</FindBugsFilter>
|
||||
|
||||
@@ -93,7 +93,7 @@ public abstract class RobotBase implements AutoCloseable {
|
||||
*/
|
||||
protected RobotBase() {
|
||||
final NetworkTableInstance inst = NetworkTableInstance.getDefault();
|
||||
m_threadId = Thread.currentThread().getId();
|
||||
m_threadId = Thread.currentThread().threadId();
|
||||
setupCameraServerShared();
|
||||
setupMathShared();
|
||||
// subscribe to "" to force persistent values to propagate to local
|
||||
|
||||
@@ -435,7 +435,6 @@ public final class StructGenerator {
|
||||
}
|
||||
|
||||
int size = 0;
|
||||
boolean failed = false;
|
||||
|
||||
for (final E constant : enumVariants) {
|
||||
final String name = constant.name();
|
||||
@@ -452,6 +451,8 @@ public final class StructGenerator {
|
||||
.filter(f -> !f.isEnumConstant() && !Modifier.isStatic(f.getModifiers()))
|
||||
.toList();
|
||||
|
||||
boolean failed = false;
|
||||
|
||||
for (final Field field : enumFields) {
|
||||
final Class<?> type = field.getType();
|
||||
final String name = field.getName();
|
||||
|
||||
Reference in New Issue
Block a user