diff --git a/lib/jars/lock.rb b/lib/jars/lock.rb index c4fad5e..2eec475 100644 --- a/lib/jars/lock.rb +++ b/lib/jars/lock.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'jars/maven_exec' +require 'uri' module Jars class JarDetails < Array @@ -49,7 +50,8 @@ def path class Lock def initialize(file) - @file = file + # JRuby treats percent escapes literally in uri:file paths + @file = file.start_with?('uri:file:') ? URI::DEFAULT_PARSER.unescape(file) : file end def process(scope) diff --git a/specs/classpath_spec.rb b/specs/classpath_spec.rb index a2eee99..adfacbd 100644 --- a/specs/classpath_spec.rb +++ b/specs/classpath_spec.rb @@ -3,6 +3,7 @@ require File.expand_path('setup', File.dirname(__FILE__)) require 'yaml' +require 'tmpdir' module Helper def self.prepare!(array) @@ -207,6 +208,20 @@ def self.prepare(array) _(Helper.prepare(subject.classpath(:runtime))).must_equal Helper.prepare(lock_expected_runtime) end + it 'processes classloader Jars.lock URLs with spaces in the path' do + Dir.mktmpdir do |root| + dir = File.join(root, 'jar dependencies') + Dir.mkdir(dir) + lock = File.join(dir, 'Jars.lock') + File.write(lock, "org.slf4j:slf4j-simple:1.6.6:compile:\n") + url = "uri:file:#{URI::DEFAULT_PARSER.escape(lock)}" + + _(Jars::Classpath.new(nil, url).classpath).must_equal [ + File.join(Jars.home, 'org/slf4j/slf4j-simple/1.6.6/slf4j-simple-1.6.6.jar') + ] + end + end + it 'processes Jars.lock and block loading of jars' do subject.instance_variable_set(:@deps, jars_no_jline_lock)