jbundler 0.6.4 → 0.7.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b6847586be4e702359fb9d976eb8182a0755ceaa
4
- data.tar.gz: f2f2fdf3e409c2546f5fc7fe3e2667c366387a5f
3
+ metadata.gz: 275f83f5be90c00276878e73a1d4ef53702107d8
4
+ data.tar.gz: 3704bde15e98b5ea6b5f0f3c76d7a3e2d4f45662
5
5
  SHA512:
6
- metadata.gz: ff23acbae92baba94fa31523d692d3638ca834790fee3579ebb165eff8d31d24c374db8bb570122002c5336a50b0ff1ad1c11452b3cb35246d426ce1cb39e61c
7
- data.tar.gz: cf96c9d43080f190daa6485c65c24d2733dfa3b4828005ca4cb4759164d2b5b44d3765602be07694ce005d88ae814f0f74428ca84354ce927063e93465be7f3f
6
+ metadata.gz: a6d85deca5ed0c0bbb374da66d137c0168c250c8cc5131d282e0d537853df3d5d870cb7978da89ea44623d20d7faae12fa7455cfad0cab8796293dc5a7a4aca6
7
+ data.tar.gz: 0819bdf611d0b905b73b493f19a4cfc312c3c75d298995ce48dbe8636f1eb6f216bc5d55e4d792f7ed58ed9a80290f26d047ce4889caf9f0c8f0f1c38861a9c6
data/Gemfile CHANGED
@@ -4,4 +4,3 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem "copyright-header", "1.0.8", :platform => :mri, :group => :copyright
7
-
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jbundler (0.6.4)
4
+ jbundler (0.6.5.dev)
5
5
  bundler (~> 1.5)
6
- jar-dependencies (~> 0.1.3)
6
+ jar-dependencies (~> 0.1.5.dev)
7
+ maven-tools (= 1.0.6.dev)
7
8
  ruby-maven (>= 3.1.1.0.6, < 3.1.2)
8
9
 
9
10
  GEM
@@ -19,11 +20,11 @@ GEM
19
20
  thread_safe (~> 0.3, >= 0.3.1)
20
21
  equalizer (0.0.9)
21
22
  ice_nine (0.11.0)
22
- jar-dependencies (0.1.3)
23
- maven-tools (1.0.5)
23
+ jar-dependencies (0.1.5.dev)
24
+ maven-tools (1.0.6.dev)
24
25
  virtus (~> 1.0)
25
- minitest (5.4.2)
26
- rake (10.3.2)
26
+ minitest (5.4.3)
27
+ rake (10.4.0)
27
28
  ruby-maven (3.1.1.0.8)
28
29
  maven-tools (~> 1.0.1)
29
30
  ruby-maven-libs (= 3.1.1)
Binary file
@@ -20,6 +20,7 @@
20
20
  #
21
21
 
22
22
  require 'jbundler/context'
23
+ require 'jbundler/lock_down'
23
24
 
24
25
  module JBundler
25
26
 
@@ -32,29 +33,6 @@ module JBundler
32
33
  context.config
33
34
  end
34
35
 
35
- def self.update
36
- if( context.classpath.needs_update?( context.jarfile,
37
- context.gemfile_lock ) and
38
- not context.vendor.vendored? )
39
-
40
- warn ''
41
- warn 'jar bundle is outdated - use jbundle install to update bundle'
42
- warn ''
43
-
44
- aether = JBundler::AetherRuby.new( context.config )
45
-
46
- context.jarfile.populate_unlocked( aether )
47
- context.gemfile_lock.populate_dependencies( aether )
48
- context.jarfile.populate_locked( aether )
49
-
50
- aether.resolve
51
-
52
- context.classpath.generate( aether.classpath_array, [], [],
53
- context.config.local_repository )
54
- context.jarfile.generate_lockfile( aether.resolved_coordinates )
55
- end
56
- end
57
-
58
36
  def self.require_jars
59
37
  if context.vendor.vendored?
60
38
  jars = context.vendor.require_jars
@@ -77,11 +55,16 @@ module JBundler
77
55
  end
78
56
  end
79
57
 
58
+ def self.install( debug = false, verbose = false )
59
+ jbundler = JBundler::LockDown.new( context.config )
60
+ msg = jbundler.lock_down( false, debug, verbose )
61
+ puts msg if msg
62
+ end
63
+
80
64
  def self.setup
81
65
  if context.config.skip
82
66
  warn "skip jbundler setup" if context.config.verbose
83
67
  else
84
- update
85
68
  require_jars
86
69
  end
87
70
  end
@@ -25,6 +25,10 @@ module JBundler
25
25
  def initialize(classpathfile = '.jbundler/classpath.rb')
26
26
  @classpathfile = classpathfile
27
27
  end
28
+
29
+ def file
30
+ @classpathfile
31
+ end
28
32
 
29
33
  def load_classpath
30
34
  load File.expand_path @classpathfile
@@ -61,7 +65,7 @@ module JBundler
61
65
  end
62
66
 
63
67
  def needs_update?(jarfile, gemfile_lock)
64
- if jarfile.exists? || gemfile_lock.exists? || jarfile.exists_lock?
68
+ if ( jarfile.exists? || gemfile_lock.exists? || jarfile.exists_lock? )
65
69
  missing?( jarfile ) || jarfile_newer?( jarfile ) || jarlock_newer?( jarfile ) || gemfile_lock.newer?( mtime )
66
70
  else
67
71
  false
@@ -87,14 +91,25 @@ module JBundler
87
91
  def dump_array( file, array, prefix, local_repo )
88
92
  file.puts "JBUNDLER_#{prefix}CLASSPATH = []"
89
93
  array.each do |path|
90
- if local_repo
91
- path.sub!( /#{local_repo}/, '' )
92
- file.puts "JBUNDLER_#{prefix}CLASSPATH << (JBUNDLER_LOCAL_REPO + '#{path}')" unless path =~ /pom$/
93
- else
94
- file.puts "JBUNDLER_#{prefix}CLASSPATH << '#{path}'" unless path =~ /pom$/
95
- end
94
+ dump_jar( file, path, prefix, local_repo )
96
95
  end
97
96
  file.puts "JBUNDLER_#{prefix}CLASSPATH.freeze"
98
97
  end
98
+
99
+ def dump_jar( file, path, prefix, local_repo )
100
+ return if path =~ /pom$/
101
+ if local_repo
102
+ path.sub!( /#{local_repo}/, '' )
103
+ unless File.exists?( path )
104
+ file.puts "JBUNDLER_#{prefix}CLASSPATH << (JBUNDLER_LOCAL_REPO + '#{path}')"
105
+ path = nil
106
+ end
107
+ end
108
+ if path
109
+ # either we do not have a local_repo or the path is a absolute
110
+ # path from system artifact
111
+ file.puts "JBUNDLER_#{prefix}CLASSPATH << '#{path}'"
112
+ end
113
+ end
99
114
  end
100
115
  end
@@ -89,12 +89,16 @@ module JBundler
89
89
  method_option :no_cache, :type => :boolean
90
90
  method_option :quiet, :type => :boolean
91
91
  def install
92
- JBundler::LockDown.new( config ).lock_down( options[ :vendor ],
93
- options[ :debug ] ,
94
- options[ :verbose ] )
92
+ msg = JBundler::LockDown.new( config ).lock_down( options[ :vendor ],
93
+ options[ :debug ] ,
94
+ options[ :verbose ] )
95
95
  config.verbose = ! options[ :quiet ]
96
96
  Show.new( config ).show_classpath
97
- puts 'jbundle complete' unless options[ :quiet ]
97
+ unless options[ :quiet ]
98
+ puts 'jbundle complete !'
99
+ puts
100
+ end
101
+ puts msg if msg
98
102
  end
99
103
 
100
104
  desc 'executable', 'create an executable jar with a given bootstrap.rb file\nLIMITATION: only for jruby 1.6.x and newer'
@@ -9,7 +9,7 @@ if basedir != bdir
9
9
  self.instance_variable_set( :@basedir, bdir )
10
10
  end
11
11
 
12
- jarfile( jfile, :skip_locked => true )
12
+ jarfile( jfile )
13
13
 
14
14
  ( 0..(java.lang.System.getProperty( "jbundler.jars.size" ).to_i - 1) ).each do |i|
15
15
  dependency_artifact Maven::Tools::Artifact.from_coordinate( java.lang.System.getProperty( "jbundler.jars.#{i}" ).to_s )
@@ -0,0 +1,67 @@
1
+ #
2
+ # Copyright (C) 2014 Christian Meier
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
5
+ # this software and associated documentation files (the "Software"), to deal in
6
+ # the Software without restriction, including without limitation the rights to
7
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8
+ # the Software, and to permit persons to whom the Software is furnished to do so,
9
+ # subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in all
12
+ # copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+ #
21
+ require 'jar_dependencies'
22
+ require 'maven/tools/dsl/jarfile_lock'
23
+ module JBundler
24
+ class JarfileLock < Maven::Tools::DSL::JarfileLock
25
+
26
+ def require( scope = :runtime )
27
+ coordinates( scope ).each do |coord|
28
+ Jars.require_jar( coord.split( /:/ ) )
29
+ end
30
+ end
31
+
32
+ def classpath( scope = :runtime )
33
+ coordinates( scope ).collect do |coord|
34
+ path_to_jar( coord.split( /:/ ) )
35
+ end
36
+ end
37
+
38
+ def downloaded?
39
+ classpath.member?( nil ) == false &&
40
+ classpath( :test ).member?( nil ) == false
41
+ end
42
+
43
+ private
44
+
45
+ # TODO should move into jar-dependencies
46
+ def to_path( group_id, artifact_id, *classifier_version )
47
+ version = classifier_version[ -1 ]
48
+ classifier = classifier_version[ -2 ]
49
+
50
+ jar = to_jar( group_id, artifact_id, version, classifier )
51
+ ( [ Jars.home ] + $LOAD_PATH ).each do |path|
52
+ if File.exists?( f = File.join( path, jar ) )
53
+ return f
54
+ end
55
+ end
56
+ nil
57
+ end
58
+
59
+ # TODO this is copy and paste from jar-dependncies
60
+ def to_jar( group_id, artifact_id, version, classifier )
61
+ file = "#{group_id.gsub( /\./, '/' )}/#{artifact_id}/#{version}/#{artifact_id}-#{version}"
62
+ file << "-#{classifier}" if classifier
63
+ file << '.jar'
64
+ file
65
+ end
66
+ end
67
+ end
@@ -32,23 +32,28 @@ module JBundler
32
32
  end
33
33
 
34
34
  def lock_down( needs_vendor = false, debug = false, verbose = false )
35
+ jarfile = Maven::Tools::Jarfile.new( @config.jarfile )
35
36
  classpath = JBundler::ClasspathFile.new( @config.classpath_file )
36
- needs_update = needs_update?( classpath )
37
+ if jarfile.exists_lock? && classpath.exists?
38
+ needs_update = false
39
+ else
40
+ needs_update = needs_update?( jarfile, classpath )
41
+ end
37
42
  if ( ! needs_update && ! needs_vendor ) || vendor.vendored?
38
43
 
39
44
  puts 'Jar dependencies are up to date !'
40
45
 
46
+ if needs_update?( jarfile, classpath )
47
+ f = classpath.file.sub(/#{Dir.pwd}#{File::SEPARATOR}/, '' )
48
+ "the #{f} is stale, i.e. Gemfile or Jarfile is newer. `jbundle update` will update it"
49
+ end
41
50
  else
42
51
 
43
52
  puts '...'
44
53
 
45
- locked = StringIO.new
46
-
47
54
  deps = install_dependencies( debug, verbose )
48
55
 
49
- jars = collect_jars( deps, locked, debug, verbose )
50
-
51
- update_files( classpath, locked, jars ) if needs_update
56
+ update_files( classpath, collect_jars( deps ) ) if needs_update
52
57
 
53
58
  vendor_it( vendor, deps ) if needs_vendor
54
59
 
@@ -57,11 +62,9 @@ module JBundler
57
62
 
58
63
  private
59
64
 
60
- def needs_update?( classpath )
61
- jarfile = Maven::Tools::Jarfile.new( @config.jarfile )
65
+ def needs_update?( jarfile, classpath )
62
66
  gemfile_lock = JBundler::GemfileLock.new( jarfile,
63
67
  @config.gemfile_lock )
64
-
65
68
  classpath.needs_update?( jarfile, gemfile_lock )
66
69
  end
67
70
 
@@ -71,37 +74,32 @@ module JBundler
71
74
  puts
72
75
  end
73
76
 
74
- def collect_jars( deps, locked, debug, verbose )
77
+ def collect_jars( deps )
75
78
  jars = {}
76
79
  deps.each do |d|
77
80
  case d.scope
78
81
  when :provided
79
- ( jars[ :jruby ] ||= [] ) << d.file
82
+ ( jars[ :jruby ] ||= [] ) << d
80
83
  when :test
81
- ( jars[ :test ] ||= [] ) << d.file
84
+ ( jars[ :test ] ||= [] ) << d
82
85
  else
83
- ( jars[ :runtime ] ||= [] ) << d.file
84
- if( ! d.gav.match( /^ruby.bundler:/ ) )
85
- # TODO make Jarfile.lock depend on jruby version as well on
86
- # include test as well, i.e. keep the scope in place
87
- locked.puts d.coord
88
- end
86
+ ( jars[ :runtime ] ||= [] ) << d
89
87
  end
90
88
  end
91
89
  jars
92
90
  end
93
91
 
94
- def update_files( classpath_file, locked, jars )
95
- if locked.string.empty?
92
+ def update_files( classpath_file, jars )
93
+ if jars.values.flatten.size == 0
96
94
  FileUtils.rm_f @config.jarfile_lock
97
95
  else
98
- File.open( @config.jarfile_lock, 'w' ) do |f|
99
- f.print locked.string
100
- end
96
+ lock = Maven::Tools::DSL::JarfileLock.new( @config.jarfile )
97
+ lock.replace( jars )
98
+ lock.dump
101
99
  end
102
- classpath_file.generate( jars[ :runtime ],
103
- jars[ :test ],
104
- jars[ :jruby ],
100
+ classpath_file.generate( (jars[ :runtime ] || []).collect { |j| j.file },
101
+ (jars[ :test ] || []).collect { |j| j.file },
102
+ (jars[ :jruby ] || []).collect { |j| j.file },
105
103
  @config.local_repository )
106
104
  end
107
105
 
@@ -147,6 +145,7 @@ module JBundler
147
145
  done = []
148
146
  index = 0
149
147
  Gem.loaded_specs.each do |name, spec|
148
+ # TODO get rid of this somehow
150
149
  deps = Maven::Tools::GemspecDependencies.new( spec )
151
150
  deps.java_dependency_artifacts.each do |a|
152
151
  unless done.include? a.key
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jbundler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Meier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-04 00:00:00.000000000 Z
11
+ date: 2014-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: maven-tools
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.6
20
+ requirement: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: 1.0.6
25
+ prerelease: false
26
+ type: :runtime
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: ruby-maven
15
29
  version_requirements: !ruby/object:Gem::Requirement
@@ -50,12 +64,12 @@ dependencies:
50
64
  requirements:
51
65
  - - ~>
52
66
  - !ruby/object:Gem::Version
53
- version: 0.1.3
67
+ version: 0.1.7
54
68
  requirement: !ruby/object:Gem::Requirement
55
69
  requirements:
56
70
  - - ~>
57
71
  - !ruby/object:Gem::Version
58
- version: 0.1.3
72
+ version: 0.1.7
59
73
  prerelease: false
60
74
  type: :runtime
61
75
  - !ruby/object:Gem::Dependency
@@ -99,6 +113,7 @@ files:
99
113
  - lib/jbundler.rb
100
114
  - lib/jbundler/aether.rb
101
115
  - lib/jbundler/classpath_file.rb
116
+ - lib/jbundler/jarfile_lock.rb
102
117
  - lib/jbundler/tree.rb
103
118
  - lib/jbundler/gemfile_lock.rb
104
119
  - lib/jbundler/executable_pom.rb