Skip to content

Fetch Chicory/ASM jars from Maven instead of bundling in gem#3019

Draft
soutaro wants to merge 4 commits into
masterfrom
claude/rbs-jruby-issue-rzltjw
Draft

Fetch Chicory/ASM jars from Maven instead of bundling in gem#3019
soutaro wants to merge 4 commits into
masterfrom
claude/rbs-jruby-issue-rzltjw

Conversation

@soutaro

@soutaro soutaro commented Jun 27, 2026

Copy link
Copy Markdown
Member

Summary

This change decouples jar dependency management from the gem distribution. Instead of bundling Chicory and ASM jars in the -java gem, they are now declared as jar-dependencies requirements and fetched from Maven Central at install time. This keeps the gem smaller and ensures all users resolve the same versions from a canonical source.

Key Changes

  • New lib/rbs/wasm/jars.rb: Centralized module defining Maven coordinates for all required and optional jars (Chicory 1.7.5 and ASM 9.9.1). Provides:

    • CHICORY_VERSION, ASM_VERSION constants
    • REQUIRED_JARS and OPTIONAL_JARS lists with [group, artifact, version] tuples
    • jar_requirements() method to generate jar-dependencies requirement strings
    • maven_url() helper to construct Maven Central download URLs
  • Updated lib/rbs/wasm/runtime.rb:

    • Removed hardcoded jar names and version constants (now in jars.rb)
    • Renamed jars_dir to local_jars_dir and made it return nil for installed gems (only returns a path when jars are vendored locally for development)
    • Refactored load_jars() to support two modes:
      • Local development: loads jars from lib/rbs/wasm/jars/ directory (set by rake wasm:vendor_jars)
      • Installed gem: uses require_jar from jar-dependencies to load jars from Maven
    • Added graceful error handling for optional AOT compiler jars
  • Updated rbs.gemspec:

    • Removed jar files from the gem's file list (no longer bundled)
    • Added jar-dependencies as a dependency for JRuby/Java platform
    • Dynamically generates spec.requirements from RBS::WASM.jar_requirements()
  • Updated Rakefile:

    • Simplified rake wasm:vendor_jars to use centralized coordinates from jars.rb
    • Updated task descriptions to clarify jars are only for source-based development, not shipped in the gem
  • Documentation updates: Updated docs/release.md and .gitignore comments to reflect that jars are fetched from Maven, not bundled

Implementation Details

  • The jars.rb module serves as the single source of truth for jar coordinates, consumed by:

    • The gemspec (for jar-dependencies declarations)
    • The runtime (for loading jars at startup)
    • The Rakefile (for development jar downloads)
  • Graceful degradation: optional AOT compiler jars are wrapped in error handling; missing jars just leave Chicory on the interpreter instead of failing the load

  • The local lib/rbs/wasm/jars/ directory remains gitignored and is only used when running tests from source

https://claude.ai/code/session_01RtMsDQEmuayTdn3rYsteYT

claude added 4 commits June 27, 2026 02:42
The WebAssembly-backed JRuby parser added in #2998 bundled all of the
Chicory and ASM jars (~1MB) inside the -java gem under
lib/rbs/wasm/jars. Shipping third-party jars bloats the gem and risks
loading conflicting copies when another gem ships the same jars.

Follow the established JRuby convention (e.g. Psych): declare the jars as
jar-dependencies requirements so they are fetched from Maven Central, the
canonical source, at gem install time. Only RBS's own build artifact
(rbs_parser.wasm) is shipped.

- lib/rbs/wasm/jars.rb: single source of truth for the Maven coordinates,
  shared by the gemspec, the runtime, and the vendoring rake task.
- rbs.gemspec: depend on jar-dependencies and add a `jar` requirement per
  coordinate; stop adding the jars to spec.files.
- runtime.rb: require_jar the coordinates for an installed gem; keep
  loading vendored jars by path when running from source.
- Rakefile: derive the vendor download URLs from the shared coordinates;
  the vendored dir is gitignored and only used to run the suite from
  source.

Refs #3018

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RtMsDQEmuayTdn3rYsteYT
Follow Psych's model more closely and drop the development-only branch:
the runtime now always loads the Chicory/ASM jars from the local Maven
repository (~/.m2) with require_jar, both for the installed gem and when
running from source.

- runtime.rb: load_jars just require_jars each coordinate; the local
  vendored-directory path and the shared coordinates helper are gone.
- Rakefile: `wasm:install_jars` runs Jars::Installer against rbs.gemspec
  to download the jars into ~/.m2 (the same path `gem install` uses),
  without copying them into the gem. Replaces the curl-based vendoring.
- jruby.yml: download the jars on JRuby (jar-dependencies resolves
  through the JVM), after building the wasm on CRuby.
- Remove lib/rbs/wasm/jars.rb; inline the coordinates in the gemspec and
  the runtime instead of abstracting them.

Refs #3018

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RtMsDQEmuayTdn3rYsteYT
jar-dependencies can generate the require_jar calls from the gem's `jar`
requirements, so the runtime no longer repeats the coordinate list that
the gemspec already declares.

- `rake wasm:install_jars` now runs Jars::Installer with its default
  require-file generation: it downloads the jars into ~/.m2 and writes
  lib/rbs_jars.rb (require_jar calls for the whole resolved set).
- runtime.rb: load_jars is just `require "rbs_jars"`.
- rbs.gemspec: ship the generated lib/rbs_jars.rb alongside
  rbs_parser.wasm; the `jar` requirements stay the single source.
- lib/rbs_jars.rb is a build artifact (gitignored, Steep-ignored,
  rebuilt in the Docker image and CI).

Refs #3018

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RtMsDQEmuayTdn3rYsteYT
Runtime loads the Chicory/ASM jars with a single `require "rbs_jars"`.
lib/rbs_jars.rb is committed and hand-maintained rather than generated:
jar-dependencies' require-file generator mangles the
`com.dylibso.chicory:runtime` artifact id into `jar` (the artifact name
collides with a Maven scope keyword), which would make the installed gem
fail to load Chicory's runtime jar. Omitting the "this is a generated
file" marker also stops jar-dependencies from overwriting the file at
gem install.

Verified on JRuby 10.0.6: `rake wasm:install_jars` resolves the `jar`
requirements to exactly these ten jars and downloads them into ~/.m2,
`require "rbs_jars"` loads them, and the Chicory classes the runtime uses
link successfully.

- runtime.rb: inline `require "rbs_jars"` (drop the load_jars method).
- Rakefile: install_jars forces the java platform (the installer skips
  non-java gems) and downloads only (the require file is hand-maintained).
- ship lib/rbs_jars.rb via git ls-files; drop its ignore entries.

Refs #3018

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RtMsDQEmuayTdn3rYsteYT
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.

2 participants