-
Notifications
You must be signed in to change notification settings - Fork 611
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
[all java] Add Java module support #7424
Open
SamCarlberg
wants to merge
3
commits into
wpilibsuite:main
Choose a base branch
from
SamCarlberg:java-modules
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+301
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
module wpilib.apriltag { | ||
requires transitive wpilib.opencv; | ||
requires wpilib.math; | ||
requires wpilib.util; | ||
requires com.fasterxml.jackson.annotation; | ||
requires com.fasterxml.jackson.databind; | ||
|
||
exports edu.wpi.first.apriltag; | ||
exports edu.wpi.first.apriltag.jni; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
module wpilib.cameraserver { | ||
requires transitive wpilib.opencv; | ||
requires wpilib.cscore; | ||
requires wpilib.ntcore; | ||
requires wpilib.util; | ||
|
||
exports edu.wpi.first.cameraserver; | ||
exports edu.wpi.first.vision; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
module wpilib.cscore { | ||
requires wpilib.opencv; | ||
requires wpilib.util; | ||
|
||
exports edu.wpi.first.cscore; | ||
exports edu.wpi.first.cscore.raw; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
import javax.annotation.processing.Processor; | ||
|
||
module wpilib.epilogue.processor { | ||
requires java.compiler; | ||
requires jdk.compiler; | ||
requires wpilib.epilogue; | ||
|
||
provides Processor with | ||
edu.wpi.first.epilogue.processor.AnnotationProcessor; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
module wpilib.epilogue { | ||
requires wpilib.ntcore; | ||
requires wpilib.units; | ||
requires wpilib.util; | ||
|
||
exports edu.wpi.first.epilogue; | ||
exports edu.wpi.first.epilogue.logging; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
module wpilib.hal { | ||
requires wpilib.util; | ||
|
||
exports edu.wpi.first.hal; | ||
exports edu.wpi.first.hal.can; | ||
exports edu.wpi.first.hal.communication; | ||
exports edu.wpi.first.hal.simulation; | ||
exports edu.wpi.first.hal.util; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
module wpilib.ntcore { | ||
requires wpilib.util; | ||
|
||
exports edu.wpi.first.networktables; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
module wpilib.romi { | ||
requires transitive wpilib.wpilibj; | ||
requires wpilib.hal; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Patch legacy non-modularized dependencies to have module info | ||
extraJavaModuleInfo { | ||
module('edu.wpi.first.thirdparty.frc2024.opencv:opencv-java', 'wpilib.opencv') { | ||
exportAllPackages() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Patch legacy non-modularized dependencies to have module info | ||
extraJavaModuleInfo { | ||
module('org.ejml:ejml-core', 'ejml.core') { | ||
exportAllPackages() | ||
} | ||
module('org.ejml:ejml-simple', 'ejml.simple') { | ||
exportAllPackages() | ||
requiresTransitive('ejml.core') | ||
} | ||
module('org.ejml:ejml-fsparse', 'ejml.fsparse') { | ||
exportAllPackages() | ||
requiresTransitive('ejml.core') | ||
} | ||
module('org.ejml:ejml-dsparse', 'ejml.dsparse') { | ||
exportAllPackages() | ||
requiresTransitive('ejml.core') | ||
} | ||
module('org.ejml:ejml-fdense', 'ejml.fdense') { | ||
exportAllPackages() | ||
requiresTransitive('ejml.core') | ||
} | ||
module('org.ejml:ejml-ddense', 'ejml.ddense') { | ||
exportAllPackages() | ||
requiresTransitive('ejml.core') | ||
} | ||
module('org.ejml:ejml-cdense', 'ejml.cdense') { | ||
exportAllPackages() | ||
requiresTransitive('ejml.core') | ||
} | ||
module('org.ejml:ejml-zdense', 'ejml.zdense') { | ||
exportAllPackages() | ||
requiresTransitive('ejml.core') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
module wpilib.commands2 { | ||
requires wpilib.units; | ||
requires wpilib.wpilibj; | ||
requires wpilib.hal; | ||
requires wpilib.ntcore; | ||
|
||
exports edu.wpi.first.wpilibj2.command; | ||
exports edu.wpi.first.wpilibj2.command.button; | ||
exports edu.wpi.first.wpilibj2.command.sysid; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
module wpilib.wpilibj { | ||
requires ejml.core; | ||
requires ejml.simple; | ||
requires transitive wpilib.math; | ||
requires transitive wpilib.units; | ||
requires transitive wpilib.util; | ||
requires wpilib.hal; | ||
requires wpilib.ntcore; | ||
requires wpilib.cscore; | ||
requires wpilib.cameraserver; | ||
|
||
exports edu.wpi.first.wpilibj; | ||
exports edu.wpi.first.wpilibj.counter; | ||
exports edu.wpi.first.wpilibj.drive; | ||
exports edu.wpi.first.wpilibj.event; | ||
exports edu.wpi.first.wpilibj.internal; | ||
exports edu.wpi.first.wpilibj.livewindow; | ||
exports edu.wpi.first.wpilibj.motorcontrol; | ||
exports edu.wpi.first.wpilibj.shuffleboard; | ||
exports edu.wpi.first.wpilibj.simulation; | ||
exports edu.wpi.first.wpilibj.smartdashboard; | ||
exports edu.wpi.first.wpilibj.sysid; | ||
exports edu.wpi.first.wpilibj.util; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
module wpilib.math { | ||
requires com.fasterxml.jackson.annotation; | ||
requires ejml.core; | ||
requires ejml.ddense; | ||
requires ejml.simple; | ||
requires us.hebi.quickbuf.runtime; | ||
requires wpilib.units; | ||
requires wpilib.util; | ||
|
||
exports edu.wpi.first.math; | ||
exports edu.wpi.first.math.controller; | ||
exports edu.wpi.first.math.controller.proto; | ||
exports edu.wpi.first.math.controller.struct; | ||
exports edu.wpi.first.math.estimator; | ||
exports edu.wpi.first.math.filter; | ||
exports edu.wpi.first.math.geometry; | ||
exports edu.wpi.first.math.geometry.proto; | ||
exports edu.wpi.first.math.geometry.struct; | ||
exports edu.wpi.first.math.interpolation; | ||
exports edu.wpi.first.math.jni; // Probably unnecessary | ||
exports edu.wpi.first.math.kinematics; | ||
exports edu.wpi.first.math.kinematics.proto; | ||
exports edu.wpi.first.math.kinematics.struct; | ||
exports edu.wpi.first.math.optimization; | ||
exports edu.wpi.first.math.path; | ||
exports edu.wpi.first.math.proto; | ||
exports edu.wpi.first.math.spline; | ||
exports edu.wpi.first.math.spline.proto; | ||
exports edu.wpi.first.math.spline.struct; | ||
exports edu.wpi.first.math.struct; | ||
exports edu.wpi.first.math.system; | ||
exports edu.wpi.first.math.system.plant; | ||
exports edu.wpi.first.math.system.plant.proto; | ||
exports edu.wpi.first.math.system.plant.struct; | ||
exports edu.wpi.first.math.system.proto; | ||
exports edu.wpi.first.math.system.struct; | ||
exports edu.wpi.first.math.trajectory; | ||
exports edu.wpi.first.math.trajectory.constraint; | ||
exports edu.wpi.first.math.trajectory.proto; | ||
exports edu.wpi.first.math.util; | ||
exports edu.wpi.first.math.numbers; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
module wpilib.net { | ||
requires wpilib.util; | ||
|
||
exports edu.wpi.first.net; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
module wpilib.units { | ||
exports edu.wpi.first.units; | ||
exports edu.wpi.first.units.collections; | ||
exports edu.wpi.first.units.measure; | ||
exports edu.wpi.first.units.mutable; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
@SuppressWarnings("requires-transitive-automatic") | ||
module wpilib.util { | ||
requires com.fasterxml.jackson.databind; | ||
requires transitive us.hebi.quickbuf.runtime; | ||
|
||
exports edu.wpi.first.util; | ||
exports edu.wpi.first.util.cleanup; | ||
exports edu.wpi.first.util.concurrent; | ||
exports edu.wpi.first.util.datalog; | ||
exports edu.wpi.first.util.function; | ||
exports edu.wpi.first.util.protobuf; | ||
exports edu.wpi.first.util.sendable; | ||
exports edu.wpi.first.util.struct; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
module wpilib.xrp { | ||
requires transitive wpilib.wpilibj; | ||
requires wpilib.hal; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open discussion:
wpilib.commands
orwpilib.commands2
? The module names already differ from the package names.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commands2
makes sense if we plan on making acommands3
, unless there's some way to version it separately. If we can use vendordep versioning and prevent users from installing two versions at once, we could just usecommands
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commands2
makes the most sense. We'll have a commands3 in 2027, and each version is essentially a completely different library so reusing the same module name wouldn't be practical (or likely even possible)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That argument doesn't make sense to me. WPILib 2008 and 2024 look completely different, yet we still call it wpilibj. Major version numbers exist to represent things like major API refactors, so we should be using the major version for that instead of the library name itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because wpilib was changed gradually over time, without multiple incompatible versions concurrently being available for use. Commands v3 will probably be available side by side with v2 during a transition period
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the case for most libraries though, and they don't name their libraries like that. Giving them different names would allow users to use them both simultaneously, which we should explicitly disallow. Allowing that for v1 and v2 was a mistake due to the package naming confusion that introduced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An advantage of the numbered naming was that it made it very clear if classes were from v1 or v2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s actually quite common in Java to have versions in package names, sometimes as a subpackage name (eg commands.v1, commands.v2). The common recommendation however is to not put the version in the class name.