Class: Jars::MavenExec
- Inherits:
-
Object
- Object
- Jars::MavenExec
- Defined in:
- lib/jars/maven_exec.rb
Instance Attribute Summary collapse
-
#basedir ⇒ Object
readonly
Returns the value of attribute basedir.
-
#spec ⇒ Object
readonly
Returns the value of attribute spec.
-
#specfile ⇒ Object
readonly
Returns the value of attribute specfile.
Instance Method Summary collapse
-
#initialize(spec = nil) ⇒ MavenExec
constructor
A new instance of MavenExec.
- #resolve_dependencies_list(file) ⇒ Object
- #setup(spec = nil, allow_no_file: false) ⇒ Object
Constructor Details
#initialize(spec = nil) ⇒ MavenExec
Returns a new instance of MavenExec.
23 24 25 26 27 28 |
# File 'lib/jars/maven_exec.rb', line 23 def initialize(spec = nil) setup(spec) rescue StandardError, LoadError => e Jars.warn "unable to load gemspec (#{e.}); skipping jar dependency discovery" Jars.debug(e) end |
Instance Attribute Details
#basedir ⇒ Object (readonly)
Returns the value of attribute basedir.
21 22 23 |
# File 'lib/jars/maven_exec.rb', line 21 def basedir @basedir end |
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
21 22 23 |
# File 'lib/jars/maven_exec.rb', line 21 def spec @spec end |
#specfile ⇒ Object (readonly)
Returns the value of attribute specfile.
21 22 23 |
# File 'lib/jars/maven_exec.rb', line 21 def specfile @specfile end |
Instance Method Details
#resolve_dependencies_list(file) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/jars/maven_exec.rb', line 59 def resolve_dependencies_list(file) require 'jars/mima' artifacts = GemspecArtifacts.new(@spec) is_local_file = File.(File.dirname(@specfile)) == File.(Dir.pwd) resolved = Jars::Mima.resolve_artifacts(artifacts.artifacts, all_dependencies: is_local_file) # Write output in Maven dependency:list format for Installer::Dependency compatibility allowed_types = %w[jar pom].freeze File.open(file, 'w') do |f| f.puts f.puts 'The following files have been resolved:' resolved.each do |dep| next unless allowed_types.include?(dep.type) line = +" #{dep.group_id}:#{dep.artifact_id}:#{dep.type}:" line << "#{dep.classifier}:" if dep.classifier line << "#{dep.version}:#{dep.scope}:#{dep.file}" f.puts line end end end |
#setup(spec = nil, allow_no_file: false) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/jars/maven_exec.rb', line 30 def setup(spec = nil, allow_no_file: false) spec ||= find_spec(allow_no_file) case spec when String @specfile = File.(spec) @basedir = File.dirname(@specfile) Dir.chdir(@basedir) do spec = eval(File.read(@specfile), TOPLEVEL_BINDING, @specfile) # rubocop:disable Security/Eval end when Gem::Specification if File.exist?(spec.loaded_from) @basedir = spec.gem_dir @specfile = spec.loaded_from else # this happens with bundle and local gems # there spec_file is "not installed" but is inside the gem_dir directory Dir.chdir(spec.gem_dir) do setup(nil, allow_no_file: true) end end when nil # ignore else Jars.debug "unsupported spec argument #{spec.class}; expected String or Gem::Specification" end @spec = spec end |