Skip to content

allow warbler to use locked jars from jar-dependencies #481

Description

@mkristian

jar-dependencies comes bundled with jruby and superseed jbundler. jbundler and jar-dependencies are using the same Jarfile but their lock file is different. jar-dependencies uses Jars.lock

With Jars.lock present and assuming jars resolution took place - buldler install - it is just a matter of using Jars::Lock.new("Jars.lock") to info to copy the jars into the war and maybe a jars loader (probably there are a few ways to require_jar the jars from the warfile)

Activity

  1. mkristian commented on Apr 23, 2020

    @mkristian
    MemberAuthor

    please on further question please ping me . . .

  2. headius commented on May 12, 2020

    @headius
    Member

    So basically we would switch the current logic from using JBundler to copy in the jars and instead use Jars::Lock?

  3. rwygand commented on Oct 5, 2021

    @rwygand

    This is something I'd be interested in leveraging, if it's still a pending feature request.

  4. mkristian commented on Nov 28, 2021

    @mkristian
    MemberAuthor

    @rwygand yes, this is still pending as:

    • jar-dependencies are shipped with jruby itself
    • jar-dependencies use the same Jarfile as jbunder, i.e. it is almost a dropin replacement
    • it makes no sense to have both jbundler and jar-dependencies as they offer the same features.

    please ping me if you need help

  5. jlahtinen commented on Oct 13, 2026

    @jlahtinen

    Can this be handled with config.java_libs += Jars::Classpath.new.classpath in warble.rb or is this something else?

  6. chadlwilson commented on Oct 13, 2026

    @chadlwilson
    Contributor

    @jlahtinen I'm not really an expert in jar-dependencies, but that is possibly a reasonable workaround if you know you have a Jars.lock there that will make it deterministic, and you are using bundler?

    I guess closing this would involve adding a small auto-discovered trait which does that automatically similar to how JBundler worked, but perhaps triggered on Jarfile or Jars.lock, but which we could make dependent on the bundler trait. Perhaps there are some niggles to address dealing with bundled jar-dependencies at warble-time vs the runtime jar-dependencies version that might be implied by ones bundle config; and maybe it's not necessary to add the libs manually, as long as they are made pre-available to jar-dependencies so they can be dynamically located at Bundle.setup time based on the locked or pre-supplied versions (rather than re-resolved)?

    def add_jbundler_jars
    require 'jbundler/config'
    classpath = ::JBundler::Config.new.classpath_file
    if File.exist?( classpath )
    require File.expand_path( classpath )
    else
    raise 'JBundler support needs JRuby to create a local config: jruby -S jbundle install'
    end
    # use only the jars from jbundler and jruby
    config.java_libs += jruby_jars
    config.java_libs += JBUNDLER_CLASSPATH
    config.java_libs.uniq! {|lib| lib.split(File::SEPARATOR).last }
    config.init_contents << "#{config.warbler_templates}/jbundler.erb"
    end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions