Class: Jars::LockDown
- Inherits:
-
Object
- Object
- Jars::LockDown
- Defined in:
- lib/jars/lock_down.rb
Instance Attribute Summary collapse
-
#debug ⇒ Object
readonly
Returns the value of attribute debug.
-
#verbose ⇒ Object
readonly
Returns the value of attribute verbose.
Instance Method Summary collapse
- #attach_jar_coordinates_from_bundler_dependencies(maven) ⇒ Object
- #basedir ⇒ Object
-
#initialize(debug, verbose) ⇒ LockDown
constructor
A new instance of LockDown.
- #lock_down(vendor_dir = nil, force: false, update: false, tree: nil) ⇒ Object
- #maven ⇒ Object
Constructor Details
#initialize(debug, verbose) ⇒ LockDown
Returns a new instance of LockDown.
13 14 15 16 |
# File 'lib/jars/lock_down.rb', line 13 def initialize(debug, verbose) @debug = debug @verbose = verbose end |
Instance Attribute Details
#debug ⇒ Object (readonly)
Returns the value of attribute debug.
11 12 13 |
# File 'lib/jars/lock_down.rb', line 11 def debug @debug end |
#verbose ⇒ Object (readonly)
Returns the value of attribute verbose.
11 12 13 |
# File 'lib/jars/lock_down.rb', line 11 def verbose @verbose end |
Instance Method Details
#attach_jar_coordinates_from_bundler_dependencies(maven) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/jars/lock_down.rb', line 40 def attach_jar_coordinates_from_bundler_dependencies(maven) load_path = $LOAD_PATH.dup require 'bundler' # TODO: make this group a commandline option Bundler.setup('default') maven.property('jars.bundler', true) cwd = File.('.') Gem.loaded_specs.each do |_name, spec| # if gemspec is local then include all dependencies maven.attach_jars(spec, all_dependencies: cwd == spec.full_gem_path) end rescue LoadError => e if Jars.verbose? warn e. warn 'no bundler found - ignore Gemfile if exists' end rescue Bundler::GemfileNotFound # do nothing then as we have bundler but no Gemfile rescue Bundler::GemNotFound warn "can not setup bundler with #{Bundler.default_lockfile}" raise ensure $LOAD_PATH.replace(load_path) end |
#basedir ⇒ Object
36 37 38 |
# File 'lib/jars/lock_down.rb', line 36 def basedir File.('.') end |
#lock_down(vendor_dir = nil, force: false, update: false, tree: nil) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/jars/lock_down.rb', line 65 def lock_down(vendor_dir = nil, force: false, update: false, tree: nil) out = File.('.jars.output') tree_provided = tree tree ||= File.('.jars.tree') maven.property('jars.outputFile', out) maven.property('maven.repo.local', Jars.local_maven_repo) maven.property('jars.home', File.(vendor_dir)) if vendor_dir maven.property('jars.lock', File.(Jars.lock)) maven.property('jars.force', force) maven.property('jars.update', update) if update # tell not to use Jars.lock as part of POM when running mvn maven.property('jars.skip.lock', true) args = ['gem:jars-lock'] args += ['dependency:tree', '-P -gemfile.lock', "-DoutputFile=#{tree}"] if tree_provided puts puts '-- jar root dependencies --' puts status = maven.exec(*args) exit 1 unless status if File.exist?(tree) puts puts '-- jar dependency tree --' puts puts File.read(tree) puts end puts puts File.read(out).gsub("#{File.dirname(out)}/", '') puts ensure FileUtils.rm_f out FileUtils.rm_f tree end |
#maven ⇒ Object
32 33 34 |
# File 'lib/jars/lock_down.rb', line 32 def maven @maven ||= maven_new end |