[ANE] Add Bazel strategy for MODULE.bazel and maven_install.json#1655
Draft
[ANE] Add Bazel strategy for MODULE.bazel and maven_install.json#1655
Conversation
Add support for Bazel's modern Bzlmod dependency management system. This parses MODULE.bazel files for bazel_dep() entries and maven extension artifacts, maven_install.json lockfiles for transitive Maven dependencies, and optionally runs `bazel mod graph` for full resolved module graphs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add strategy documentation at docs/references/strategies/languages/bazel/. Add BazelModGraphSpec tests for `bazel mod graph` JSON parsing. Improve MavenInstallSpec with GraphUtil edge/direct assertions, v1 fallback tests, and coordinate format edge cases (jar, classifier). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The parser was failing on real projects (rules_jvm_external, rules_oci) due to Starlark features it couldn't skip past: bare string docstrings, list comprehensions, .format()/.replace() method chains, string concatenation with +/%, parenthesized expressions, and function calls used as values (e.g. use_repo_rule(...)). Also fixed otherStatement consuming subsequent top-level statements via a greedy skip loop. Tested against rules_oci (13 deps), bazel-examples (5 deps), and rules_jvm_external (16 bazel + 11 maven deps from maven_install.json). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
|
Whats the motivating reason for this? |
Contributor
|
Re: #1655 (comment) Preparation for Java ecosystem expansion deeper into enterprise customer environments -- supporting the known monorepo tooling for our primary languages |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds Bazel project support to fossa-cli, focused on the modern Bzlmod system (MODULE.bazel). Bazel 9 removed WORKSPACE entirely, making MODULE.bazel the only dependency management approach.
What's analyzed:
bazel_dep()entries from MODULE.bazel — dependencies from the Bazel Central Registrymaven_install.json— Coursier-resolved Maven artifacts with full transitive dependency graphmaven.install(artifacts=[...])from MODULE.bazel — direct Maven coordinates when no lockfile existsNew files:
src/Strategy/Bazel.hs— discovery, static analysis, project typessrc/Strategy/Bazel/ModuleBazel.hs— Megaparsec parser for the restricted Starlark subset in MODULE.bazelsrc/Strategy/Bazel/MavenInstall.hs— Aeson parser for maven_install.json lockfilessrc/Strategy/Bazel/Errors.hs— error types and documentation URLstest/Bazel/ModuleBazelSpec.hs— parser unit tests with multiple fixture variantstest/Bazel/MavenInstallSpec.hs— lockfile parser and graph building testsdocs/references/strategies/languages/bazel/bazel.md— strategy documentationModified files:
src/Types.hs—BazelProjectTypeadded toDiscoveredProjectTypesrc/DepTypes.hs—BazelRegistryTypeadded toDepTypesrc/App/Fossa/Analyze/Discover.hs— registered Bazel discoveryTested against real-world projects:
rules_oci— 13 bazel depsbazel-examples/bzlmod— 5 bazel depsrules_jvm_external— 16 bazel deps + 11 maven depsWhat's not yet implemented
bazel mod graph --output json) — follow-up PRTest plan
cabal build— no warningscabal test unit-tests -m Bazel— all parser and graph tests passfossa list-targetsshowsbazel@./for MODULE.bazel projectsfossa analyze -oagainst rules_oci, bazel-examples/bzlmod, rules_jvm_externalmake lint(fourmolu + hlint)🤖 Generated with Claude Code