jar-dependencies 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.1'.freeze
3
- JRUBY_PLUGINS_VERSION = '1.1.3'.freeze
4
- DEPENDENCY_PLUGIN_VERSION = '2.8'.freeze
4
+ VERSION = '0.5.0'
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,61 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jar-dependencies
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
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: 2020-07-14 00:00:00.000000000 Z
11
+ date: 2024-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 5.10.0
18
+ version: '5.10'
19
19
  name: minitest
20
- prerelease: false
21
20
  type: :development
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 5.10.0
27
- - !ruby/object:Gem::Dependency
28
- requirement: !ruby/object:Gem::Requirement
29
- requirements:
30
- - - "~>"
31
- - !ruby/object:Gem::Version
32
- version: '10.2'
33
- name: rake
34
21
  prerelease: false
35
- type: :development
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
24
  - - "~>"
39
25
  - !ruby/object:Gem::Version
40
- version: '10.2'
26
+ version: '5.10'
41
27
  - !ruby/object:Gem::Dependency
42
28
  requirement: !ruby/object:Gem::Requirement
43
29
  requirements:
44
30
  - - "~>"
45
31
  - !ruby/object:Gem::Version
46
- version: 3.3.11
32
+ version: '3.9'
47
33
  name: ruby-maven
48
- prerelease: false
49
34
  type: :development
35
+ prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: 3.3.11
55
- description: manage jar dependencies for gems and keep track which jar was already
56
- loaded using maven artifact coordinates. it warns on version conflicts and loads
57
- only ONE jar assuming the first one is compatible to the second one otherwise your
58
- 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.
59
47
  email:
60
48
  - mkristian@web.de
61
49
  executables:
@@ -67,12 +55,11 @@ files:
67
55
  - Mavenfile
68
56
  - Rakefile
69
57
  - Readme.md
70
- - bin/lock_jars
58
+ - exe/lock_jars
71
59
  - jar-dependencies.gemspec
72
60
  - lib/jar-dependencies.rb
73
61
  - lib/jar_dependencies.rb
74
62
  - lib/jar_install_post_install_hook.rb
75
- - lib/jar_installer.rb
76
63
  - lib/jars/attach_jars_pom.rb
77
64
  - lib/jars/classpath.rb
78
65
  - lib/jars/gemspec_artifacts.rb
@@ -93,16 +80,17 @@ files:
93
80
  homepage: https://github.com/mkristian/jar-dependencies
94
81
  licenses:
95
82
  - MIT
96
- metadata: {}
83
+ metadata:
84
+ rubygems_mfa_required: 'true'
97
85
  post_install_message: |2+
98
86
 
99
87
  if you want to use the executable lock_jars then install ruby-maven gem before using lock_jars
100
88
 
101
- $ gem install ruby-maven -v '~> 3.3.11'
89
+ $ gem install ruby-maven -v '~> 3.9'
102
90
 
103
91
  or add it as a development dependency to your Gemfile
104
92
 
105
- gem 'ruby-maven', '~> 3.3.11'
93
+ gem 'ruby-maven', '~> 3.9'
106
94
 
107
95
  rdoc_options: []
108
96
  require_paths:
@@ -111,15 +99,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
99
  requirements:
112
100
  - - ">="
113
101
  - !ruby/object:Gem::Version
114
- version: '0'
102
+ version: '2.6'
115
103
  required_rubygems_version: !ruby/object:Gem::Requirement
116
104
  requirements:
117
105
  - - ">="
118
106
  - !ruby/object:Gem::Version
119
107
  version: '0'
120
108
  requirements: []
121
- rubyforge_project:
122
- rubygems_version: 2.6.14.1
109
+ rubygems_version: 3.3.26
123
110
  signing_key:
124
111
  specification_version: 4
125
112
  summary: manage jar dependencies for gems
data/lib/jar_installer.rb DELETED
@@ -1 +0,0 @@
1
- require 'jars/installer'