jar-dependencies 0.6.0.pre3-java → 0.6.2-java
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.
- checksums.yaml +4 -4
- data/Rakefile +3 -1
- data/Readme.md +32 -7
- data/lib/jar_dependencies.rb +11 -8
- data/lib/jars/gemspec_artifacts.rb +1 -0
- data/lib/jars/jarfile.rb +193 -0
- data/lib/jars/lock.rb +9 -2
- data/lib/jars/lock_down.rb +55 -26
- data/lib/jars/maven_exec.rb +3 -3
- data/lib/jars/mima/{context-2.4.42.jar → context-2.4.48.jar} +0 -0
- data/lib/jars/mima/{jcl-over-slf4j-2.0.17.jar → jcl-over-slf4j-2.0.18.jar} +0 -0
- data/lib/jars/mima/{slf4j-api-2.0.17.jar → slf4j-api-2.0.18.jar} +0 -0
- data/lib/jars/mima/slf4j-simple-2.0.18.jar +0 -0
- data/lib/jars/mima/{standalone-static-uber-2.4.42.jar → standalone-static-uber-2.4.48.jar} +0 -0
- data/lib/jars/mima/version.rb +12 -12
- data/lib/jars/mima.rb +32 -3
- data/lib/jars/version.rb +1 -1
- metadata +11 -13
- data/lib/jars/mima/slf4j-simple-2.0.17.jar +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b0aafa51e772b913e2304291b87f60d6987c7ca3be2e623d284e754be7d5daa6
|
|
4
|
+
data.tar.gz: a4ab73069e9fe58ca76e7e269abf5efad16012990f68b17c02b97cf81011c2f7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aab74a6548e5f0d3c18979789d7a6434c423434aa7eb5eb791fc4c87ab596d67d40350928998e2fbc1d36dd026cec749793ce7100a538bf07cfc30ab7c90de17
|
|
7
|
+
data.tar.gz: 7f9c3d7fe6fab532aacc994cf8ee3e81cf388933e547fd41c37f96d24d4772f3a3d3bb11db42d1c0a0dbbede3d1a07550e871b42c7a44420538001211b073e9e
|
data/Rakefile
CHANGED
|
@@ -28,7 +28,9 @@ SLF4J_VERSION = Jars::Mima::SLF4J_VERSION
|
|
|
28
28
|
MIMA_JARS = Jars::Mima::JARS
|
|
29
29
|
MIMA_DIR = Jars::Mima::MIMA_DIR
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
CLEAN.include(File.join(MIMA_DIR, "*.jar"))
|
|
32
|
+
|
|
33
|
+
task :build => :download_jars
|
|
32
34
|
|
|
33
35
|
desc 'download Mima (and dependent SLF4J) jars'
|
|
34
36
|
task :download_jars do
|
data/Readme.md
CHANGED
|
@@ -134,11 +134,38 @@ And look at the dependencies tree
|
|
|
134
134
|
lock_jars --tree
|
|
135
135
|
```
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
137
|
+
`lock_jars` resolves the jars with the Maven resolver bundled inside
|
|
138
|
+
jar-dependencies (Mima), so you no longer need Maven or the ruby-maven gem
|
|
139
|
+
installed to run it.
|
|
140
|
+
|
|
141
|
+
# Jarfile
|
|
142
|
+
|
|
143
|
+
If your project is not a gem, or you would rather keep jar versions out of the
|
|
144
|
+
gemspec, list them in a `Jarfile`. The `lock_jars` will read these together with
|
|
145
|
+
your gemspec and bundled gems and resolves everything in one go into `Jars.lock`.
|
|
146
|
+
|
|
147
|
+
A `Jarfile` is plain Ruby and reads similar to a *Gemfile*:
|
|
148
|
+
|
|
149
|
+
```ruby
|
|
150
|
+
jar 'org.yaml:snakeyaml', '2.7'
|
|
151
|
+
pom 'org.springframework.boot:spring-boot-dependencies', '3.2.5'
|
|
152
|
+
|
|
153
|
+
# using artifacts that aren't on maven central
|
|
154
|
+
repository 'my-nexus', 'https://nexus.example.com/repo'
|
|
155
|
+
|
|
156
|
+
# drop a transitive dependency you do not want
|
|
157
|
+
jar 'io.dropwizard:dropwizard-logging', '5.0.2', exclusions: ['jakarta.validation:jakarta.validation-api']
|
|
158
|
+
|
|
159
|
+
# keep some jars out of the runtime
|
|
160
|
+
scope :test do
|
|
161
|
+
jar 'org.junit.jupiter:junit-jupiter', '5.11.0'
|
|
162
|
+
end
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Both coordinate styles work, `'group:artifact', 'version'` or the packed
|
|
166
|
+
`'group:artifact:version'`, and you can pass a `:classifier`, a `:scope`, or a
|
|
167
|
+
block with nested `exclusion`s. Use `snapshot_repository` for a snapshot repo
|
|
168
|
+
and `local 'path/to/some.jar'` to point at a jar that already sits on disk.
|
|
142
169
|
|
|
143
170
|
# Proxy and mirror setup
|
|
144
171
|
|
|
@@ -220,6 +247,4 @@ With JRuby 9000 it was the right time to get jar dependencies "right".
|
|
|
220
247
|
|
|
221
248
|
# Developing
|
|
222
249
|
|
|
223
|
-
You must have the latest ruby-maven installed in your local JRuby.
|
|
224
|
-
|
|
225
250
|
./mvnw install will build the gem and run integration tests
|
data/lib/jar_dependencies.rb
CHANGED
|
@@ -56,7 +56,7 @@ module Jars
|
|
|
56
56
|
autoload :Mima, 'jars/mima'
|
|
57
57
|
|
|
58
58
|
@jars = {}
|
|
59
|
-
@jars_lock =
|
|
59
|
+
@jars_lock = nil
|
|
60
60
|
@jars_locked = nil
|
|
61
61
|
|
|
62
62
|
class JarLoadError < LoadError; end
|
|
@@ -177,13 +177,13 @@ module Jars
|
|
|
177
177
|
|
|
178
178
|
def reset
|
|
179
179
|
instance_variables.each do |var|
|
|
180
|
-
next if var == :@
|
|
180
|
+
next if var == :@jars
|
|
181
181
|
|
|
182
182
|
instance_variable_set(var, nil)
|
|
183
183
|
end
|
|
184
|
+
@jars.clear
|
|
185
|
+
|
|
184
186
|
Jars::MavenSettings.reset
|
|
185
|
-
@jars = {}
|
|
186
|
-
@jars_locked = nil
|
|
187
187
|
end
|
|
188
188
|
|
|
189
189
|
def maven_local_settings
|
|
@@ -263,11 +263,15 @@ module Jars
|
|
|
263
263
|
end
|
|
264
264
|
end
|
|
265
265
|
|
|
266
|
+
# Requires *Jars.lock* (once).
|
|
267
|
+
# @return whether a lock was actually required by this call
|
|
266
268
|
def require_jars_lock
|
|
267
|
-
return
|
|
269
|
+
return false unless @jars_lock.nil?
|
|
268
270
|
|
|
269
|
-
require_jars_lock!
|
|
270
|
-
|
|
271
|
+
require_jars_lock! # sets @jars_lock to the loaded lock (truthy) when there is one
|
|
272
|
+
required = !@jars_lock.nil?
|
|
273
|
+
@jars_lock = false # do not require again
|
|
274
|
+
required
|
|
271
275
|
end
|
|
272
276
|
|
|
273
277
|
def mark_as_required(group_id, artifact_id, *classifier_version)
|
|
@@ -380,7 +384,6 @@ module Jars
|
|
|
380
384
|
require jar
|
|
381
385
|
end
|
|
382
386
|
rescue LoadError => e
|
|
383
|
-
Jars.warn "failed to load jar: #{jar} (#{e.message})"
|
|
384
387
|
Jars.debug(e)
|
|
385
388
|
raise JarLoadError, "failed to load jar: #{jar}; run `lock_jars` or reinstall the gem"
|
|
386
389
|
end
|
data/lib/jars/jarfile.rb
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'jars/gemspec_artifacts'
|
|
4
|
+
|
|
5
|
+
module Jars
|
|
6
|
+
# Self-contained reader for the (j)bundler Jarfile DSL.
|
|
7
|
+
class Jarfile
|
|
8
|
+
def self.load(file)
|
|
9
|
+
new.tap { |jarfile| jarfile.eval_file(file) }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
Repository = Struct.new(:name, :url, :snapshot)
|
|
13
|
+
LocalJar = Struct.new(:group_id, :artifact_id, :version, :path) do
|
|
14
|
+
# a system-scoped Jars.lock entry: "group:artifact:version:system:path"
|
|
15
|
+
def to_lock_entry
|
|
16
|
+
"#{group_id}:#{artifact_id}:#{version}:system:#{path}"
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def initialize
|
|
21
|
+
@artifacts = []
|
|
22
|
+
@repositories = []
|
|
23
|
+
@local_jars = []
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
attr_reader :artifacts, :repositories, :local_jars
|
|
27
|
+
|
|
28
|
+
def eval_file(file)
|
|
29
|
+
instance_eval(File.read(file), file.to_s)
|
|
30
|
+
self
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# -- DSL --
|
|
34
|
+
|
|
35
|
+
def jar(*args, &block)
|
|
36
|
+
add(:jar, args, &block)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def pom(*args, &block)
|
|
40
|
+
add(:pom, args, &block)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def scope(scope)
|
|
44
|
+
previous = @scope
|
|
45
|
+
@scope = scope
|
|
46
|
+
yield if block_given?
|
|
47
|
+
ensure
|
|
48
|
+
@scope = previous
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def repository(name, url = nil)
|
|
52
|
+
@repositories << Repository.new(name.to_s, url || name, false)
|
|
53
|
+
end
|
|
54
|
+
alias_method :source, :repository
|
|
55
|
+
|
|
56
|
+
def snapshot_repository(name, url = nil)
|
|
57
|
+
@repositories << Repository.new(name.to_s, url || name, true)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# a local jar on disk - carried through as a system-scoped dependency
|
|
61
|
+
def local(path)
|
|
62
|
+
abs = File.expand_path(path)
|
|
63
|
+
name = File.basename(abs).sub(/\.jar$/, '')
|
|
64
|
+
if (dash = name.rindex('-'))
|
|
65
|
+
version = name[(dash + 1)..]
|
|
66
|
+
name = name[0...dash]
|
|
67
|
+
else
|
|
68
|
+
version = '0'
|
|
69
|
+
end
|
|
70
|
+
@local_jars << LocalJar.new('ruby.maven-tools.jar', name, version, abs)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# @deprecated in maven-tools, kept as a no-op so existing Jarfiles still load
|
|
74
|
+
def jruby(*)
|
|
75
|
+
nil
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Normalizes a DSL exclusion list ('group:artifact' or ['group', 'artifact']) to coordinate strings
|
|
79
|
+
def self.normalize_exclusions(list)
|
|
80
|
+
return [] if list.nil?
|
|
81
|
+
|
|
82
|
+
list.map { |e| e.is_a?(Array) ? e.join(':') : e.to_s }
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
private
|
|
86
|
+
|
|
87
|
+
def add(type, args, &block)
|
|
88
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
|
89
|
+
group_id, artifact_id, classifier, version = coordinate(args)
|
|
90
|
+
|
|
91
|
+
config = DepConfig.new(options)
|
|
92
|
+
config.instance_eval(&block) if block
|
|
93
|
+
|
|
94
|
+
classifier ||= config.classifier
|
|
95
|
+
scope = (config.scope || @scope)&.to_s
|
|
96
|
+
exclusions = build_exclusions(config.exclusions)
|
|
97
|
+
@artifacts << GemspecArtifacts::Artifact.new(
|
|
98
|
+
type.to_s, group_id, artifact_id, classifier, version, exclusions, scope: scope
|
|
99
|
+
)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Normalizes the positional coordinate forms into [group, artifact, classifier, version].
|
|
103
|
+
# Mirrors maven-tools Artifact.from: the colon-packed string carries the classifier.
|
|
104
|
+
def coordinate(args)
|
|
105
|
+
case args.size
|
|
106
|
+
when 1
|
|
107
|
+
# 'group:artifact:version' or 'group:artifact:version:classifier'
|
|
108
|
+
group_id, artifact_id, version, classifier = args[0].split(':')
|
|
109
|
+
when 2
|
|
110
|
+
# 'group:artifact', 'version' or 'group:artifact:classifier', 'version'
|
|
111
|
+
group_id, artifact_id, classifier = args[0].split(':')
|
|
112
|
+
version = args[1]
|
|
113
|
+
when 3
|
|
114
|
+
if args[0].include?(':')
|
|
115
|
+
# 'group:artifact[:classifier]', version-constraint, version-constraint
|
|
116
|
+
group_id, artifact_id, classifier = args[0].split(':')
|
|
117
|
+
version = args[1..].join(', ')
|
|
118
|
+
else
|
|
119
|
+
# 'group', 'artifact', 'version'
|
|
120
|
+
group_id, artifact_id, version = args
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
[group_id, artifact_id, classifier, version]
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# @param coords [Array<String>] normalized 'group:artifact' exclusion coordinates
|
|
127
|
+
def build_exclusions(coords)
|
|
128
|
+
return nil if coords.nil? || coords.empty?
|
|
129
|
+
|
|
130
|
+
GemspecArtifacts::Exclusions.new("[#{coords.join(', ')}]")
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Collects scope / classifier / exclusions declared in a jar/pom block, seeded by inline options.
|
|
134
|
+
# scope / classifier / exclusions double as DSL setters (with a value) and readers (no value).
|
|
135
|
+
class DepConfig
|
|
136
|
+
def initialize(options)
|
|
137
|
+
@scope = options[:scope]
|
|
138
|
+
@classifier = options[:classifier]
|
|
139
|
+
@exclusions = Jarfile.normalize_exclusions(options[:exclusions])
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# dual getter (no arg, read after eval) / setter (DSL call with a value)
|
|
143
|
+
def scope(value = nil)
|
|
144
|
+
value.nil? ? @scope : (@scope = value)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def classifier(value = nil)
|
|
148
|
+
value.nil? ? @classifier : (@classifier = value)
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def exclusion(*args, &block)
|
|
152
|
+
@exclusions << ExclusionBuilder.coordinate(*args, &block)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def exclusions(*list, &block)
|
|
156
|
+
list.each { |e| @exclusions << ExclusionBuilder.coordinate(e) }
|
|
157
|
+
instance_eval(&block) if block
|
|
158
|
+
@exclusions
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Resolves one exclusion declaration (any DSL form) to a 'group:artifact' coordinate.
|
|
163
|
+
module ExclusionBuilder
|
|
164
|
+
def self.coordinate(*args, &block)
|
|
165
|
+
return from_block(args, &block) if block
|
|
166
|
+
|
|
167
|
+
case args.first
|
|
168
|
+
when Hash then "#{args.first[:group_id]}:#{args.first[:artifact_id]}"
|
|
169
|
+
when Array then args.first.join(':')
|
|
170
|
+
else args.join(':') # 'group:artifact', or 'group', 'artifact'
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def self.from_block(args, &block)
|
|
175
|
+
receiver = Receiver.new
|
|
176
|
+
receiver.group_id(args.first) if args.first.is_a?(String)
|
|
177
|
+
receiver.instance_eval(&block)
|
|
178
|
+
"#{receiver.group_id}:#{receiver.artifact_id}"
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# Receiver for the `exclusion do group_id ..; artifact_id .. end` form
|
|
182
|
+
class Receiver
|
|
183
|
+
def group_id(value = nil)
|
|
184
|
+
value.nil? ? @group_id : (@group_id = value)
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def artifact_id(value = nil)
|
|
188
|
+
value.nil? ? @artifact_id : (@artifact_id = value)
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
end
|
data/lib/jars/lock.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'jars/maven_exec'
|
|
4
|
+
require 'uri'
|
|
4
5
|
|
|
5
6
|
module Jars
|
|
6
7
|
class JarDetails < Array
|
|
@@ -42,14 +43,20 @@ module Jars
|
|
|
42
43
|
ENV_JAVA[a[2..-2]] || a
|
|
43
44
|
end
|
|
44
45
|
else
|
|
45
|
-
|
|
46
|
+
filename = if classifier
|
|
47
|
+
"#{artifact_id}-#{version}-#{classifier}.jar"
|
|
48
|
+
else
|
|
49
|
+
"#{artifact_id}-#{version}.jar"
|
|
50
|
+
end
|
|
51
|
+
File.join(Jars.home, group_id.tr('.', '/'), artifact_id, version, filename)
|
|
46
52
|
end
|
|
47
53
|
end
|
|
48
54
|
end
|
|
49
55
|
|
|
50
56
|
class Lock
|
|
51
57
|
def initialize(file)
|
|
52
|
-
|
|
58
|
+
# JRuby treats percent escapes literally in uri:file paths
|
|
59
|
+
@file = file.start_with?('uri:file:') ? URI::DEFAULT_PARSER.unescape(file) : file
|
|
53
60
|
end
|
|
54
61
|
|
|
55
62
|
def process(scope)
|
data/lib/jars/lock_down.rb
CHANGED
|
@@ -3,37 +3,62 @@
|
|
|
3
3
|
require 'jar_dependencies'
|
|
4
4
|
require 'jars/version'
|
|
5
5
|
require 'jars/gemspec_artifacts'
|
|
6
|
+
require 'jars/jarfile'
|
|
6
7
|
|
|
7
8
|
module Jars
|
|
8
9
|
class LockDown
|
|
10
|
+
attr_reader :repositories, :local_jars
|
|
11
|
+
|
|
12
|
+
def initialize
|
|
13
|
+
@repositories = []
|
|
14
|
+
@local_jars = []
|
|
15
|
+
end
|
|
16
|
+
|
|
9
17
|
def basedir
|
|
10
18
|
File.expand_path('.')
|
|
11
19
|
end
|
|
12
20
|
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
# @return [Array[Jars::GemspecArtifacts::Artifact]]
|
|
13
24
|
def collect_artifacts
|
|
14
|
-
|
|
15
|
-
done = []
|
|
25
|
+
collected = {} # artifact.key => artifact
|
|
16
26
|
|
|
17
|
-
attach_jar_coordinates_from_bundler_dependencies(
|
|
27
|
+
attach_jar_coordinates_from_bundler_dependencies(collected)
|
|
18
28
|
|
|
19
29
|
# Also collect from local gemspec if present
|
|
20
|
-
specs = Dir
|
|
30
|
+
specs = Dir.children(basedir).sort.select { |f| f.end_with?('.gemspec') }
|
|
21
31
|
if specs.size == 1
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
done << a.key
|
|
28
|
-
end
|
|
29
|
-
end
|
|
32
|
+
spec_file = File.join(basedir, specs.first)
|
|
33
|
+
spec = Gem::Specification.load(spec_file)
|
|
34
|
+
raise "failed to load gemspec #{spec_file}" unless spec
|
|
35
|
+
|
|
36
|
+
GemspecArtifacts.new(spec).artifacts.each { |a| collected[a.key] ||= a }
|
|
30
37
|
end
|
|
31
38
|
|
|
32
|
-
|
|
39
|
+
append_artifacts_from_jarfile_if_any(collected)
|
|
40
|
+
|
|
41
|
+
collected.values
|
|
33
42
|
end
|
|
34
|
-
private :collect_artifacts
|
|
35
43
|
|
|
36
|
-
|
|
44
|
+
# jar/pom coordinates, repositories and local jars from a Jarfile (if any)
|
|
45
|
+
def append_artifacts_from_jarfile_if_any(collected)
|
|
46
|
+
file_path = File.expand_path(Jars.jarfile, basedir)
|
|
47
|
+
return unless File.exist?(file_path)
|
|
48
|
+
|
|
49
|
+
Jars.debug { "Jarfile loading from #{file_path}" }
|
|
50
|
+
jarfile = Jars::Jarfile.load(file_path)
|
|
51
|
+
@repositories.concat(jarfile.repositories)
|
|
52
|
+
@local_jars.concat(jarfile.local_jars)
|
|
53
|
+
|
|
54
|
+
jarfile.artifacts.each do |a|
|
|
55
|
+
previous = collected[a.key]
|
|
56
|
+
Jars.info { "Jarfile overrides #{previous.to_gacv} with #{a.to_gacv}" } if previous
|
|
57
|
+
collected[a.key] = a # Jarfile entry overrides the same coordinate from a gemspec
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def attach_jar_coordinates_from_bundler_dependencies(collected)
|
|
37
62
|
load_path = $LOAD_PATH.dup
|
|
38
63
|
require 'bundler'
|
|
39
64
|
# TODO: make this group a commandline option
|
|
@@ -41,13 +66,11 @@ module Jars
|
|
|
41
66
|
cwd = File.expand_path('.')
|
|
42
67
|
Gem.loaded_specs.each_value do |spec|
|
|
43
68
|
all = cwd == spec.full_gem_path # if gemspec is local then include all dependencies
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
next if done.include?(a.key)
|
|
69
|
+
GemspecArtifacts.new(spec).artifacts.each do |a|
|
|
70
|
+
next if collected.key?(a.key)
|
|
47
71
|
next unless all || (a.scope != 'provided' && a.scope != 'test')
|
|
48
72
|
|
|
49
|
-
|
|
50
|
-
done << a.key
|
|
73
|
+
collected[a.key] = a
|
|
51
74
|
end
|
|
52
75
|
end
|
|
53
76
|
rescue LoadError => e
|
|
@@ -61,6 +84,8 @@ module Jars
|
|
|
61
84
|
$LOAD_PATH.replace(load_path)
|
|
62
85
|
end
|
|
63
86
|
|
|
87
|
+
public
|
|
88
|
+
|
|
64
89
|
def lock_down(vendor_dir = nil, force: false, update: false, tree: nil) # rubocop:disable Lint/UnusedMethodArgument
|
|
65
90
|
lock_file = File.expand_path(Jars.lock)
|
|
66
91
|
|
|
@@ -71,7 +96,7 @@ module Jars
|
|
|
71
96
|
|
|
72
97
|
artifacts = collect_artifacts
|
|
73
98
|
|
|
74
|
-
if artifacts.empty?
|
|
99
|
+
if artifacts.empty? && @local_jars.empty?
|
|
75
100
|
puts 'no jar dependencies found'
|
|
76
101
|
return
|
|
77
102
|
end
|
|
@@ -84,11 +109,14 @@ module Jars
|
|
|
84
109
|
puts " exclusions: #{a.exclusions}" if a.exclusions && !a.exclusions.empty?
|
|
85
110
|
end
|
|
86
111
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
112
|
+
resolved = []
|
|
113
|
+
unless artifacts.empty?
|
|
114
|
+
context = Jars::Mima.create_context(repositories: @repositories)
|
|
115
|
+
begin
|
|
116
|
+
resolved = Jars::Mima.resolve_with_context(context, artifacts, all_dependencies: true)
|
|
117
|
+
ensure
|
|
118
|
+
context.close
|
|
119
|
+
end
|
|
92
120
|
end
|
|
93
121
|
|
|
94
122
|
# Write Jars.lock
|
|
@@ -98,6 +126,7 @@ module Jars
|
|
|
98
126
|
|
|
99
127
|
f.puts dep.to_lock_entry
|
|
100
128
|
end
|
|
129
|
+
@local_jars.each { |local| f.puts local.to_lock_entry }
|
|
101
130
|
end
|
|
102
131
|
|
|
103
132
|
# Optionally vendor jars
|
data/lib/jars/maven_exec.rb
CHANGED
|
@@ -34,9 +34,9 @@ module Jars
|
|
|
34
34
|
when String
|
|
35
35
|
@specfile = File.expand_path(spec)
|
|
36
36
|
@basedir = File.dirname(@specfile)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
# chdir so gemspecs that read relative files still resolve
|
|
38
|
+
spec = Dir.chdir(@basedir) { Gem::Specification.load(@specfile) }
|
|
39
|
+
raise "failed to load gemspec #{@specfile}" unless spec
|
|
40
40
|
when Gem::Specification
|
|
41
41
|
if File.exist?(spec.loaded_from)
|
|
42
42
|
@basedir = spec.gem_dir
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/lib/jars/mima/version.rb
CHANGED
|
@@ -2,28 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
module Jars
|
|
4
4
|
module Mima
|
|
5
|
-
MIMA_VERSION = '2.4.
|
|
6
|
-
SLF4J_VERSION = '2.0.
|
|
5
|
+
MIMA_VERSION = '2.4.48'
|
|
6
|
+
SLF4J_VERSION = '2.0.18'
|
|
7
7
|
|
|
8
8
|
MAVEN_CENTRAL = 'https://repo.maven.apache.org/maven2'
|
|
9
9
|
MIMA_DIR = 'lib/jars/mima'
|
|
10
10
|
|
|
11
11
|
# GAV and SHA-1 checksum (as published on Maven Central) for each jar
|
|
12
12
|
jars = %w[
|
|
13
|
-
org.slf4j:slf4j-api:2.0.
|
|
14
|
-
|
|
13
|
+
org.slf4j:slf4j-api:2.0.18
|
|
14
|
+
78a9e7a37cd6360e0b818e86341b24123d28d4df
|
|
15
15
|
|
|
16
|
-
org.slf4j:slf4j-simple:2.0.
|
|
17
|
-
|
|
16
|
+
org.slf4j:slf4j-simple:2.0.18
|
|
17
|
+
503354e24cb3a2c61f808a83934b76c2dc4ec4d8
|
|
18
18
|
|
|
19
|
-
org.slf4j:jcl-over-slf4j:2.0.
|
|
20
|
-
|
|
19
|
+
org.slf4j:jcl-over-slf4j:2.0.18
|
|
20
|
+
fb36c10c70e27bb427bb3cec86ac30bb83f667c7
|
|
21
21
|
|
|
22
|
-
eu.maveniverse.maven.mima:context:2.4.
|
|
23
|
-
|
|
22
|
+
eu.maveniverse.maven.mima:context:2.4.48
|
|
23
|
+
e792b92b226c2bdc829030c19f1239553dc1e382
|
|
24
24
|
|
|
25
|
-
eu.maveniverse.maven.mima.runtime:standalone-static-uber:2.4.
|
|
26
|
-
|
|
25
|
+
eu.maveniverse.maven.mima.runtime:standalone-static-uber:2.4.48
|
|
26
|
+
b2bb20acce196213d1cbd39cbe1cdb76d8a6b67b
|
|
27
27
|
]
|
|
28
28
|
|
|
29
29
|
JARS = jars.each_slice(2).to_h do |gav, sha1|
|
data/lib/jars/mima.rb
CHANGED
|
@@ -34,7 +34,7 @@ module Jars
|
|
|
34
34
|
# (local repo, user/global settings.xml).
|
|
35
35
|
#
|
|
36
36
|
# @return [Java::eu.maveniverse.maven.mima.context.ContextOverrides]
|
|
37
|
-
def context_overrides
|
|
37
|
+
def context_overrides(repositories: [])
|
|
38
38
|
ensure_jars_loaded
|
|
39
39
|
|
|
40
40
|
builder = Java::eu.maveniverse.maven.mima.context.ContextOverrides.create
|
|
@@ -52,20 +52,43 @@ module Jars
|
|
|
52
52
|
global = ::Jars::MavenSettings.global_settings
|
|
53
53
|
builder.withGlobalSettingsXmlOverride(java.nio.file.Paths.get(global)) if global
|
|
54
54
|
|
|
55
|
+
# extra repositories (e.g. declared in a Jarfile), appended to Central + settings mirrors
|
|
56
|
+
unless repositories.empty?
|
|
57
|
+
add_op = Java::eu.maveniverse.maven.mima.context.ContextOverrides::AddRepositoriesOp::APPEND
|
|
58
|
+
builder.repositories(remote_repositories(repositories))
|
|
59
|
+
builder.addRepositoriesOp(add_op)
|
|
60
|
+
end
|
|
61
|
+
|
|
55
62
|
builder.repositoryListener(aether_repository_listener)
|
|
56
63
|
builder.transferListener(aether_transfer_listener)
|
|
57
64
|
builder.build
|
|
58
65
|
end
|
|
59
66
|
|
|
67
|
+
# Converts repository declarations (responding to +name+, +url+, +snapshot+) to Aether
|
|
68
|
+
# +RemoteRepository+ objects. A snapshot repository enables snapshots and disables releases;
|
|
69
|
+
# a regular one does the opposite.
|
|
70
|
+
def remote_repositories(repositories)
|
|
71
|
+
ensure_jars_loaded
|
|
72
|
+
|
|
73
|
+
enabled = repository_policy(true)
|
|
74
|
+
disabled = repository_policy(false)
|
|
75
|
+
repositories.map do |repo|
|
|
76
|
+
builder = org.eclipse.aether.repository.RemoteRepository::Builder.new(repo.name, 'default', repo.url)
|
|
77
|
+
builder.setReleasePolicy(repo.snapshot ? disabled : enabled)
|
|
78
|
+
builder.setSnapshotPolicy(repo.snapshot ? enabled : disabled)
|
|
79
|
+
builder.build
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
60
83
|
# Creates a Mima Context. Caller is responsible for closing it.
|
|
61
84
|
#
|
|
62
85
|
# @param overrides [Java::eu.maveniverse.maven.mima.context.ContextOverrides, nil]
|
|
63
86
|
# optional overrides; when +nil+, {#context_overrides} is used
|
|
64
87
|
# @return [Java::eu.maveniverse.maven.mima.context.Context]
|
|
65
|
-
def create_context(overrides = nil)
|
|
88
|
+
def create_context(overrides = nil, repositories: [])
|
|
66
89
|
ensure_jars_loaded
|
|
67
90
|
|
|
68
|
-
overrides ||= context_overrides
|
|
91
|
+
overrides ||= context_overrides(repositories: repositories)
|
|
69
92
|
runtime = Java::eu.maveniverse.maven.mima.context.Runtimes::INSTANCE.getRuntime
|
|
70
93
|
runtime.create(overrides)
|
|
71
94
|
end
|
|
@@ -110,6 +133,12 @@ module Jars
|
|
|
110
133
|
|
|
111
134
|
private
|
|
112
135
|
|
|
136
|
+
def repository_policy(enabled)
|
|
137
|
+
update = org.eclipse.aether.repository.RepositoryPolicy::UPDATE_POLICY_DAILY
|
|
138
|
+
checksum = org.eclipse.aether.repository.RepositoryPolicy::CHECKSUM_POLICY_WARN
|
|
139
|
+
org.eclipse.aether.repository.RepositoryPolicy.new(enabled, update, checksum)
|
|
140
|
+
end
|
|
141
|
+
|
|
113
142
|
def configure_logging
|
|
114
143
|
return unless Object.const_defined?(:ENV_JAVA)
|
|
115
144
|
|
data/lib/jars/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jar-dependencies
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.2
|
|
5
5
|
platform: java
|
|
6
6
|
authors:
|
|
7
7
|
- christian meier
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies: []
|
|
13
12
|
description: |
|
|
14
13
|
manage jar dependencies for gems and keep track which jar was already
|
|
@@ -35,16 +34,17 @@ files:
|
|
|
35
34
|
- lib/jars/classpath.rb
|
|
36
35
|
- lib/jars/gemspec_artifacts.rb
|
|
37
36
|
- lib/jars/installer.rb
|
|
37
|
+
- lib/jars/jarfile.rb
|
|
38
38
|
- lib/jars/lock.rb
|
|
39
39
|
- lib/jars/lock_down.rb
|
|
40
40
|
- lib/jars/maven_exec.rb
|
|
41
41
|
- lib/jars/maven_settings.rb
|
|
42
42
|
- lib/jars/mima.rb
|
|
43
|
-
- lib/jars/mima/context-2.4.
|
|
44
|
-
- lib/jars/mima/jcl-over-slf4j-2.0.
|
|
45
|
-
- lib/jars/mima/slf4j-api-2.0.
|
|
46
|
-
- lib/jars/mima/slf4j-simple-2.0.
|
|
47
|
-
- lib/jars/mima/standalone-static-uber-2.4.
|
|
43
|
+
- lib/jars/mima/context-2.4.48.jar
|
|
44
|
+
- lib/jars/mima/jcl-over-slf4j-2.0.18.jar
|
|
45
|
+
- lib/jars/mima/slf4j-api-2.0.18.jar
|
|
46
|
+
- lib/jars/mima/slf4j-simple-2.0.18.jar
|
|
47
|
+
- lib/jars/mima/standalone-static-uber-2.4.48.jar
|
|
48
48
|
- lib/jars/mima/version.rb
|
|
49
49
|
- lib/jars/post_install_hook.rb
|
|
50
50
|
- lib/jars/setup.rb
|
|
@@ -55,7 +55,6 @@ licenses:
|
|
|
55
55
|
- MIT
|
|
56
56
|
metadata:
|
|
57
57
|
rubygems_mfa_required: 'true'
|
|
58
|
-
post_install_message:
|
|
59
58
|
rdoc_options: []
|
|
60
59
|
require_paths:
|
|
61
60
|
- lib
|
|
@@ -66,12 +65,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
66
65
|
version: '2.6'
|
|
67
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
67
|
requirements:
|
|
69
|
-
- - "
|
|
68
|
+
- - ">="
|
|
70
69
|
- !ruby/object:Gem::Version
|
|
71
|
-
version:
|
|
70
|
+
version: '0'
|
|
72
71
|
requirements: []
|
|
73
|
-
rubygems_version:
|
|
74
|
-
signing_key:
|
|
72
|
+
rubygems_version: 4.0.23
|
|
75
73
|
specification_version: 4
|
|
76
74
|
summary: manage jar dependencies for gems
|
|
77
75
|
test_files: []
|
|
Binary file
|