rspec-openhab-scripting 0.0.1-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.
Files changed (35) hide show
  1. checksums.yaml +7 -0
  2. data/lib/rspec/bundler/inline.rb +12 -0
  3. data/lib/rspec/openhab/api.rb +34 -0
  4. data/lib/rspec/openhab/core/cron_scheduler.rb +13 -0
  5. data/lib/rspec/openhab/core/load_path.rb +13 -0
  6. data/lib/rspec/openhab/core/logger.rb +24 -0
  7. data/lib/rspec/openhab/core/openhab_setup.rb +11 -0
  8. data/lib/rspec/openhab/core/osgi.rb +19 -0
  9. data/lib/rspec/openhab/core/script_handling.rb +21 -0
  10. data/lib/rspec/openhab/dsl/imports.rb +231 -0
  11. data/lib/rspec/openhab/dsl/timers/timer.rb +86 -0
  12. data/lib/rspec/openhab/version.rb +7 -0
  13. data/lib/rspec-openhab-scripting.rb +115 -0
  14. data/lib/rspec-openhab-scripting_jars.rb +14 -0
  15. data/vendor/gems/jar-dependencies-1.0.0/lib/jar-dependencies.rb +24 -0
  16. data/vendor/gems/jar-dependencies-1.0.0/lib/jar_dependencies.rb +397 -0
  17. data/vendor/gems/jar-dependencies-1.0.0/lib/jar_install_post_install_hook.rb +29 -0
  18. data/vendor/gems/jar-dependencies-1.0.0/lib/jars/attach_jars_pom.rb +35 -0
  19. data/vendor/gems/jar-dependencies-1.0.0/lib/jars/classpath.rb +92 -0
  20. data/vendor/gems/jar-dependencies-1.0.0/lib/jars/gemspec_artifacts.rb +220 -0
  21. data/vendor/gems/jar-dependencies-1.0.0/lib/jars/gemspec_pom.rb +11 -0
  22. data/vendor/gems/jar-dependencies-1.0.0/lib/jars/installer.rb +221 -0
  23. data/vendor/gems/jar-dependencies-1.0.0/lib/jars/lock.rb +75 -0
  24. data/vendor/gems/jar-dependencies-1.0.0/lib/jars/lock_down.rb +102 -0
  25. data/vendor/gems/jar-dependencies-1.0.0/lib/jars/lock_down_pom.rb +35 -0
  26. data/vendor/gems/jar-dependencies-1.0.0/lib/jars/maven_exec.rb +88 -0
  27. data/vendor/gems/jar-dependencies-1.0.0/lib/jars/maven_factory.rb +138 -0
  28. data/vendor/gems/jar-dependencies-1.0.0/lib/jars/maven_require.rb +48 -0
  29. data/vendor/gems/jar-dependencies-1.0.0/lib/jars/maven_settings.rb +124 -0
  30. data/vendor/gems/jar-dependencies-1.0.0/lib/jars/output_jars_pom.rb +16 -0
  31. data/vendor/gems/jar-dependencies-1.0.0/lib/jars/post_install_hook.rb +33 -0
  32. data/vendor/gems/jar-dependencies-1.0.0/lib/jars/setup.rb +9 -0
  33. data/vendor/gems/jar-dependencies-1.0.0/lib/jars/version.rb +7 -0
  34. data/vendor/gems/jar-dependencies-1.0.0/lib/rubygems_plugin.rb +24 -0
  35. metadata +217 -0
@@ -0,0 +1,220 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jars
4
+ class MavenVersion < String
5
+ class << self
6
+ def new(*args)
7
+ if args.empty? || (args.size == 1 && args[0].nil?)
8
+ nil
9
+ else
10
+ low, high = convert(args[0])
11
+ low, high = convert(args[1], low, high) if /[=~><]/.match?(args[1])
12
+ if low == high
13
+ low
14
+ else
15
+ super "#{low || "[0"},#{high || ")"}"
16
+ end
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def convert(arg, low = nil, high = nil)
23
+ if arg.include?("~>")
24
+ val = arg.sub(/~>\s*/, "")
25
+ last = val.include?(".") ? val.sub(/\.[0-9]*[a-z]+.*$/, "").sub(/\.[^.]+$/, ".99999") : "99999"
26
+ ["[#{snapshot_version(val)}", "#{snapshot_version(last)}]"]
27
+ elsif arg.include?(">=")
28
+ val = arg.sub(/>=\s*/, "")
29
+ ["[#{snapshot_version(val)}", (nil || high)]
30
+ elsif arg.include?("<=")
31
+ val = arg.sub(/<=\s*/, "")
32
+ [(nil || low), "#{snapshot_version(val)}]"]
33
+ # treat '!' the same way as '>' since maven can not describe such range
34
+ elsif /[!>]/.match?(arg)
35
+ val = arg.sub(/[!>]\s*/, "")
36
+ ["(#{snapshot_version(val)}", (nil || high)]
37
+ elsif arg.include?("<")
38
+ val = arg.sub(/<\s*/, "")
39
+ [(nil || low), "#{snapshot_version(val)})"]
40
+ elsif arg.include?("=")
41
+ val = arg.sub(/=\s*/, "")
42
+ # for prereleased version pick the maven version (no version range)
43
+ if /[a-z]|[A-Z]/.match?(val)
44
+ [val, val]
45
+ else
46
+ ["[#{val}", "#{val}.0.0.0.0.1)"]
47
+ end
48
+ else
49
+ # no conversion here, i.e. assume maven version
50
+ [arg, arg]
51
+ end
52
+ end
53
+
54
+ def snapshot_version(val)
55
+ if val.match(/[a-z]|[A-Z]/) && !val.match(/-SNAPSHOT|[${}]/)
56
+ "#{val}-SNAPSHOT"
57
+ else
58
+ val
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ class GemspecArtifacts
65
+ class Exclusion
66
+ attr_reader :group_id, :artifact_id
67
+
68
+ def initialize(line)
69
+ @group_id, @artifact_id = line.gsub(/['"]/, "").strip.split(":")
70
+ @artifact_id.strip!
71
+ end
72
+
73
+ def to_s
74
+ "#{@group_id}:#{@artifact_id}"
75
+ end
76
+ end
77
+
78
+ class Exclusions < Array
79
+ def to_s
80
+ "[#{join(", ")}]"
81
+ end
82
+
83
+ def initialize(line)
84
+ super()
85
+ line.gsub(/'"|^\s*\[|\]\s*$/, "").split(/,\s*/).each do |exclusion|
86
+ self.<< Exclusion.new(exclusion)
87
+ end
88
+ freeze
89
+ end
90
+ end
91
+
92
+ class Artifact
93
+ attr_reader :type, :group_id, :artifact_id, :classifier, :version, :scope, :exclusions
94
+
95
+ ALLOWED_TYPES = %w[jar pom].freeze
96
+
97
+ def initialize(options, *args)
98
+ @type, @group_id, @artifact_id, @classifier, @version, @exclusions = *args
99
+ options.each do |k, v|
100
+ instance_variable_set("@#{k}", v)
101
+ end
102
+ end
103
+
104
+ def self.new(line)
105
+ line = line.strip
106
+ index = line.index(/\s/)
107
+ return nil if index.nil?
108
+
109
+ type = line[0..index].strip
110
+ return nil unless ALLOWED_TYPES.member?(type)
111
+
112
+ line = line[index..]
113
+ line.gsub!(/['"]/, "")
114
+ line.strip!
115
+
116
+ options = {}
117
+ line.sub!(/,\s*:exclusions\s*(:|=>)\s*(\[[^\]]+\])/) do
118
+ options[:exclusions] = Exclusions.new(Regexp.last_match(2).strip)
119
+ ""
120
+ end
121
+ line.sub!(/,\s*:([a-z]+)\s*(:|=>)\s*(:?[a-zA-Z0-9_]+)/) do
122
+ options[Regexp.last_match(1).to_sym] = Regexp.last_match(3).sub(/^:/, "")
123
+ ""
124
+ end
125
+ exclusions = nil
126
+ line.sub!(/[,:]\s*\[(.+:.+,?\s*)+\]$/) do |a|
127
+ exclusions = Exclusions.new(a[1..].strip)
128
+ ""
129
+ end
130
+
131
+ line.strip!
132
+ line.gsub!(/,\s*/, ":")
133
+
134
+ if /[\[()\]]/.match?(line)
135
+ index = line.index(/[\[(].+$/)
136
+ version = line[index..].sub(/:/, ", ")
137
+ line = line[0..index - 1].strip.sub(/:$/, "")
138
+ else
139
+ index = line.index(/:[^:]+$/)
140
+ version = line[index + 1..]
141
+ line = line[0..index - 1].strip
142
+ end
143
+
144
+ case line.count(":")
145
+ when 2
146
+ group_id, artifact_id, classifier = line.split(":")
147
+ when 1
148
+ group_id, artifact_id = line.split(":")
149
+ classifier = nil
150
+ else
151
+ warn line
152
+ return nil
153
+ end
154
+ super(options, type, group_id, artifact_id, classifier, version, exclusions)
155
+ end
156
+
157
+ def to_s
158
+ args = [@group_id, @artifact_id]
159
+ args << @classifier if @classifier
160
+ args << @version
161
+ args << @exclusions.to_s if @exclusions
162
+ "#{@type} #{group_id}:#{args[1..].join(", ")}"
163
+ end
164
+
165
+ def to_gacv
166
+ args = [@group_id, @artifact_id]
167
+ args << @classifier if @classifier
168
+ args << @version
169
+ args.join(":")
170
+ end
171
+
172
+ def to_coord_no_classifier
173
+ args = [@group_id, @artifact_id]
174
+ args << @type
175
+ args << MavenVersion.new(@version)
176
+ args.join(":")
177
+ end
178
+
179
+ def to_coord
180
+ args = [@group_id, @artifact_id]
181
+ args << @classifier if @classifier
182
+ args << @type
183
+ args << MavenVersion.new(@version)
184
+ args.join(":")
185
+ end
186
+
187
+ def key
188
+ args = [@group_id, @artifact_id]
189
+ args << @classifier if @classifier
190
+ args.join(":")
191
+ end
192
+ end
193
+
194
+ attr_reader :artifacts
195
+
196
+ def initialize(spec)
197
+ @artifacts = []
198
+ spec.requirements.each do |req|
199
+ req.split("\n").each do |line|
200
+ if (a = Artifact.new(line))
201
+ @artifacts << a
202
+ end
203
+ end
204
+ end
205
+ @artifacts.freeze
206
+ end
207
+
208
+ def [](index)
209
+ @artifacts[index]
210
+ end
211
+
212
+ def each(&block)
213
+ @artifacts.each(&block)
214
+ end
215
+
216
+ def size
217
+ @artifacts.size
218
+ end
219
+ end
220
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ # this file is maven DSL and used by maven via jars/maven_exec.rb
4
+
5
+ def eval_file(file)
6
+ file = File.join(__dir__, file)
7
+ eval(File.read(file), nil, file) # rubocop:disable Security/Eval
8
+ end
9
+
10
+ eval_file("attach_jars_pom.rb")
11
+ eval_file("output_jars_pom.rb")
@@ -0,0 +1,221 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "jar_dependencies"
4
+ require "jars/maven_exec"
5
+
6
+ module Jars
7
+ class Installer
8
+ class Dependency
9
+ attr_reader :path, :file, :gav, :scope, :type, :coord
10
+
11
+ def self.new(line)
12
+ super if /:jar:|:pom:/.match?(line)
13
+ end
14
+
15
+ def setup_type(line)
16
+ if line.index(":pom:")
17
+ @type = :pom
18
+ elsif line.index(":jar:")
19
+ @type = :jar
20
+ end
21
+ end
22
+ private :setup_type
23
+
24
+ def setup_scope(line)
25
+ @scope =
26
+ case line
27
+ when /:provided:/
28
+ :provided
29
+ when /:test:/
30
+ :test
31
+ else
32
+ :runtime
33
+ end
34
+ end
35
+ private :setup_scope
36
+
37
+ REG = /:jar:|:pom:|:test:|:compile:|:runtime:|:provided:|:system:/.freeze
38
+ EMPTY = ""
39
+ def initialize(line)
40
+ setup_type(line)
41
+
42
+ line.strip!
43
+ @coord = line.sub(/:[^:]+:([A-Z]:\\)?[^:]+$/, EMPTY)
44
+ first, second = @coord.split(/:#{type}:/)
45
+ group_id, artifact_id = first.split(":")
46
+ parts = group_id.split(".")
47
+ parts << artifact_id
48
+ parts << second.split(":")[-1]
49
+ @file = line.slice(@coord.length, line.length).sub(REG, EMPTY).strip
50
+ last = @file.reverse.index(%r{\\|/})
51
+ parts << line[-last..]
52
+ @path = File.join(parts).strip
53
+
54
+ setup_scope(line)
55
+
56
+ @system = !line.index(":system:").nil?
57
+ @gav = @coord.sub(REG, ":")
58
+ end
59
+
60
+ def system?
61
+ @system
62
+ end
63
+ end
64
+
65
+ def self.install_jars(write_require_file: false)
66
+ new.install_jars(write_require_file: write_require_file)
67
+ end
68
+
69
+ def self.load_from_maven(file)
70
+ result = []
71
+ File.read(file).each_line do |line|
72
+ dep = Dependency.new(line)
73
+ result << dep if dep && dep.scope == :runtime
74
+ end
75
+ result
76
+ end
77
+
78
+ def self.vendor_file(dir, dep)
79
+ return unless !dep.system? && dep.type == :jar && dep.scope == :runtime
80
+
81
+ vendored = File.join(dir, dep.path)
82
+ FileUtils.mkdir_p(File.dirname(vendored))
83
+ FileUtils.cp(dep.file, vendored)
84
+ end
85
+
86
+ def self.print_require_jar(file, dep, fallback: false)
87
+ return if dep.type != :jar || dep.scope != :runtime
88
+
89
+ if dep.system?
90
+ file&.puts("require '#{dep.file}'")
91
+ elsif dep.scope == :runtime
92
+ if fallback
93
+ file&.puts(" require '#{dep.path}'")
94
+ else
95
+ file&.puts(" require_jar '#{dep.gav.gsub(":", "', '")}'")
96
+ end
97
+ end
98
+ end
99
+
100
+ COMMENT = "# this is a generated file, to avoid over-writing it just delete this comment"
101
+ def self.needs_to_write?(require_filename)
102
+ require_filename && (!File.exist?(require_filename) || File.read(require_filename).match(COMMENT))
103
+ end
104
+
105
+ def self.write_require_jars(deps, require_filename)
106
+ return unless needs_to_write?(require_filename)
107
+
108
+ FileUtils.mkdir_p(File.dirname(require_filename))
109
+ File.open(require_filename, "w") do |f|
110
+ f.puts COMMENT
111
+ f.puts "begin"
112
+ f.puts " require 'jar_dependencies'"
113
+ f.puts "rescue LoadError"
114
+ deps.each do |dep|
115
+ # do not use require_jar method
116
+ print_require_jar(f, dep, fallback: true)
117
+ end
118
+ f.puts "end"
119
+ f.puts
120
+ f.puts "if defined? Jars"
121
+ deps.each do |dep|
122
+ print_require_jar(f, dep)
123
+ end
124
+ f.puts "end"
125
+ end
126
+ end
127
+
128
+ def self.vendor_jars(deps, dir)
129
+ deps.each do |dep|
130
+ vendor_file(dir, dep)
131
+ end
132
+ end
133
+
134
+ def initialize(spec = nil)
135
+ @mvn = MavenExec.new(spec)
136
+ end
137
+
138
+ def spec
139
+ @mvn.spec
140
+ end
141
+
142
+ def vendor_jars(vendor_dir = nil, write_require_file: true)
143
+ return unless jars?
144
+
145
+ if Jars.to_prop(Jars::VENDOR) == "false"
146
+ vendor_dir = nil
147
+ else
148
+ vendor_dir ||= spec.require_path
149
+ end
150
+ do_install(vendor_dir, write_require_file)
151
+ end
152
+
153
+ def self.vendor_jars!(vendor_dir = nil)
154
+ new.vendor_jars!(vendor_dir)
155
+ end
156
+
157
+ def vendor_jars!(vendor_dir = nil, write_require_file: true)
158
+ vendor_dir ||= spec.require_path
159
+ do_install(vendor_dir, write_require_file)
160
+ end
161
+
162
+ def install_jars(write_require_file: true)
163
+ return unless jars?
164
+
165
+ do_install(nil, write_require_file)
166
+ end
167
+
168
+ def ruby_maven_install_options=(options)
169
+ @mvn.ruby_maven_install_options = options
170
+ end
171
+
172
+ def jars?
173
+ # first look if there are any requirements in the spec
174
+ # and then if gem depends on jar-dependencies for runtime.
175
+ # only then install the jars declared in the requirements
176
+ result = (spec = self.spec) && !spec.requirements.empty? &&
177
+ spec.dependencies.detect { |d| d.name == "jar-dependencies" && d.type == :runtime }
178
+ if result && spec.platform.to_s != "java"
179
+ Jars.warn "\njar dependencies found on non-java platform gem - do not install jars\n"
180
+ false
181
+ else
182
+ result
183
+ end
184
+ end
185
+
186
+ private
187
+
188
+ def do_install(vendor_dir, write_require_file)
189
+ if !spec.require_paths.include?(vendor_dir) && vendor_dir
190
+ raise "vendor dir #{vendor_dir} not in require_paths of gemspec #{spec.require_paths}"
191
+ end
192
+
193
+ target_dir = File.join(@mvn.basedir, vendor_dir || spec.require_path)
194
+ jars_file = File.join(target_dir, "#{spec.name}_jars.rb")
195
+
196
+ # write out new jars_file it write_require_file is true or
197
+ # check timestamps:
198
+ # do not generate file if specfile is older then the generated file
199
+ if !write_require_file &&
200
+ File.exist?(jars_file) &&
201
+ File.mtime(@mvn.specfile) < File.mtime(jars_file)
202
+ # leave jars_file as is
203
+ jars_file = nil
204
+ end
205
+ deps = install_dependencies
206
+ self.class.write_require_jars(deps, jars_file)
207
+ self.class.vendor_jars(target_dir, write_require_file: deps) if vendor_dir
208
+ end
209
+
210
+ def install_dependencies
211
+ deps = File.join(@mvn.basedir, "deps.lst")
212
+
213
+ puts " jar dependencies for #{spec.spec_name} . . ." unless Jars.quiet?
214
+ @mvn.resolve_dependencies_list(deps)
215
+
216
+ self.class.load_from_maven(deps)
217
+ ensure
218
+ FileUtils.rm_f(deps) if deps
219
+ end
220
+ end
221
+ end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "jars/maven_exec"
4
+
5
+ module Jars
6
+ class JarDetails < Array
7
+ def scope
8
+ self[-2].to_sym
9
+ end
10
+
11
+ def file
12
+ file = self[-1].strip
13
+ file.empty? ? path : file
14
+ end
15
+
16
+ def group_id
17
+ self[0]
18
+ end
19
+
20
+ def artifact_id
21
+ self[1]
22
+ end
23
+
24
+ def version
25
+ self[-3]
26
+ end
27
+
28
+ def classifier
29
+ size == 5 ? nil : self[2]
30
+ end
31
+
32
+ def gacv
33
+ classifier ? self[0..3] : self[0..2]
34
+ end
35
+
36
+ def path
37
+ if scope == :system
38
+ # replace maven like system properties embedded into the string
39
+ self[-1].gsub(/\$\{[a-zA-Z.]+\}/) do |a|
40
+ ENV_JAVA[a[2..-2]] || a
41
+ end
42
+ else
43
+ File.join(Jars.home, group_id.gsub(/[.]/, "/"), artifact_id, version, "#{gacv[1..].join("-")}.jar")
44
+ end
45
+ end
46
+ end
47
+
48
+ class Lock
49
+ def initialize(file)
50
+ @file = file
51
+ end
52
+
53
+ def process(scope)
54
+ scope ||= :runtime
55
+ File.read(@file).each_line do |line|
56
+ next unless /:.+:/.match?(line)
57
+
58
+ jar = JarDetails.new(line.strip.sub(/:jar:/, ":").sub(/:$/, ": ").split(":"))
59
+ case scope
60
+ when :all, :test
61
+ yield jar
62
+ when :compile
63
+ # jar.scope is maven scope
64
+ yield jar if jar.scope != :test
65
+ when :provided
66
+ # jar.scope is maven scope
67
+ yield jar if jar.scope == :provided
68
+ when :runtime
69
+ # jar.scope is maven scope
70
+ yield jar if (jar.scope != :test) && (jar.scope != :provided)
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,102 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fileutils"
4
+ require "jar_dependencies"
5
+ require "jars/version"
6
+ require "jars/maven_factory"
7
+ require "jars/gemspec_artifacts"
8
+
9
+ module Jars
10
+ class LockDown
11
+ attr_reader :debug, :verbose
12
+
13
+ def initialize(debug, verbose)
14
+ @debug = debug
15
+ @verbose = verbose
16
+ end
17
+
18
+ def maven_new
19
+ factory = MavenFactory.new({}, @debug, @verbose)
20
+ pom = File.expand_path("lock_down_pom.rb", __dir__)
21
+ m = factory.maven_new(pom)
22
+ m["jruby.plugins.version"] = Jars::JRUBY_PLUGINS_VERSION
23
+ m["dependency.plugin.version"] = Jars::DEPENDENCY_PLUGIN_VERSION
24
+ m["jars.basedir"] = File.expand_path(basedir)
25
+ jarfile = File.expand_path(Jars.jarfile)
26
+ m["jars.jarfile"] = jarfile if File.exist?(jarfile)
27
+ attach_jar_coordinates_from_bundler_dependencies(m)
28
+ m
29
+ end
30
+ private :maven_new
31
+
32
+ def maven
33
+ @maven ||= maven_new
34
+ end
35
+
36
+ def basedir
37
+ File.expand_path(".")
38
+ end
39
+
40
+ def attach_jar_coordinates_from_bundler_dependencies(maven)
41
+ load_path = $LOAD_PATH.dup
42
+ require "bundler"
43
+ # TODO: make this group a commandline option
44
+ Bundler.setup("default")
45
+ maven.property("jars.bundler", true)
46
+ cwd = File.expand_path(".")
47
+ maven.attach_repos
48
+ Gem.loaded_specs.each do |_name, spec|
49
+ # if gemspec is local then include all dependencies
50
+ maven.attach_jars(spec, all_dependencies: cwd == spec.full_gem_path)
51
+ end
52
+ rescue LoadError => e
53
+ if Jars.verbose?
54
+ warn e.message
55
+ warn "no bundler found - ignore Gemfile if exists"
56
+ end
57
+ rescue Bundler::GemfileNotFound
58
+ # do nothing then as we have bundler but no Gemfile
59
+ rescue Bundler::GemNotFound
60
+ warn "can not setup bundler with #{Bundler.default_lockfile}"
61
+ raise
62
+ ensure
63
+ $LOAD_PATH.replace(load_path)
64
+ end
65
+
66
+ def lock_down(vendor_dir = nil, force: false, update: false, tree: nil)
67
+ out = File.expand_path(".jars.output")
68
+ tree_provided = tree
69
+ tree ||= File.expand_path(".jars.tree")
70
+ maven.property("jars.outputFile", out)
71
+ maven.property("maven.repo.local", Jars.local_maven_repo)
72
+ maven.property("jars.home", File.expand_path(vendor_dir)) if vendor_dir
73
+ maven.property("jars.lock", File.expand_path(Jars.lock))
74
+ maven.property("jars.force", force)
75
+ maven.property("jars.update", update) if update
76
+ # tell not to use Jars.lock as part of POM when running mvn
77
+ maven.property("jars.skip.lock", true)
78
+
79
+ args = ["gem:jars-lock"]
80
+ args += ["dependency:tree", "-P -gemfile.lock", "-DoutputFile=#{tree}"] if tree_provided
81
+
82
+ puts
83
+ puts "-- jar root dependencies --"
84
+ puts
85
+ status = maven.exec(*args)
86
+ exit 1 unless status
87
+ if File.exist?(tree)
88
+ puts
89
+ puts "-- jar dependency tree --"
90
+ puts
91
+ puts File.read(tree)
92
+ puts
93
+ end
94
+ puts
95
+ puts File.read(out).gsub("#{File.dirname(out)}/", "")
96
+ puts
97
+ ensure
98
+ FileUtils.rm_f out
99
+ FileUtils.rm_f tree
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ # this file is maven DSL and used by maven via jars/lock_down.rb
4
+
5
+ basedir(ENV_JAVA["jars.basedir"])
6
+
7
+ def eval_file(file)
8
+ file = File.join(__dir__, file)
9
+ eval(File.read(file), nil, file) # rubocop:disable Security/Eval
10
+ end
11
+
12
+ eval_file("attach_jars_pom.rb")
13
+
14
+ jfile = ENV_JAVA["jars.jarfile"]
15
+ jarfile(jfile) if jfile
16
+
17
+ # need to fix the version of this plugin for gem:jars_lock goal
18
+ jruby_plugin :gem, ENV_JAVA["jruby.plugins.version"]
19
+
20
+ # if you use bundler we collect all root jar dependencies
21
+ # from each gemspec file. otherwise we need to resolve
22
+ # the gemspec artifact in the maven way
23
+ unless ENV_JAVA["jars.bundler"]
24
+ begin
25
+ gemspec
26
+ rescue
27
+ nil
28
+ end
29
+ end
30
+
31
+ properties("project.build.sourceEncoding" => "utf-8")
32
+
33
+ plugin :dependency, ENV_JAVA["dependency.plugin.version"]
34
+
35
+ eval_file("output_jars_pom.rb")