jar-dependencies 0.4.1 → 0.5.1
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.
Potentially problematic release.
This version of jar-dependencies might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/Mavenfile +6 -10
- data/Rakefile +6 -22
- data/Readme.md +7 -2
- data/{bin → exe}/lock_jars +7 -2
- data/jar-dependencies.gemspec +25 -22
- data/lib/jar-dependencies.rb +2 -0
- data/lib/jar_dependencies.rb +91 -84
- data/lib/jar_install_post_install_hook.rb +2 -0
- data/lib/jars/attach_jars_pom.rb +6 -2
- data/lib/jars/classpath.rb +8 -10
- data/lib/jars/gemspec_artifacts.rb +62 -56
- data/lib/jars/gemspec_pom.rb +8 -2
- data/lib/jars/installer.rb +49 -70
- data/lib/jars/lock.rb +10 -7
- data/lib/jars/lock_down.rb +21 -29
- data/lib/jars/lock_down_pom.rb +9 -4
- data/lib/jars/maven_exec.rb +11 -8
- data/lib/jars/maven_factory.rb +12 -13
- data/lib/jars/maven_settings.rb +21 -27
- data/lib/jars/output_jars_pom.rb +10 -2
- data/lib/jars/post_install_hook.rb +3 -1
- data/lib/jars/setup.rb +2 -0
- data/lib/jars/version.rb +5 -3
- data/lib/rubygems_plugin.rb +2 -0
- metadata +21 -34
- data/lib/jar_installer.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ee409eae212c171dc0b3e3e27929ca77f394867b48ad2af15e2e74602d7c2f23
|
4
|
+
data.tar.gz: f7627912032451d03f96b493205a1d878a800b7442b2e3bc08d8873a2fe124ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 174d772e5c11bea9a43ed3e4dfb8ce5c70f60d229d1a941c39a54e7fcec9fe0b91dc8cb40d2e9d4e63081b75e31fdec5a7b43de9bfdf28833937cfde4a494f79
|
7
|
+
data.tar.gz: c2dbdb85231c85d642f85e924490f8b0ffd39d49b2c69bdb9c0d358a3ec1f9e63d74da1ddee764105cbf0c16fcfae920a76884183e65f7802168968a3c3fc768
|
data/Mavenfile
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
gemfile
|
4
4
|
|
5
|
-
plugin_repository id: :
|
5
|
+
plugin_repository id: :mavengems, url: 'mavengem:https://rubygems.org'
|
6
6
|
|
7
7
|
jruby_plugin(:minitest, minispecDirectory: 'specs/*_spec.rb') do
|
8
8
|
execute_goals(:spec)
|
@@ -17,13 +17,12 @@ ruby_maven = gemfile_profile.dependencies.detect do |d|
|
|
17
17
|
d.artifact_id == 'ruby-maven'
|
18
18
|
end
|
19
19
|
|
20
|
-
properties('jruby.versions' => ['
|
21
|
-
'jruby.modes' => ['1.9', '2.0', '2.2'].join(','),
|
20
|
+
properties('jruby.versions' => ['${jruby.version}'].join(','),
|
22
21
|
# just lock the version
|
23
|
-
'bundler.version' => '
|
22
|
+
'bundler.version' => '2.5.11',
|
24
23
|
'ruby-maven.version' => ruby_maven.version,
|
25
|
-
'jruby.version' => '9.
|
26
|
-
'jruby.plugins.version' => '
|
24
|
+
'jruby.version' => '9.4.8.0',
|
25
|
+
'jruby.plugins.version' => '3.0.2',
|
27
26
|
'push.skip' => true)
|
28
27
|
|
29
28
|
plugin :invoker, '1.8' do
|
@@ -37,7 +36,6 @@ plugin :invoker, '1.8' do
|
|
37
36
|
cloneProjectsTo: '${project.build.directory}',
|
38
37
|
properties: { 'jar-dependencies.version' => '${project.version}',
|
39
38
|
# use an old jruby with old ruby-maven here
|
40
|
-
'jruby.old-version' => '1.7.20',
|
41
39
|
'jruby.version' => '${jruby.version}',
|
42
40
|
'jruby.plugins.version' => '${jruby.plugins.version}',
|
43
41
|
'bundler.version' => '${bundler.version}',
|
@@ -59,5 +57,3 @@ profile id: :release do
|
|
59
57
|
default_goal :deploy
|
60
58
|
end
|
61
59
|
end
|
62
|
-
|
63
|
-
# vim: syntax=Ruby
|
data/Rakefile
CHANGED
@@ -1,7 +1,12 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
task default: [:specs]
|
4
4
|
|
5
|
+
require 'bundler/gem_tasks'
|
6
|
+
require 'rubocop/rake_task'
|
7
|
+
|
8
|
+
RuboCop::RakeTask.new
|
9
|
+
|
5
10
|
desc 'run specs'
|
6
11
|
task :specs do
|
7
12
|
$LOAD_PATH << 'specs'
|
@@ -10,24 +15,3 @@ task :specs do
|
|
10
15
|
require File.basename(f.sub(/.rb$/, ''))
|
11
16
|
end
|
12
17
|
end
|
13
|
-
|
14
|
-
task :headers do
|
15
|
-
require 'copyright_header'
|
16
|
-
|
17
|
-
s = Gem::Specification.load(Dir['*gemspec'].first)
|
18
|
-
|
19
|
-
args = {
|
20
|
-
license: s.license,
|
21
|
-
copyright_software: s.name,
|
22
|
-
copyright_software_description: s.description,
|
23
|
-
copyright_holders: s.authors,
|
24
|
-
copyright_years: [Time.now.year],
|
25
|
-
add_path: 'lib',
|
26
|
-
output_dir: './'
|
27
|
-
}
|
28
|
-
|
29
|
-
command_line = CopyrightHeader::CommandLine.new(args)
|
30
|
-
command_line.execute
|
31
|
-
end
|
32
|
-
|
33
|
-
# vim: syntax=Ruby
|
data/Readme.md
CHANGED
@@ -47,7 +47,7 @@ during installation.
|
|
47
47
|
|
48
48
|
If you do not want to vendor jars into a gem then **jar-dependency** gem can vendor
|
49
49
|
them when you install the gem. In that case do not use
|
50
|
-
`Jars::
|
50
|
+
`Jars::Installer.install_jars` from the above rake tasks.
|
51
51
|
|
52
52
|
**NOTE**: Recent JRuby comes with **jar-dependencies** as default gem, for older
|
53
53
|
versions for the feature to work you need to gem install **jar-dependencies** first
|
@@ -172,7 +172,7 @@ Or, with maven debug enabled
|
|
172
172
|
JARS_DEBUG=true bundle install
|
173
173
|
JARS_DEBUG=true gem install some_gem
|
174
174
|
|
175
|
-
The maven command line which gets printed needs maven-3.
|
175
|
+
The maven command line which gets printed needs maven-3.9.x and the
|
176
176
|
ruby DSL extension for maven:
|
177
177
|
[https://github.com/takari/polyglot-maven#configuration](polyglot-maven
|
178
178
|
configuration) where ```${maven.multiModuleProjectDirectory}``` is
|
@@ -216,3 +216,8 @@ Or a few days ago an issue for rake-compile [https://github.com/luislavena/rake-
|
|
216
216
|
|
217
217
|
With JRuby 9000 it is the right time to get jar dependencies "right" - the current situation is like the time before bundler for gems.
|
218
218
|
|
219
|
+
# Developing
|
220
|
+
|
221
|
+
You must have the latest ruby-maven installed in your local JRuby.
|
222
|
+
|
223
|
+
./mvnw install will build the gem and run integration tests
|
data/{bin → exe}/lock_jars
RENAMED
@@ -1,4 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
require 'jar_dependencies'
|
3
5
|
require 'optparse'
|
4
6
|
options = {}
|
@@ -25,11 +27,14 @@ optparse = OptionParser.new do |opts|
|
|
25
27
|
options[:tree] = t
|
26
28
|
end
|
27
29
|
|
28
|
-
opts.on('-u', '--update JAR_COORDINATE',
|
30
|
+
opts.on('-u', '--update JAR_COORDINATE',
|
31
|
+
'Resolves given dependency and use latest version. ' \
|
32
|
+
'JAR_COORDINATE is either artifact_id or group_id:artifact_id') do |u|
|
29
33
|
options[:update] = u
|
30
34
|
end
|
31
35
|
|
32
|
-
opts.on('--vendor-dir DIRECTORY', 'Vendor directory where to copy the installed jars.'
|
36
|
+
opts.on('--vendor-dir DIRECTORY', 'Vendor directory where to copy the installed jars.' \
|
37
|
+
'add this directory to $LOAD_PATH or set JARS_HOME respectively.') do |dir|
|
33
38
|
options[:vendor_dir] = dir
|
34
39
|
end
|
35
40
|
|
data/jar-dependencies.gemspec
CHANGED
@@ -1,44 +1,47 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/jars/version'
|
2
4
|
|
3
5
|
Gem::Specification.new do |s|
|
4
6
|
s.name = 'jar-dependencies'
|
5
7
|
|
6
|
-
|
7
|
-
s.version = File.read(path).match(/\s*VERSION\s*=\s*['"](.*)['"]/)[1]
|
8
|
+
s.version = Jars::VERSION
|
8
9
|
|
9
10
|
s.author = 'christian meier'
|
10
11
|
s.email = ['mkristian@web.de']
|
11
12
|
s.summary = 'manage jar dependencies for gems'
|
12
13
|
s.homepage = 'https://github.com/mkristian/jar-dependencies'
|
13
14
|
|
14
|
-
s.bindir = '
|
15
|
-
s.executables = [lock_jars = 'lock_jars'
|
15
|
+
s.bindir = 'exe'
|
16
|
+
s.executables = [lock_jars = 'lock_jars']
|
16
17
|
|
17
18
|
s.license = 'MIT'
|
18
19
|
|
19
|
-
s.files =
|
20
|
-
file =~ /^lib\// ||
|
21
|
-
%w[Mavenfile Rakefile].include?(file) ||
|
22
|
-
['Readme.md', 'jar-dependencies.gemspec', 'MIT-LICENSE'].include?(file)
|
23
|
-
end
|
20
|
+
s.files = Dir['{lib}/**/*'] + %w[Mavenfile Rakefile Readme.md jar-dependencies.gemspec MIT-LICENSE]
|
24
21
|
|
25
|
-
s.description =
|
22
|
+
s.description = <<~TEXT
|
23
|
+
manage jar dependencies for gems and keep track which jar was already
|
24
|
+
loaded using maven artifact coordinates. it warns on version conflicts and
|
25
|
+
loads only ONE jar assuming the first one is compatible to the second one
|
26
|
+
otherwise your project needs to lock down the right version by providing a
|
27
|
+
Jars.lock file.
|
28
|
+
TEXT
|
26
29
|
|
27
|
-
s.
|
28
|
-
s.add_development_dependency 'rake', '~> 10.2'
|
29
|
-
s.add_development_dependency 'ruby-maven', ruby_maven_version = '~> 3.3.11'.freeze
|
30
|
+
s.required_ruby_version = '>= 2.6'
|
30
31
|
|
31
|
-
s.
|
32
|
+
s.add_development_dependency 'minitest', '~> 5.10'
|
33
|
+
s.add_development_dependency 'ruby-maven', ruby_maven_version = '~> 3.9'
|
32
34
|
|
33
|
-
|
35
|
+
s.post_install_message = <<~TEXT
|
34
36
|
|
35
|
-
|
37
|
+
if you want to use the executable #{lock_jars} then install ruby-maven gem before using #{lock_jars}
|
36
38
|
|
37
|
-
|
39
|
+
$ gem install ruby-maven -v '#{ruby_maven_version}'
|
38
40
|
|
39
|
-
|
41
|
+
or add it as a development dependency to your Gemfile
|
40
42
|
|
41
|
-
|
42
|
-
end
|
43
|
+
gem 'ruby-maven', '#{ruby_maven_version}'
|
43
44
|
|
44
|
-
|
45
|
+
TEXT
|
46
|
+
s.metadata['rubygems_mfa_required'] = 'true'
|
47
|
+
end
|
data/lib/jar-dependencies.rb
CHANGED
data/lib/jar_dependencies.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#
|
2
4
|
# Copyright (C) 2014 Christian Meier
|
3
5
|
#
|
@@ -21,41 +23,44 @@
|
|
21
23
|
|
22
24
|
module Jars
|
23
25
|
unless defined? Jars::SKIP_LOCK
|
24
|
-
MAVEN_SETTINGS = 'JARS_MAVEN_SETTINGS'
|
25
|
-
LOCAL_MAVEN_REPO = 'JARS_LOCAL_MAVEN_REPO'
|
26
|
+
MAVEN_SETTINGS = 'JARS_MAVEN_SETTINGS'
|
27
|
+
LOCAL_MAVEN_REPO = 'JARS_LOCAL_MAVEN_REPO'
|
26
28
|
# lock file to use
|
27
|
-
LOCK = 'JARS_LOCK'
|
29
|
+
LOCK = 'JARS_LOCK'
|
28
30
|
# where the locally stored jars are search for or stored
|
29
|
-
HOME = 'JARS_HOME'
|
31
|
+
HOME = 'JARS_HOME'
|
30
32
|
# skip the gem post install hook
|
31
|
-
SKIP = 'JARS_SKIP'
|
33
|
+
SKIP = 'JARS_SKIP'
|
32
34
|
# skip Jars.lock mainly to run lock_jars
|
33
|
-
SKIP_LOCK = 'JARS_SKIP_LOCK'
|
35
|
+
SKIP_LOCK = 'JARS_SKIP_LOCK'
|
34
36
|
# do not require any jars if set to false
|
35
|
-
REQUIRE = 'JARS_REQUIRE'
|
37
|
+
REQUIRE = 'JARS_REQUIRE'
|
36
38
|
# @private
|
37
|
-
NO_REQUIRE = 'JARS_NO_REQUIRE'
|
39
|
+
NO_REQUIRE = 'JARS_NO_REQUIRE'
|
38
40
|
# no more warnings on conflict. this still requires jars but will
|
39
41
|
# not warn. it is needed to load jars from (default) gems which
|
40
42
|
# do contribute to any dependency manager (maven, gradle, jbundler)
|
41
|
-
QUIET = 'JARS_QUIET'
|
43
|
+
QUIET = 'JARS_QUIET'
|
42
44
|
# show maven output
|
43
|
-
VERBOSE = 'JARS_VERBOSE'
|
45
|
+
VERBOSE = 'JARS_VERBOSE'
|
44
46
|
# maven debug
|
45
|
-
DEBUG = 'JARS_DEBUG'
|
47
|
+
DEBUG = 'JARS_DEBUG'
|
46
48
|
# vendor jars inside gem when installing gem
|
47
|
-
VENDOR = 'JARS_VENDOR'
|
49
|
+
VENDOR = 'JARS_VENDOR'
|
48
50
|
# string used when the version is unknown
|
49
51
|
UNKNOWN = 'unknown'
|
50
52
|
end
|
51
53
|
|
52
54
|
autoload :MavenSettings, 'jars/maven_settings'
|
53
55
|
|
56
|
+
@jars_lock = false
|
57
|
+
@jars = {}
|
58
|
+
|
54
59
|
class << self
|
55
|
-
def lock_down(debug
|
60
|
+
def lock_down(debug: false, verbose: false, **kwargs)
|
56
61
|
ENV[SKIP_LOCK] = 'true'
|
57
62
|
require 'jars/lock_down' # do this lazy to keep things clean
|
58
|
-
Jars::LockDown.new(debug, verbose).lock_down(
|
63
|
+
Jars::LockDown.new(debug, verbose).lock_down(**kwargs)
|
59
64
|
ensure
|
60
65
|
ENV[SKIP_LOCK] = nil
|
61
66
|
end
|
@@ -63,8 +68,11 @@ module Jars
|
|
63
68
|
if defined? JRUBY_VERSION
|
64
69
|
def to_prop(key)
|
65
70
|
key = key.tr('_', '.')
|
66
|
-
ENV_JAVA[(key.downcase
|
67
|
-
|
71
|
+
ENV_JAVA[(key.downcase!
|
72
|
+
key)] ||
|
73
|
+
ENV[(key.tr!('.', '_')
|
74
|
+
key.upcase!
|
75
|
+
key)]
|
68
76
|
end
|
69
77
|
else
|
70
78
|
def to_prop(key)
|
@@ -74,6 +82,7 @@ module Jars
|
|
74
82
|
|
75
83
|
def to_boolean(key)
|
76
84
|
return nil if (prop = to_prop(key)).nil?
|
85
|
+
|
77
86
|
prop.empty? || prop.eql?('true')
|
78
87
|
end
|
79
88
|
|
@@ -82,7 +91,6 @@ module Jars
|
|
82
91
|
end
|
83
92
|
|
84
93
|
def require?
|
85
|
-
@require = nil unless instance_variable_defined?(:@require)
|
86
94
|
if @require.nil?
|
87
95
|
if (require = to_boolean(REQUIRE)).nil?
|
88
96
|
no_require = to_boolean(NO_REQUIRE)
|
@@ -96,16 +104,16 @@ module Jars
|
|
96
104
|
attr_writer :require
|
97
105
|
|
98
106
|
def quiet?
|
99
|
-
|
107
|
+
@quiet = to_boolean(QUIET) if @quiet.nil?
|
108
|
+
@quiet
|
100
109
|
end
|
101
110
|
|
102
|
-
def
|
103
|
-
|
111
|
+
def no_more_warnings
|
112
|
+
@quiet = true
|
104
113
|
end
|
105
114
|
|
106
|
-
|
107
|
-
|
108
|
-
!require?
|
115
|
+
def jarfile
|
116
|
+
ENV['JARFILE'] || ENV_JAVA['jarfile'] || ENV['JBUNDLER_JARFILE'] || ENV_JAVA['jbundler.jarfile'] || 'Jarfile'
|
109
117
|
end
|
110
118
|
|
111
119
|
def verbose?
|
@@ -120,10 +128,6 @@ module Jars
|
|
120
128
|
to_boolean(VENDOR)
|
121
129
|
end
|
122
130
|
|
123
|
-
def no_more_warnings
|
124
|
-
@silent = true
|
125
|
-
end
|
126
|
-
|
127
131
|
def freeze_loading
|
128
132
|
self.require = false
|
129
133
|
end
|
@@ -137,18 +141,20 @@ module Jars
|
|
137
141
|
end
|
138
142
|
|
139
143
|
def jars_lock_from_class_loader
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
144
|
+
return unless to_prop(LOCK).nil? && defined?(JRUBY_VERSION)
|
145
|
+
|
146
|
+
if JRuby::Util.respond_to?(:class_loader_resources)
|
147
|
+
JRuby::Util.class_loader_resources('Jars.lock')
|
148
|
+
else
|
149
|
+
require 'jruby'
|
150
|
+
JRuby.runtime.jruby_class_loader.get_resources('Jars.lock').collect(&:to_s)
|
146
151
|
end
|
147
152
|
end
|
148
153
|
|
149
154
|
def lock_path(basedir = nil)
|
150
155
|
deps = lock
|
151
156
|
return deps if File.exist?(deps)
|
157
|
+
|
152
158
|
basedir ||= '.'
|
153
159
|
['.', 'jars', 'vendor/jars'].each do |dir|
|
154
160
|
file = File.join(basedir, dir, lock)
|
@@ -158,9 +164,13 @@ module Jars
|
|
158
164
|
end
|
159
165
|
|
160
166
|
def reset
|
161
|
-
instance_variables.each
|
167
|
+
instance_variables.each do |var|
|
168
|
+
next if var == :@jars_lock
|
169
|
+
|
170
|
+
instance_variable_set(var, nil)
|
171
|
+
end
|
162
172
|
Jars::MavenSettings.reset
|
163
|
-
|
173
|
+
@jars = {}
|
164
174
|
end
|
165
175
|
|
166
176
|
def maven_local_settings
|
@@ -180,21 +190,21 @@ module Jars
|
|
180
190
|
end
|
181
191
|
|
182
192
|
def local_maven_repo
|
183
|
-
@
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
193
|
+
@local_maven_repo ||= absolute(to_prop(LOCAL_MAVEN_REPO)) ||
|
194
|
+
detect_local_repository(maven_local_settings) ||
|
195
|
+
detect_local_repository(maven_user_settings) ||
|
196
|
+
detect_local_repository(maven_global_settings) ||
|
197
|
+
File.join(user_home, '.m2', 'repository')
|
188
198
|
end
|
189
199
|
|
190
200
|
def home
|
191
|
-
absolute(to_prop(HOME)) || local_maven_repo
|
201
|
+
@home ||= absolute(to_prop(HOME)) || local_maven_repo
|
192
202
|
end
|
193
203
|
|
194
204
|
def require_jars_lock!(scope = :runtime)
|
195
205
|
urls = jars_lock_from_class_loader
|
196
206
|
if urls && !urls.empty?
|
197
|
-
|
207
|
+
@jars_lock = true
|
198
208
|
# funny error during spec where it tries to load it again
|
199
209
|
# and finds it as gem instead of the LOAD_PATH
|
200
210
|
require 'jars/classpath' unless defined? Jars::Classpath
|
@@ -202,6 +212,7 @@ module Jars
|
|
202
212
|
while done != urls
|
203
213
|
urls.each do |url|
|
204
214
|
next if done.member?(url)
|
215
|
+
|
205
216
|
Jars.debug { "--- load jars from uri #{url}" }
|
206
217
|
classpath = Jars::Classpath.new(nil, "uri:#{url}")
|
207
218
|
classpath.require(scope)
|
@@ -210,9 +221,9 @@ module Jars
|
|
210
221
|
urls = jars_lock_from_class_loader
|
211
222
|
end
|
212
223
|
no_more_warnings
|
213
|
-
elsif jars_lock = Jars.lock_path
|
224
|
+
elsif (jars_lock = Jars.lock_path)
|
214
225
|
Jars.debug { "--- load jars from #{jars_lock}" }
|
215
|
-
|
226
|
+
@jars_lock = jars_lock
|
216
227
|
# funny error during spec where it tries to load it again
|
217
228
|
# and finds it as gem instead of the LOAD_PATH
|
218
229
|
require 'jars/classpath' unless defined? Jars::Classpath
|
@@ -221,8 +232,7 @@ module Jars
|
|
221
232
|
no_more_warnings
|
222
233
|
end
|
223
234
|
Jars.debug do
|
224
|
-
|
225
|
-
loaded = @@jars.collect { |k, v| "#{k}:#{v}" }
|
235
|
+
loaded = @jars.collect { |k, v| "#{k}:#{v}" }
|
226
236
|
"--- loaded jars ---\n\t#{loaded.join("\n\t")}"
|
227
237
|
end
|
228
238
|
end
|
@@ -232,8 +242,8 @@ module Jars
|
|
232
242
|
when Symbol
|
233
243
|
require_jars_lock!(options)
|
234
244
|
when Hash
|
235
|
-
@
|
236
|
-
@
|
245
|
+
@home = options[:jars_home]
|
246
|
+
@jars_lock = options[:jars_lock]
|
237
247
|
require_jars_lock!(options[:scope] || :runtime)
|
238
248
|
else
|
239
249
|
require_jars_lock!
|
@@ -241,25 +251,23 @@ module Jars
|
|
241
251
|
end
|
242
252
|
|
243
253
|
def require_jars_lock
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
end
|
254
|
+
return if @jars_lock
|
255
|
+
|
256
|
+
require_jars_lock!
|
257
|
+
@jars_lock ||= true # rubocop:disable Naming/MemoizedInstanceVariableName
|
249
258
|
end
|
250
259
|
|
251
260
|
def mark_as_required(group_id, artifact_id, *classifier_version)
|
252
261
|
require_jar_with_block(group_id, artifact_id, *classifier_version) do
|
262
|
+
# ignore
|
253
263
|
end
|
254
264
|
end
|
255
265
|
|
256
|
-
def require_jar(group_id, artifact_id, *classifier_version
|
266
|
+
def require_jar(group_id, artifact_id, *classifier_version)
|
257
267
|
require_jars_lock unless skip_lock?
|
258
268
|
if classifier_version.empty? && block_given?
|
259
|
-
classifier_version = [
|
260
|
-
if classifier_version.empty?
|
261
|
-
return mark_as_required(group_id, artifact_id, UNKNOWN) || false
|
262
|
-
end
|
269
|
+
classifier_version = [yield].compact
|
270
|
+
return mark_as_required(group_id, artifact_id, UNKNOWN) || false if classifier_version.empty?
|
263
271
|
end
|
264
272
|
require_jar_with_block(group_id, artifact_id, *classifier_version) do |gid, aid, version, classifier|
|
265
273
|
do_require(gid, aid, version, classifier)
|
@@ -281,9 +289,7 @@ module Jars
|
|
281
289
|
def user_home
|
282
290
|
ENV['HOME'] || begin
|
283
291
|
user_home = Dir.home if Dir.respond_to?(:home)
|
284
|
-
|
285
|
-
user_home = ENV_JAVA['user.home'] if Object.const_defined?(:ENV_JAVA)
|
286
|
-
end
|
292
|
+
user_home = ENV_JAVA['user.home'] if !user_home && Object.const_defined?(:ENV_JAVA)
|
287
293
|
user_home
|
288
294
|
end
|
289
295
|
end
|
@@ -294,19 +300,18 @@ module Jars
|
|
294
300
|
version = classifier_version[-1]
|
295
301
|
classifier = classifier_version[-2]
|
296
302
|
|
297
|
-
|
298
|
-
coordinate = "#{group_id}:#{artifact_id}"
|
303
|
+
coordinate = +"#{group_id}:#{artifact_id}"
|
299
304
|
coordinate << ":#{classifier}" if classifier
|
300
|
-
if
|
301
|
-
if
|
305
|
+
if @jars.key? coordinate
|
306
|
+
if @jars[coordinate] == version
|
302
307
|
false
|
303
308
|
else
|
304
|
-
|
309
|
+
@jars[coordinate] # version of already registered jar
|
305
310
|
end
|
306
311
|
else
|
307
312
|
yield group_id, artifact_id, version, classifier
|
308
|
-
|
309
|
-
|
313
|
+
@jars[coordinate] = version
|
314
|
+
true
|
310
315
|
end
|
311
316
|
end
|
312
317
|
|
@@ -315,7 +320,7 @@ module Jars
|
|
315
320
|
|
316
321
|
doc = File.read(settings)
|
317
322
|
# TODO: filter out xml comments
|
318
|
-
local_repo = doc.sub(
|
323
|
+
local_repo = doc.sub(%r{</localRepository>.*}m, '').sub(/.*<localRepository>/m, '')
|
319
324
|
# replace maven like system properties embedded into the string
|
320
325
|
local_repo.gsub!(/\$\{[a-zA-Z.]+\}/) do |a|
|
321
326
|
ENV_JAVA[a[2..-2]] || a
|
@@ -328,7 +333,7 @@ module Jars
|
|
328
333
|
end
|
329
334
|
|
330
335
|
def to_jar(group_id, artifact_id, version, classifier = nil)
|
331
|
-
file =
|
336
|
+
file = +"#{group_id.tr('.', '/')}/#{artifact_id}/#{version}/#{artifact_id}-#{version}"
|
332
337
|
file << "-#{classifier}" if classifier
|
333
338
|
file << '.jar'
|
334
339
|
file
|
@@ -336,34 +341,36 @@ module Jars
|
|
336
341
|
|
337
342
|
def do_require(*args)
|
338
343
|
jar = to_jar(*args)
|
339
|
-
local = File.join(Dir.pwd, 'jars', jar)
|
340
|
-
vendor = File.join(Dir.pwd, 'vendor', 'jars', jar)
|
341
|
-
file = File.join(home, jar)
|
342
|
-
# use jar from local repository if exists
|
343
|
-
if File.exist?(file)
|
344
|
-
require file
|
345
|
-
# use jar from PWD/jars if exists
|
346
|
-
elsif File.exist?(local)
|
347
|
-
require local
|
348
344
|
# use jar from PWD/vendor/jars if exists
|
349
|
-
|
345
|
+
if File.exist?(vendor = File.join(Dir.pwd, 'vendor', 'jars', jar))
|
350
346
|
require vendor
|
347
|
+
# use jar from PWD/jars if exists
|
348
|
+
elsif File.exist?(local = File.join(Dir.pwd, 'jars', jar))
|
349
|
+
require local
|
350
|
+
# use jar from local repository if exists
|
351
|
+
elsif File.exist?(file = File.join(home, jar))
|
352
|
+
require file
|
351
353
|
else
|
352
354
|
# otherwise try to find it on the load path
|
353
355
|
require jar
|
354
356
|
end
|
355
357
|
rescue LoadError => e
|
356
|
-
raise "\n\n\tyou might need to reinstall the gem which depends on the
|
358
|
+
raise "\n\n\tyou might need to reinstall the gem which depends on the " \
|
359
|
+
'missing jar or in case there is Jars.lock then resolve the jars with ' \
|
360
|
+
"`lock_jars` command\n\n#{e.message} (LoadError)"
|
357
361
|
end
|
358
|
-
end
|
362
|
+
end
|
359
363
|
end
|
360
364
|
|
361
365
|
def require_jar(*args, &block)
|
362
366
|
return nil unless Jars.require?
|
367
|
+
|
363
368
|
result = Jars.require_jar(*args, &block)
|
364
369
|
if result.is_a? String
|
365
|
-
args << (
|
366
|
-
Jars.warn
|
370
|
+
args << (yield || Jars::UNKNOWN) if args.size == 2 && block
|
371
|
+
Jars.warn do
|
372
|
+
"--- jar coordinate #{args[0..-2].join(':')} already loaded with version #{result} - omit version #{args[-1]}"
|
373
|
+
end
|
367
374
|
Jars.debug { " try to load from #{caller.join("\n\t")}" }
|
368
375
|
return false
|
369
376
|
end
|
data/lib/jars/attach_jars_pom.rb
CHANGED
@@ -1,13 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# this file is maven DSL
|
2
4
|
|
3
|
-
|
5
|
+
10_000.times do |i|
|
4
6
|
coord = ENV_JAVA["jars.#{i}"]
|
5
7
|
break unless coord
|
8
|
+
|
6
9
|
artifact = Maven::Tools::Artifact.from_coordinate(coord)
|
7
10
|
exclusions = []
|
8
|
-
|
11
|
+
10_000.times do |j|
|
9
12
|
exclusion = ENV_JAVA["jars.#{i}.exclusions.#{j}"]
|
10
13
|
break unless exclusion
|
14
|
+
|
11
15
|
exclusions << exclusion
|
12
16
|
end
|
13
17
|
scope = ENV_JAVA["jars.#{i}.scope"]
|
data/lib/jars/classpath.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'jars/maven_exec'
|
2
4
|
require 'jars/lock'
|
3
5
|
require 'fileutils'
|
@@ -38,15 +40,11 @@ module Jars
|
|
38
40
|
deps = Jars.lock_path(mvn.basedir)
|
39
41
|
@deps = deps if deps && File.exist?(deps)
|
40
42
|
end
|
41
|
-
|
42
|
-
@deps
|
43
|
-
else
|
44
|
-
resolve_dependencies
|
45
|
-
end
|
43
|
+
@deps || resolve_dependencies
|
46
44
|
end
|
47
45
|
private :dependencies_list
|
48
46
|
|
49
|
-
DEPENDENCY_LIST = 'dependencies.list'
|
47
|
+
DEPENDENCY_LIST = 'dependencies.list'
|
50
48
|
def resolve_dependencies
|
51
49
|
basedir = workdir('pkg') || workdir('target') || workdir('')
|
52
50
|
deps = File.join(basedir, DEPENDENCY_LIST)
|
@@ -63,10 +61,10 @@ module Jars
|
|
63
61
|
require_jar(*jar.gacv)
|
64
62
|
end
|
65
63
|
end
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
64
|
+
return unless scope.nil? || scope == :runtime
|
65
|
+
|
66
|
+
process(:provided) do |jar|
|
67
|
+
Jars.mark_as_required(*jar.gacv)
|
70
68
|
end
|
71
69
|
end
|
72
70
|
|