Skip to content

Commit

Permalink
Merge pull request #83 from kares/master
Browse files Browse the repository at this point in the history
get test up to-date + minor fixes/refactorings
  • Loading branch information
kares authored Sep 11, 2024
2 parents 2e295f5 + 680d6db commit 04baf10
Show file tree
Hide file tree
Showing 18 changed files with 290 additions and 355 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

strategy:
matrix:
ruby-version: [jruby-9.3]
ruby-version: [jruby-9.3, jruby-9.4]

steps:
- uses: actions/checkout@v2
Expand All @@ -24,7 +24,7 @@ jobs:
bundler-cache: true
- name: Install dependencies
run: bundle install
- name: Run RuboCop
run: bundle exec rubocop
- name: Run test
run: bundle exec rake specs
run: jruby -Ilib -rbundler/setup -S rake specs
- name: Run RuboCop
run: jruby -Ilib -rbundler/setup -S rubocop lib
9 changes: 9 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,12 @@
source 'https://rubygems.org'

gemspec

group :development do
gem 'rake', require: false
gem 'ruby-debug', '~> 0.11', require: false

gem 'rubocop', '~> 1.50.2', require: false
gem 'rubocop-performance', require: false
gem 'rubocop-rake', require: false
end
63 changes: 0 additions & 63 deletions Gemfile.lock

This file was deleted.

7 changes: 1 addition & 6 deletions jar-dependencies.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ Gem::Specification.new do |s|

s.required_ruby_version = '>= 2.6'

s.add_development_dependency 'minitest', '~> 5.10.0'
s.add_development_dependency 'rake', '~> 13.0'
s.add_development_dependency 'rubocop', '~> 1.31'
s.add_development_dependency 'rubocop-performance', '~> 1.14'
s.add_development_dependency 'rubocop-rake', '~> 0.6'
s.add_development_dependency 'ruby-debug', '~> 0.11'
s.add_development_dependency 'minitest', '~> 5.10'
s.add_development_dependency 'ruby-maven', ruby_maven_version = '~> 3.3'

s.post_install_message = <<~TEXT
Expand Down
33 changes: 15 additions & 18 deletions lib/jar_dependencies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ def skip?
end

def require?
@require = nil unless instance_variable_defined?(:@require)
if @require.nil?
if (require = to_boolean(REQUIRE)).nil?
no_require = to_boolean(NO_REQUIRE)
Expand All @@ -105,7 +104,12 @@ def require?
attr_writer :require

def quiet?
(@silent ||= false) || to_boolean(QUIET)
@quiet = to_boolean(QUIET) if @quiet.nil?
@quiet
end

def no_more_warnings
@quiet = true
end

def jarfile
Expand All @@ -124,10 +128,6 @@ def vendor?
to_boolean(VENDOR)
end

def no_more_warnings
@silent = true
end

def freeze_loading
self.require = false
end
Expand Down Expand Up @@ -198,7 +198,7 @@ def local_maven_repo
end

def home
absolute(to_prop(HOME)) || local_maven_repo
@home ||= absolute(to_prop(HOME)) || local_maven_repo
end

def require_jars_lock!(scope = :runtime)
Expand Down Expand Up @@ -242,7 +242,7 @@ def setup(options = nil)
when Symbol
require_jars_lock!(options)
when Hash
@jars_home = options[:jars_home]
@home = options[:jars_home]
@jars_lock = options[:jars_lock]
require_jars_lock!(options[:scope] || :runtime)
else
Expand Down Expand Up @@ -341,18 +341,15 @@ def to_jar(group_id, artifact_id, version, classifier = nil)

def do_require(*args)
jar = to_jar(*args)
local = File.join(Dir.pwd, 'jars', jar)
vendor = File.join(Dir.pwd, 'vendor', 'jars', jar)
file = File.join(home, jar)
# use jar from local repository if exists
if File.exist?(file)
require file
# use jar from PWD/jars if exists
elsif File.exist?(local)
require local
# use jar from PWD/vendor/jars if exists
elsif File.exist?(vendor)
if File.exist?(vendor = File.join(Dir.pwd, 'vendor', 'jars', jar))
require vendor
# use jar from PWD/jars if exists
elsif File.exist?(local = File.join(Dir.pwd, 'jars', jar))
require local
# use jar from local repository if exists
elsif File.exist?(file = File.join(home, jar))
require file
else
# otherwise try to find it on the load path
require jar
Expand Down
4 changes: 2 additions & 2 deletions lib/jars/attach_jars_pom.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

# this file is maven DSL

(0..10_000).each do |i|
10_000.times do |i|
coord = ENV_JAVA["jars.#{i}"]
break unless coord

artifact = Maven::Tools::Artifact.from_coordinate(coord)
exclusions = []
(0..10_000).each do |j|
10_000.times do |j|
exclusion = ENV_JAVA["jars.#{i}.exclusions.#{j}"]
break unless exclusion

Expand Down
8 changes: 4 additions & 4 deletions lib/jars/gemspec_artifacts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def new(*args)
end
end

private
private

def convert(arg, low = nil, high = nil)
if arg.include?('~>')
Expand Down Expand Up @@ -58,7 +58,7 @@ def snapshot_version(val)
val
end
end
end
end
end

class GemspecArtifacts
Expand All @@ -83,7 +83,7 @@ def to_s
def initialize(line)
super()
line.gsub(/'"|^\s*\[|\]\s*$/, '').split(/,\s*/).each do |exclusion|
self.<< Exclusion.new(exclusion)
self << Exclusion.new(exclusion)
end
freeze
end
Expand All @@ -97,7 +97,7 @@ class Artifact
def initialize(options, *args)
@type, @group_id, @artifact_id, @classifier, @version, @exclusions = *args
options.each do |k, v|
instance_variable_set("@#{k}", v)
instance_variable_set(:"@#{k}", v)
end
end

Expand Down
4 changes: 3 additions & 1 deletion lib/jars/lock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ def version
end

def classifier
size == 5 ? nil : self[2]
return nil if size == 5

self[2]
end

def gacv
Expand Down
4 changes: 2 additions & 2 deletions lib/jars/maven_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def add_gem_to_load_path(name)

def requirement(name)
jars = Gem.loaded_specs['jar-dependencies']
dep = jars.nil? ? nil : jars.dependencies.detect { |d| d.name == name }
dep = jars&.dependencies&.detect { |d| d.name == name }
dep.nil? ? Gem::Requirement.create('>0') : dep.requirement
end

Expand All @@ -122,7 +122,7 @@ def install_gem(name, req)
inst.install(name, req).first
rescue => e
if Jars.verbose?
warn e.inspect.to_s
warn e.inspect
warn e.backtrace.join("\n")
end
raise "there was an error installing '#{name} (#{req})' " \
Expand Down
11 changes: 8 additions & 3 deletions lib/jars/maven_settings.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
# frozen_string_literal: true

require 'rubygems/uri_formatter'
module Jars
class MavenSettings
LINE_SEPARATOR = ENV_JAVA['line.separator']

class << self
def local_settings
@_jars_maven_local_settings_ = nil unless instance_variable_defined?(:@_jars_maven_local_settings_)
if @_jars_maven_local_settings_.nil? && (settings = Jars.absolute('settings.xml')) && File.exist?(settings)
@_jars_maven_local_settings_ = settings
if @_jars_maven_local_settings_.nil?
settings = Jars.absolute('settings.xml')
@_jars_maven_local_settings_ =
if settings && File.exist?(settings)
settings
else
false
end
end
@_jars_maven_local_settings_ || nil
end
Expand Down
2 changes: 1 addition & 1 deletion lib/jars/post_install_hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

if defined?(JRUBY_VERSION) && Gem.post_install_hooks.empty?
Gem.post_install do |gem_installer|
unless (ENV['JARS_SKIP'] || ENV_JAVA['jars.skip']) == 'true'
if ENV['JARS_SKIP'] != 'true' && ENV_JAVA['jars.skip'] != 'true'
require 'jars/installer'
jars = Jars::Installer.new(gem_installer.spec)
jars.ruby_maven_install_options = gem_installer.options || {}
Expand Down
Loading

0 comments on commit 04baf10

Please sign in to comment.