Conversation
- Update sbt version to 2.0.0-RC2 for Scala 3 cross-build - Enable sbt 2.x CI workflow tests - Add compatibility layer for sbt 1.x and 2.0 differences - Provide JsonFormat instances required by sbt 2.0 Note: Full sbt 2.0 compilation still requires additional work for HashWriter instances, but CI is now enabled to test compatibility. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Summary of Changes
Hello @xerial, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request upgrades the sbt version from 2.0.0-M4 to 2.0.0-RC2 to enable Scala 3 cross-compilation and facilitate the setup of a CI workflow for sbt 2.x testing. It introduces a compatibility layer to bridge differences between sbt 1.x and 2.0, specifically by adding JsonFormat instances and removing Def.derive wrappers that were problematic in sbt 2.0. While full sbt 2.0 compilation still requires further work, this change is crucial for initiating CI testing for sbt 2.0 compatibility.
Highlights
- sbt Version Upgrade: The project's sbt version has been updated from 2.0.0-M4 to 2.0.0-RC2 to support Scala 3 cross-compilation.
- sbt 2.x Compatibility Layer: New PluginCompat utilities have been introduced to handle differences between sbt 1.x and 2.0, including JsonFormat instances for FileRef and an uncached wrapper.
- CI Enablement: This PR lays the groundwork for enabling continuous integration for sbt 2.x, allowing for early testing of compatibility.
- Def.derive Removal: Def.derive wrappers have been removed from various sbt settings (packArchiveTgz, packLibJars, etc.) to resolve compatibility issues with sbt 2.0.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
Run scalafmtAll to ensure consistent code formatting across the project. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request upgrades sbt to 2.0.0-RC2 and introduces a compatibility layer to support both sbt 1.x and 2.0. The changes include updating the sbt version in build.sbt, adding compatibility shims in PluginCompat.scala for both Scala 2 and 3, and removing legacy Def.derive wrappers from task definitions.
My review has identified a critical issue in the sbt 2.0 compatibility layer (src/main/scala-3/xerial/sbt/pack/PluginCompat.scala) where the implementation of JsonFormat[FileRef] is incorrect and will lead to runtime errors. I've also pointed out a minor code style improvement. Overall, the direction of the changes is good, but the critical issue needs to be addressed for the sbt 2.0 support to be functional.
| override def read[J](jsOpt: Option[J], unbuilder: Unbuilder[J]): FileRef = { | ||
| val path = BasicJsonProtocol.StringJsonFormat.read(jsOpt, unbuilder) | ||
| conv.toVirtualFile(NioPath.of(path)) | ||
| } |
There was a problem hiding this comment.
The read method is declared to return a FileRef (which is an alias for HashedVirtualFileRef), but conv.toVirtualFile(NioPath.of(path)) returns a VirtualFile (specifically a PlainVirtualFile). This is a supertype of HashedVirtualFileRef and will likely cause a ClassCastException at runtime because a VirtualFile is not necessarily a HashedVirtualFileRef.
To correctly reconstruct a HashedVirtualFileRef, the contentHash is also required, but it's not being serialized in the write method. The write method only serializes the file path.
This same issue exists in the implicit conversion toFileRef on line 17, which is not part of this diff but is related.
While the PR note mentions that caching-related changes are still needed, this implementation is fundamentally incorrect and will cause runtime failures.
| toNioPaths(cp).map(_.toFile()) | ||
|
|
||
| // JSON formats for sbt 2.0 compatibility - provide all needed instances | ||
| import sjsonnew.{Builder, Unbuilder, JsonFormat} |
Summary
Changes
build.sbtto use sbt 2.0.0-RC2 for Scala 3.github/workflows/test.ymlDef.derivewrappers that were causing issues in sbt 2.0Note
Full sbt 2.0 compilation still requires additional work for HashWriter instances and other caching-related changes, but this PR enables CI to start testing sbt 2.0 compatibility.
Test plan
🤖 Generated with Claude Code