Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/jars/lock.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require 'jars/maven_exec'
require 'uri'

module Jars
class JarDetails < Array
Expand Down Expand Up @@ -49,7 +50,8 @@

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

Check warning on line 54 in lib/jars/lock.rb

View workflow job for this annotation

GitHub Actions / test (jruby-10.0, 21)

URI::RFC3986_PARSER.unescape is obsolete. Use URI::RFC2396_PARSER.unescape explicitly.

Check warning on line 54 in lib/jars/lock.rb

View workflow job for this annotation

GitHub Actions / test (jruby-10.0, 21)

URI::RFC3986_PARSER.unescape is obsolete. Use URI::RFC2396_PARSER.unescape explicitly.
end

def process(scope)
Expand Down
15 changes: 15 additions & 0 deletions specs/classpath_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require File.expand_path('setup', File.dirname(__FILE__))

require 'yaml'
require 'tmpdir'

module Helper
def self.prepare!(array)
Expand Down Expand Up @@ -207,6 +208,20 @@
_(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)}"

Check warning on line 217 in specs/classpath_spec.rb

View workflow job for this annotation

GitHub Actions / test (jruby-10.0, 21)

URI::RFC3986_PARSER.escape is obsolete. Use URI::RFC2396_PARSER.escape explicitly.

Check warning on line 217 in specs/classpath_spec.rb

View workflow job for this annotation

GitHub Actions / test (jruby-10.0, 21)

URI::RFC3986_PARSER.escape is obsolete. Use URI::RFC2396_PARSER.escape explicitly.

_(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)

Expand Down
Loading