Add detect_scala_info_provider in .bazelproject#8193
Add detect_scala_info_provider in .bazelproject#8193julius-stripe wants to merge 1 commit intobazelbuild:ijwbfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello, 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 enhances the configuration options for Scala projects by introducing a new setting in Highlights
Changelog
Activity
Using Gemini Code AssistThe 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 by creating a comment using either
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 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new .bazelproject setting, detect_scala_info_provider, which allows users to opt-out of using the ScalaInfo provider for Scala target detection and fall back to an older heuristic-based method. This is useful for projects using older versions of rules_scala.
The changes include:
- A new
DetectScalaInfoProviderSectionto define the project view setting. - Integration of this setting into the aspect generation logic in
AspectTemplateWriter. - Updates to the list of supported sections and related tests.
The implementation looks correct and addresses the issue described. I have one suggestion to improve the newly added DetectScalaInfoProviderSection class by making it non-instantiable, which is a common best practice for utility classes.
| public class DetectScalaInfoProviderSection { | ||
| public static final SectionKey<Boolean, ScalarSection<Boolean>> KEY = | ||
| SectionKey.of("detect_scala_info_provider"); | ||
|
|
||
| public static final SectionParser PARSER = new BooleanSectionParser( | ||
| KEY, | ||
| """ | ||
| Set to false if using an older rules_scala version (e.g. @io_bazel_rules_scala) that \ | ||
| does not export ScalaInfo from scala/providers.bzl. When false, Scala targets are \ | ||
| detected using the rule-name prefix heuristic (ctx.rule.kind.startswith("scala")) \ | ||
| instead of the ScalaInfo provider. By default this is true. | ||
| """); | ||
| } |
There was a problem hiding this comment.
This class only contains static members and is not intended to be instantiated. It's a good practice to make such utility classes final and provide a private constructor to prevent instantiation.
| public class DetectScalaInfoProviderSection { | |
| public static final SectionKey<Boolean, ScalarSection<Boolean>> KEY = | |
| SectionKey.of("detect_scala_info_provider"); | |
| public static final SectionParser PARSER = new BooleanSectionParser( | |
| KEY, | |
| """ | |
| Set to false if using an older rules_scala version (e.g. @io_bazel_rules_scala) that \ | |
| does not export ScalaInfo from scala/providers.bzl. When false, Scala targets are \ | |
| detected using the rule-name prefix heuristic (ctx.rule.kind.startswith("scala")) \ | |
| instead of the ScalaInfo provider. By default this is true. | |
| """); | |
| } | |
| public final class DetectScalaInfoProviderSection { | |
| private DetectScalaInfoProviderSection() {} | |
| public static final SectionKey<Boolean, ScalarSection<Boolean>> KEY = | |
| SectionKey.of("detect_scala_info_provider"); | |
| public static final SectionParser PARSER = new BooleanSectionParser( | |
| KEY, | |
| """ | |
| Set to false if using an older rules_scala version (e.g. @io_bazel_rules_scala) that \ | |
| does not export ScalaInfo from scala/providers.bzl. When false, Scala targets are \ | |
| detected using the rule-name prefix heuristic (ctx.rule.kind.startswith("scala")) \ | |
| instead of the ScalaInfo provider. By default this is true. | |
| """); | |
| } |
There was a problem hiding this comment.
I followed the exact pattern in https://github.com/bazelbuild/intellij/blob/ijwb/base/src/com/google/idea/blaze/base/projectview/section/sections/AutomaticallyDeriveTargetsSection.java, not opinionated here, I can follow the suggestion if you would like
Checklist
Please note that the maintainers will not be reviewing this change until all checkboxes are ticked. See
the Contributions section in the README for more
details.
Discussion thread for this change
Issue number: #8182
Description of this change
Adds a new
.bazelprojectsectiondetect_scala_info_providerto opt into the older heuristic-based scala rule detection