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(options = {}) ⇒ Object
- #maven ⇒ Object
Constructor Details
permalink #initialize(debug, verbose) ⇒ LockDown
Returns a new instance of LockDown.
12 13 14 15 |
# File 'lib/jars/lock_down.rb', line 12 def initialize( debug, verbose ) @debug = debug @verbose = verbose end |
Instance Attribute Details
permalink #debug ⇒ Object (readonly)
Returns the value of attribute debug.
10 11 12 |
# File 'lib/jars/lock_down.rb', line 10 def debug @debug end |
permalink #verbose ⇒ Object (readonly)
Returns the value of attribute verbose.
10 11 12 |
# File 'lib/jars/lock_down.rb', line 10 def verbose @verbose end |
Instance Method Details
permalink #attach_jar_coordinates_from_bundler_dependencies(maven) ⇒ Object
[View source]
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/jars/lock_down.rb', line 39 def attach_jar_coordinates_from_bundler_dependencies( maven ) load_path = $LOAD_PATH.dup require 'bundler/setup' done = [] index = 0 Gem.loaded_specs.each do |name, spec| deps = GemspecArtifacts.new( spec ) deps.artifacts.each do |a| unless done.include? a.key maven.property( "jars.#{index}", a.to_coord ) if a.exclusions jndex = 0 a.exclusions.each do |ex| maven.property( "jars.#{index}.exclusions.#{jndex}", ex.to_s ) end end maven.property( "jars.#{index}.scope", a.scope ) if a.scope index += 1 done << a.key end end end rescue LoadError => e if Jars.verbose? warn e. warn "no bundler found - ignore Gemfile if exists" end rescue SystemExit # we want to continue ensure $LOAD_PATH.replace( load_path ) end |
permalink #basedir ⇒ Object
[View source]
35 36 37 |
# File 'lib/jars/lock_down.rb', line 35 def basedir File.( '.' ) end |
permalink #lock_down(options = {}) ⇒ Object
[View source]
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 100 101 102 103 104 105 106 |
# File 'lib/jars/lock_down.rb', line 72 def lock_down( = {} ) vendor_dir = File.( [ :vendor_dir ] ) if [ :vendor_dir ] out = File.( '.jars.output' ) tree = File.( '.jars.tree' ) maven.property( 'jars.outputFile', out ) maven.property( 'maven.repo.local', Jars.home ) maven.property( 'jars.home', vendor_dir ) if vendor_dir maven.property( 'jars.lock', File.( Jars.lock ) ) maven.property( 'jars.force', [ :force ] == true ) maven.property( 'jars.update', [ :update ] ) if [ :update ] args = [ 'gem:jars-lock' ] if [ :tree ] args += [ 'dependency:tree', '-P -gemfile.lock', '-DoutputFile=' + tree ] end puts puts '-- jar root dependencies --' puts status = maven.exec( *args ) exit 1 unless status if File.exists?( 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 |
permalink #maven ⇒ Object
[View source]
31 32 33 |
# File 'lib/jars/lock_down.rb', line 31 def maven @maven ||= maven_new end |