jar-dependencies 0.4.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'jar_dependencies'
2
4
  require 'jars/maven_factory'
3
5
 
@@ -23,11 +25,11 @@ module Jars
23
25
  setup(spec)
24
26
  rescue StandardError, LoadError => e
25
27
  # If spec load fails, skip looking for jar-dependencies
26
- warn 'jar-dependencies: ' + e.to_s
28
+ warn "jar-dependencies: #{e}"
27
29
  warn e.backtrace.join("\n") if Jars.verbose?
28
30
  end
29
31
 
30
- def setup(spec = nil, allow_no_file = false)
32
+ def setup(spec = nil, allow_no_file: false)
31
33
  spec ||= find_spec(allow_no_file)
32
34
 
33
35
  case spec
@@ -35,23 +37,24 @@ module Jars
35
37
  @specfile = File.expand_path(spec)
36
38
  @basedir = File.dirname(@specfile)
37
39
  Dir.chdir(@basedir) do
38
- spec = eval(File.read(@specfile), TOPLEVEL_BINDING, @specfile)
40
+ spec = eval(File.read(@specfile), TOPLEVEL_BINDING, @specfile) # rubocop:disable Security/Eval
39
41
  end
40
42
  when Gem::Specification
41
- if File.exist?(spec.spec_file)
43
+ if File.exist?(spec.loaded_from)
42
44
  @basedir = spec.gem_dir
43
- @specfile = spec.spec_file
45
+ @specfile = spec.loaded_from
44
46
  else
45
47
  # this happens with bundle and local gems
46
48
  # there the spec_file is "not installed" but inside
47
49
  # the gem_dir directory
48
50
  Dir.chdir(spec.gem_dir) do
49
- setup(nil, true)
51
+ setup(nil, allow_no_file: true)
50
52
  end
51
53
  end
52
- when NilClass
54
+ when nil
55
+ # ignore
53
56
  else
54
- Jars.debug('spec must be either String or Gem::Specification. ' +
57
+ Jars.debug('spec must be either String or Gem::Specification. ' \
55
58
  'File an issue on github if you need it.')
56
59
  end
57
60
  @spec = spec
@@ -63,10 +66,10 @@ module Jars
63
66
 
64
67
  def resolve_dependencies_list(file)
65
68
  factory = MavenFactory.new(@options)
66
- maven = factory.maven_new(File.expand_path('../gemspec_pom.rb', __FILE__))
69
+ maven = factory.maven_new(File.expand_path('gemspec_pom.rb', __dir__))
67
70
 
68
71
  is_local_file = File.expand_path(File.dirname(@specfile)) == File.expand_path(Dir.pwd)
69
- maven.attach_jars(@spec, is_local_file)
72
+ maven.attach_jars(@spec, all_dependencies: is_local_file)
70
73
 
71
74
  maven['jars.specfile'] = @specfile.to_s
72
75
  maven['outputAbsoluteArtifactFilename'] = 'true'
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'jar_dependencies'
2
4
  require 'jars/gemspec_artifacts'
3
5
 
4
6
  module Jars
5
7
  class MavenFactory
6
8
  module AttachJars
7
- def attach_jars(spec, all_dependencies = false)
9
+ def attach_jars(spec, all_dependencies: false)
8
10
  @index ||= 0
9
11
  @done ||= []
10
12
 
@@ -63,17 +65,13 @@ module Jars
63
65
  end
64
66
  maven['verbose'] = (@debug || @verbose) == true
65
67
 
66
- if Jars.maven_settings
67
- maven.options['-s'] = Jars::MavenSettings.effective_settings
68
- end
68
+ maven.options['-s'] = Jars::MavenSettings.effective_settings if Jars.maven_settings
69
69
 
70
70
  maven['maven.repo.local'] = java.io.File.new(Jars.local_maven_repo).absolute_path.to_s
71
71
 
72
72
  maven
73
73
  end
74
74
 
75
- private
76
-
77
75
  def lazy_load_maven
78
76
  add_gem_to_load_path('ruby-maven')
79
77
  add_gem_to_load_path('ruby-maven-libs')
@@ -97,22 +95,22 @@ module Jars
97
95
  def add_gem_to_load_path(name)
98
96
  # if the gem is already activated => good
99
97
  return if Gem.loaded_specs[name]
98
+
100
99
  # just install gem if needed and add it to the load_path
101
100
  # and leave activated gems as they are
102
101
  req = requirement(name)
103
- unless spec = find_spec_via_rubygems(name, req)
102
+ unless (spec = find_spec_via_rubygems(name, req))
104
103
  spec = install_gem(name, req)
105
104
  end
106
- unless spec
107
- raise "failed to resolve gem '#{name}' if you're using Bundler add it as a dependency"
108
- end
105
+ raise "failed to resolve gem '#{name}' if you're using Bundler add it as a dependency" unless spec
106
+
109
107
  path = File.join(spec.full_gem_path, spec.require_path)
110
108
  $LOAD_PATH << path unless $LOAD_PATH.include?(path)
111
109
  end
112
110
 
113
111
  def requirement(name)
114
112
  jars = Gem.loaded_specs['jar-dependencies']
115
- dep = jars.nil? ? nil : jars.dependencies.detect { |d| d.name == name }
113
+ dep = jars&.dependencies&.detect { |d| d.name == name }
116
114
  dep.nil? ? Gem::Requirement.create('>0') : dep.requirement
117
115
  end
118
116
 
@@ -124,10 +122,11 @@ module Jars
124
122
  inst.install(name, req).first
125
123
  rescue => e
126
124
  if Jars.verbose?
127
- warn e.inspect.to_s
125
+ warn e.inspect
128
126
  warn e.backtrace.join("\n")
129
127
  end
130
- raise "there was an error installing '#{name} (#{req})' #{@options[:domain]}. please install it manually: #{e.inspect}"
128
+ raise "there was an error installing '#{name} (#{req})' " \
129
+ "#{@options[:domain]}. please install it manually: #{e.inspect}"
131
130
  end
132
131
  end
133
132
  end
@@ -1,27 +1,28 @@
1
- require 'rubygems/uri_formatter'
1
+ # frozen_string_literal: true
2
+
2
3
  module Jars
3
4
  class MavenSettings
4
5
  LINE_SEPARATOR = ENV_JAVA['line.separator']
5
6
 
6
7
  class << self
7
8
  def local_settings
8
- unless instance_variable_defined?(:@_jars_maven_local_settings_)
9
- @_jars_maven_local_settings_ = nil
10
- end
9
+ @_jars_maven_local_settings_ = nil unless instance_variable_defined?(:@_jars_maven_local_settings_)
11
10
  if @_jars_maven_local_settings_.nil?
12
- if settings = Jars.absolute('settings.xml')
13
- @_jars_maven_local_settings_ = settings if File.exist?(settings)
14
- end
11
+ settings = Jars.absolute('settings.xml')
12
+ @_jars_maven_local_settings_ =
13
+ if settings && File.exist?(settings)
14
+ settings
15
+ else
16
+ false
17
+ end
15
18
  end
16
19
  @_jars_maven_local_settings_ || nil
17
20
  end
18
21
 
19
22
  def user_settings
20
- unless instance_variable_defined?(:@_jars_maven_user_settings_)
21
- @_jars_maven_user_settings_ = nil
22
- end
23
+ @_jars_maven_user_settings_ = nil unless instance_variable_defined?(:@_jars_maven_user_settings_)
23
24
  if @_jars_maven_user_settings_.nil?
24
- if settings = Jars.absolute(Jars.to_prop(MAVEN_SETTINGS))
25
+ if (settings = Jars.absolute(Jars.to_prop(MAVEN_SETTINGS)))
25
26
  unless File.exist?(settings)
26
27
  Jars.warn { "configured ENV['#{MAVEN_SETTINGS}'] = '#{settings}' not found" }
27
28
  settings = false
@@ -36,9 +37,7 @@ module Jars
36
37
  end
37
38
 
38
39
  def effective_settings
39
- unless instance_variable_defined?(:@_jars_effective_maven_settings_)
40
- @_jars_effective_maven_settings_ = nil
41
- end
40
+ @_jars_effective_maven_settings_ = nil unless instance_variable_defined?(:@_jars_effective_maven_settings_)
42
41
  if @_jars_effective_maven_settings_.nil?
43
42
  begin
44
43
  require 'rubygems/request'
@@ -48,12 +47,11 @@ module Jars
48
47
  rescue
49
48
  Jars.debug('ignore rubygems proxy configuration as rubygems is too old')
50
49
  end
51
- if http.nil? && https.nil?
52
- @_jars_effective_maven_settings_ = settings
53
- else
54
- @_jars_effective_maven_settings_ =
55
- setup_interpolated_settings(http, https) || settings
56
- end
50
+ @_jars_effective_maven_settings_ = if http.nil? && https.nil?
51
+ settings
52
+ else
53
+ setup_interpolated_settings(http, https) || settings
54
+ end
57
55
  end
58
56
  @_jars_effective_maven_settings_
59
57
  end
@@ -69,18 +67,14 @@ module Jars
69
67
  end
70
68
 
71
69
  def settings
72
- unless instance_variable_defined?(:@_jars_maven_settings_)
73
- @_jars_maven_settings_ = nil
74
- end
70
+ @_jars_maven_settings_ = nil unless instance_variable_defined?(:@_jars_maven_settings_)
75
71
  local_settings || user_settings if @_jars_maven_settings_.nil?
76
72
  end
77
73
 
78
74
  def global_settings
79
- unless instance_variable_defined?(:@_jars_maven_global_settings_)
80
- @_jars_maven_global_settings_ = nil
81
- end
75
+ @_jars_maven_global_settings_ = nil unless instance_variable_defined?(:@_jars_maven_global_settings_)
82
76
  if @_jars_maven_global_settings_.nil?
83
- if mvn_home = ENV['M2_HOME'] || ENV['MAVEN_HOME']
77
+ if (mvn_home = ENV['M2_HOME'] || ENV['MAVEN_HOME'])
84
78
  settings = File.join(mvn_home, 'conf/settings.xml')
85
79
  settings = false unless File.exist?(settings)
86
80
  else
@@ -1,8 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # this file is maven DSL
2
4
 
3
5
  if ENV_JAVA['jars.quiet'] != 'true'
4
6
  model.dependencies.each do |d|
5
- puts ' ' + d.group_id + ':' + d.artifact_id + (d.classifier ? ':' + d.classifier : '') + ':' + d.version + ':' + (d.scope || 'compile')
6
- puts ' exclusions: ' + d.exclusions.collect { |e| e.group_id + ':' + e.artifact_id }.join unless d.exclusions.empty?
7
+ puts " #{d.group_id}:#{d.artifact_id}" \
8
+ "#{d.classifier ? ":#{d.classifier}" : ''}" \
9
+ ":#{d.version}:#{d.scope || 'compile'}"
10
+ next if d.exclusions.empty?
11
+
12
+ puts " exclusions: #{d.exclusions.collect do |e|
13
+ "#{e.group_id}:#{e.artifact_id}"
14
+ end.join}"
7
15
  end
8
16
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #
2
4
  # Copyright (C) 2014 Christian Meier
3
5
  #
@@ -21,7 +23,7 @@
21
23
 
22
24
  if defined?(JRUBY_VERSION) && Gem.post_install_hooks.empty?
23
25
  Gem.post_install do |gem_installer|
24
- unless (ENV['JARS_SKIP'] || ENV_JAVA['jars.skip']) == 'true'
26
+ if ENV['JARS_SKIP'] != 'true' && ENV_JAVA['jars.skip'] != 'true'
25
27
  require 'jars/installer'
26
28
  jars = Jars::Installer.new(gem_installer.spec)
27
29
  jars.ruby_maven_install_options = gem_installer.options || {}
data/lib/jars/setup.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # to do as bundler does and allow to load Jars.lock via
2
4
  # require 'jars/setup'. can be useful via commandline -rjars/setup
3
5
  # or tell bundler autorequire to load it
data/lib/jars/version.rb CHANGED
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Jars
2
- VERSION = '0.4.0'.freeze
3
- JRUBY_PLUGINS_VERSION = '1.1.3'.freeze
4
- DEPENDENCY_PLUGIN_VERSION = '2.8'.freeze
4
+ VERSION = '0.5.2'
5
+ JRUBY_PLUGINS_VERSION = '3.0.2'
6
+ DEPENDENCY_PLUGIN_VERSION = '2.8'
5
7
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #
2
4
  # Copyright (C) 2014 Christian Meier
3
5
  #
metadata CHANGED
@@ -1,75 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jar-dependencies
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - christian meier
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-02 00:00:00.000000000 Z
11
+ date: 2025-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- requirement: !ruby/object:Gem::Requirement
15
- requirements:
16
- - - "~>"
17
- - !ruby/object:Gem::Version
18
- version: '5.3'
19
14
  name: minitest
20
- prerelease: false
21
- type: :development
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '5.3'
27
- - !ruby/object:Gem::Dependency
28
- requirement: !ruby/object:Gem::Requirement
29
- requirements:
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: '0'
33
- name: pry
34
- prerelease: false
35
- type: :development
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
15
  requirement: !ruby/object:Gem::Requirement
43
16
  requirements:
44
17
  - - "~>"
45
18
  - !ruby/object:Gem::Version
46
- version: '10.2'
47
- name: rake
48
- prerelease: false
19
+ version: '5.10'
49
20
  type: :development
21
+ prerelease: false
50
22
  version_requirements: !ruby/object:Gem::Requirement
51
23
  requirements:
52
24
  - - "~>"
53
25
  - !ruby/object:Gem::Version
54
- version: '10.2'
26
+ version: '5.10'
55
27
  - !ruby/object:Gem::Dependency
28
+ name: ruby-maven
56
29
  requirement: !ruby/object:Gem::Requirement
57
30
  requirements:
58
31
  - - "~>"
59
32
  - !ruby/object:Gem::Version
60
- version: 3.3.11
61
- name: ruby-maven
62
- prerelease: false
33
+ version: '3.9'
63
34
  type: :development
35
+ prerelease: false
64
36
  version_requirements: !ruby/object:Gem::Requirement
65
37
  requirements:
66
38
  - - "~>"
67
39
  - !ruby/object:Gem::Version
68
- version: 3.3.11
69
- description: manage jar dependencies for gems and keep track which jar was already
70
- loaded using maven artifact coordinates. it warns on version conflicts and loads
71
- only ONE jar assuming the first one is compatible to the second one otherwise your
72
- project needs to lock down the right version by providing a Jars.lock file.
40
+ version: '3.9'
41
+ description: |
42
+ manage jar dependencies for gems and keep track which jar was already
43
+ loaded using maven artifact coordinates. it warns on version conflicts and
44
+ loads only ONE jar assuming the first one is compatible to the second one
45
+ otherwise your project needs to lock down the right version by providing a
46
+ Jars.lock file.
73
47
  email:
74
48
  - mkristian@web.de
75
49
  executables:
@@ -81,12 +55,11 @@ files:
81
55
  - Mavenfile
82
56
  - Rakefile
83
57
  - Readme.md
84
- - bin/lock_jars
58
+ - exe/lock_jars
85
59
  - jar-dependencies.gemspec
86
60
  - lib/jar-dependencies.rb
87
61
  - lib/jar_dependencies.rb
88
62
  - lib/jar_install_post_install_hook.rb
89
- - lib/jar_installer.rb
90
63
  - lib/jars/attach_jars_pom.rb
91
64
  - lib/jars/classpath.rb
92
65
  - lib/jars/gemspec_artifacts.rb
@@ -107,16 +80,17 @@ files:
107
80
  homepage: https://github.com/mkristian/jar-dependencies
108
81
  licenses:
109
82
  - MIT
110
- metadata: {}
83
+ metadata:
84
+ rubygems_mfa_required: 'true'
111
85
  post_install_message: |2+
112
86
 
113
87
  if you want to use the executable lock_jars then install ruby-maven gem before using lock_jars
114
88
 
115
- $ gem install ruby-maven -v '~> 3.3.11'
89
+ $ gem install ruby-maven -v '~> 3.9'
116
90
 
117
91
  or add it as a development dependency to your Gemfile
118
92
 
119
- gem 'ruby-maven', '~> 3.3.11'
93
+ gem 'ruby-maven', '~> 3.9'
120
94
 
121
95
  rdoc_options: []
122
96
  require_paths:
@@ -125,15 +99,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
99
  requirements:
126
100
  - - ">="
127
101
  - !ruby/object:Gem::Version
128
- version: '0'
102
+ version: '2.6'
129
103
  required_rubygems_version: !ruby/object:Gem::Requirement
130
104
  requirements:
131
105
  - - ">="
132
106
  - !ruby/object:Gem::Version
133
107
  version: '0'
134
108
  requirements: []
135
- rubyforge_project:
136
- rubygems_version: 2.6.14.1
109
+ rubygems_version: 3.5.23
137
110
  signing_key:
138
111
  specification_version: 4
139
112
  summary: manage jar dependencies for gems
data/lib/jar_installer.rb DELETED
@@ -1 +0,0 @@
1
- require 'jars/installer'