Skip to content
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
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

SamCarlberg
Copy link
Member

Resolves #7236

Non-modular Java dependencies (ejml, opencv) need a gradle plugin to add a module-info file to the JAR. I'm not sure if this is the correct approach, since those JARs won't be repacked and published for user programs to consume. Will need to test the artifacts to see if user programs will be broken

@SamCarlberg SamCarlberg requested review from PeterJohnson and a team as code owners November 22, 2024 02:45
Copy link
Contributor

This PR modifies commands. Please open a corresponding PR in Python Commands and include a link to this PR.

// 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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open discussion: wpilib.commands or wpilib.commands2? The module names already differ from the package names.

Copy link
Member

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 a commands3, 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 use commands.

Copy link
Member Author

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)

Copy link
Member

@calcmogul calcmogul Nov 22, 2024

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.

Copy link
Member Author

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

Copy link
Member

@calcmogul calcmogul Nov 23, 2024

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.

Copy link
Member

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.

Copy link
Member

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.

An older one was in the edu.wpi.first.math.util package, conflicting with the wpimath module
Single JAR means no split packages

Depends on lessthanoptimal/ejml#203 and local EJML artifacts
Place generated files in their own package, to avoid splitting the epilogue package between the runtime and user code

Explicitly scope CustomLoggerFor validations to TypeElements (would break on ModuleElements)
Otherwise, would probably need its own module to declare a `provides`
@SamCarlberg SamCarlberg requested a review from a team as a code owner December 4, 2024 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add module-info definitions for the Java libraries
5 participants