Method: Jars.require_jars_lock!

Defined in:
lib/jar_dependencies.rb

.require_jars_lock!(scope = :runtime) ⇒ Object

[View source]

189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/jar_dependencies.rb', line 189

def require_jars_lock!( scope = :runtime )
  urls = jars_lock_from_class_loader
  if urls and urls.size > 0
    @@jars_lock = true
    # funny error during spec where it tries to load it again
    # and finds it as gem instead of the LOAD_PATH
    require 'jars/classpath' unless defined? Jars::Classpath
    done = []
    while done != urls do
      urls.each do |url|
        unless done.member?( url )
          Jars.debug { "--- load jars from uri #{url}" }
          classpath = Jars::Classpath.new( nil, "uri:#{url}" )
          classpath.require( scope )
          done << url
        end
      end
      urls = jars_lock_from_class_loader
    end
    no_more_warnings
  elsif jars_lock = Jars.lock_path
    Jars.debug { "--- load jars from #{jars_lock}" }
    @@jars_lock = jars_lock
    # funny error during spec where it tries to load it again
    # and finds it as gem instead of the LOAD_PATH
    require 'jars/classpath' unless defined? Jars::Classpath
    classpath = Jars::Classpath.new( nil, jars_lock )
    classpath.require( scope )
    no_more_warnings
  end
  Jars.debug {
    @@jars ||= {}
    loaded = @@jars.collect{ |k,v| "#{k}:#{v}" }
    "--- loaded jars ---\n\t#{loaded.join("\n\t")}"
  }
end