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
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ jobs:
- name: Run test
run: jruby -Ilib -rbundler/setup -S rake specs
- name: Run RuboCop
run: jruby -Ilib -rbundler/setup -S rubocop lib
if: matrix.ruby-version == 'jruby-10.0' # Only run RuboCop on modern JRuby; target older jrubies via .rubocop.yml
run: jruby -Ilib -rbundler/setup -S rubocop lib specs
3 changes: 2 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require:
plugins:
- rubocop-rake
- rubocop-performance
- rubocop-minitest

AllCops:
TargetRubyVersion: 2.6
Expand Down
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ group :development do
gem 'rake', require: false
gem 'ruby-debug', '~> 0.11', require: false

gem 'rubocop', '~> 1.50.0', require: false
gem 'rubocop', require: false
gem 'rubocop-minitest', require: false
gem 'rubocop-performance', require: false
gem 'rubocop-rake', require: false
end
2 changes: 1 addition & 1 deletion lib/jar_dependencies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def require?
if @require.nil?
if (require = to_boolean(REQUIRE)).nil?
no_require = to_boolean(NO_REQUIRE)
@require = no_require.nil? ? true : !no_require
@require = no_require.nil? || !no_require
else
@require = require
end
Expand Down
18 changes: 9 additions & 9 deletions lib/jars/gemspec_artifacts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def new(*args)
if low == high
low
else
super "#{low || '[0'},#{high || ')'}"
super("#{low || '[0'},#{high || ')'}")
end
end
end
Expand All @@ -26,17 +26,17 @@ def convert(arg, low = nil, high = nil)
["[#{snapshot_version(val)}", "#{snapshot_version(last)}]"]
elsif arg.include?('>=')
val = arg.sub(/>=\s*/, '')
["[#{snapshot_version(val)}", (nil || high)]
["[#{snapshot_version(val)}", high]
elsif arg.include?('<=')
val = arg.sub(/<=\s*/, '')
[(nil || low), "#{snapshot_version(val)}]"]
[low, "#{snapshot_version(val)}]"]
# treat '!' the same way as '>' since maven can not describe such range
elsif /[!>]/.match?(arg)
val = arg.sub(/[!>]\s*/, '')
["(#{snapshot_version(val)}", (nil || high)]
["(#{snapshot_version(val)}", high]
elsif arg.include?('<')
val = arg.sub(/<\s*/, '')
[(nil || low), "#{snapshot_version(val)})"]
[low, "#{snapshot_version(val)})"]
elsif arg.include?('=')
val = arg.sub(/=\s*/, '')
# for prereleased version pick the maven version (no version range)
Expand Down Expand Up @@ -133,12 +133,12 @@ def self.new(line)

if /[\[()\]]/.match?(line)
index = line.index(/[\[(].+$/)
version = line[index..].sub(/:/, ', ')
line = line[0..index - 1].strip.sub(/:$/, '')
version = line[index..].sub(':', ', ')
line = line[0..(index - 1)].strip.sub(/:$/, '')
else
index = line.index(/:[^:]+$/)
version = line[index + 1..]
line = line[0..index - 1].strip
version = line[(index + 1)..]
line = line[0..(index - 1)].strip
end

case line.count(':')
Expand Down
2 changes: 1 addition & 1 deletion lib/jars/gemspec_pom.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

def eval_file(file)
file = File.join(__dir__, file)
eval(File.read(file), nil, file) # rubocop:disable Security/Eval
eval(File.read(file), nil, file) # rubocop:disable Security/Eval
end

eval_file('attach_jars_pom.rb')
Expand Down
2 changes: 1 addition & 1 deletion lib/jars/lock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def process(scope)
File.read(@file).each_line do |line|
next unless /:.+:/.match?(line)

jar = JarDetails.new(line.strip.sub(/:jar:/, ':').sub(/:$/, ': ').split(':'))
jar = JarDetails.new(line.strip.sub(':jar:', ':').sub(/:$/, ': ').split(':'))
case scope
when :all, :test
yield jar
Expand Down
2 changes: 1 addition & 1 deletion lib/jars/lock_down.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def attach_jar_coordinates_from_bundler_dependencies(maven)
Bundler.setup('default')
maven.property('jars.bundler', true)
cwd = File.expand_path('.')
Gem.loaded_specs.each do |_name, spec|
Gem.loaded_specs.each_value do |spec|
# if gemspec is local then include all dependencies
maven.attach_jars(spec, all_dependencies: cwd == spec.full_gem_path)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/jars/output_jars_pom.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
if ENV_JAVA['jars.quiet'] != 'true'
model.dependencies.each do |d|
puts " #{d.group_id}:#{d.artifact_id}" \
"#{d.classifier ? ":#{d.classifier}" : ''}" \
"#{":#{d.classifier}" if d.classifier}" \
":#{d.version}:#{d.scope || 'compile'}"
next if d.exclusions.empty?

Expand Down
21 changes: 11 additions & 10 deletions specs/classpath_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,22 +142,23 @@ def self.prepare(array)
it 'resolves classpath_string from gemspec' do
ENV_JAVA['jars.quiet'] = 'true'
Dir.chdir(File.dirname(example_spec)) do
_(Helper.prepare(subject.classpath_string.split(File::PATH_SEPARATOR))).must_equal Helper.prepare(example_expected)
_(Helper.prepare(subject.classpath_string.split(File::PATH_SEPARATOR)))
.must_equal Helper.prepare(example_expected)

_(Helper.prepare(subject.classpath_string(:compile).split(File::PATH_SEPARATOR)))
.must_equal Helper.prepare(
expected_with_bc + ['org/slf4j/slf4j-simple/1.7.7/slf4j-simple-1.7.7.jar']
)
.must_equal Helper.prepare(
expected_with_bc + ['org/slf4j/slf4j-simple/1.7.7/slf4j-simple-1.7.7.jar']
)

_(Helper.prepare(subject.classpath_string(:test).split(File::PATH_SEPARATOR)))
.must_equal Helper.prepare(expected_with_bc + [
'junit/junit/4.12/junit-4.12.jar',
'org/slf4j/slf4j-simple/1.7.7/slf4j-simple-1.7.7.jar',
'org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar'
])
.must_equal Helper.prepare(expected_with_bc + [
'junit/junit/4.12/junit-4.12.jar',
'org/slf4j/slf4j-simple/1.7.7/slf4j-simple-1.7.7.jar',
'org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar'
])

_(Helper.prepare(subject.classpath_string(:runtime).split(File::PATH_SEPARATOR)))
.must_equal Helper.prepare(example_expected)
.must_equal Helper.prepare(example_expected)
end
end

Expand Down
4 changes: 2 additions & 2 deletions specs/jar_installer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def do_install(vendor, write)
File.read(jars).each_line do |line|
_(line).must_match(/^\s{2}require(_jar)?\s'.+'$/) if line.size > 30 && !line.match(/^#/)
end
_( Dir[File.join(dir, '**')].size ).must_equal 1
_(Dir[File.join(dir, '**')].size).must_equal 1
end

it 'generates vendored require-file' do
Expand All @@ -54,7 +54,7 @@ def do_install(vendor, write)
File.read(jars).each_line do |line|
_(line).must_match(/^\s{2}require(_jar)?\s'.+'$/) if line.size > 30 && !line.match(/^#/)
end
_( Dir[File.join(dir, '**', '*.jar')].size ).must_equal 45
_(Dir[File.join(dir, '**', '*.jar')].size).must_equal 45
end

it 'just skips install_jars and vendor_jars if there are no requirements' do
Expand Down
4 changes: 1 addition & 3 deletions specs/jars_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
begin
$stderr = StringIO.new

-> { require_jar('org.slf4j', 'slf4j-simple', '1.6.6') }.must_raise RuntimeError
_ { require_jar('org.slf4j', 'slf4j-simple', '1.6.6') }.must_raise RuntimeError

$stderr.flush

Expand Down Expand Up @@ -246,7 +246,6 @@
load File.expand_path('lib/jar_dependencies.rb')

_($stderr.string).must_equal ''

ensure
$stderr = STDERR
end
Expand All @@ -267,7 +266,6 @@
_($stderr.string).must_match(/omit version 2/)
_($stderr.string).must_match(/omit version 3/)
_($stderr.string).wont_match(/omit version 4/)

ensure
$stderr = STDERR

Expand Down