jar-dependencies 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f27be364d8c8f32d577aef905556c4cd660fe8e
4
- data.tar.gz: 3e7a4d1af9b4156354f47be93a4b03f7c333a6f2
3
+ metadata.gz: 2bd8d100f1b60a90cfe7a66415f8413dcdf93dfa
4
+ data.tar.gz: 655a3e16c92bc6f43023d139c64935b096b0e18f
5
5
  SHA512:
6
- metadata.gz: 6d1c68ce4acf5dfb0e95c919761ba653cb1bf24088744cba40a3801395b80f9db27091bbe922f4edef80367e8f37252349a276f4883895b4fd9d6d34fe26d074
7
- data.tar.gz: 031880f018fe453260aaa5f8e852c93a512d22adbb613df1e1176368527b58c69db2167c2663c5474b383c124ff43bc3dd612088466e12604b64805351243439
6
+ metadata.gz: a0a071dd5b2d2950b227b19f8a3f66f54e5d51581ba580cbf3b731a47b052f5d3ff40a44a683e3a18bcc4c9867adf452734427acc19bea0986ed0044791be813
7
+ data.tar.gz: dcf7a0895ae39e501d2e6a61bff7f4e6ae5ebd6fa3ece8f0976dc6c3b73f912ef8cea23e86550ad919e5a0a4add03687a9b6aa4b23e641728e996285b0e5d51d
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ #-*- mode: ruby -*-
2
+ source 'https://rubygems.org'
3
+
4
+ gemspec
5
+
6
+ gem "copyright-header", "1.0.8", :platform => :mri, :group => :copyright
7
+
8
+ gem 'rake', '~> 10.0'
9
+ gem 'minitest', '~> 5.3'
10
+
data/Rakefile ADDED
@@ -0,0 +1,33 @@
1
+ #-*- mode: ruby -*-
2
+
3
+ task :default => [ :specs ]
4
+
5
+ desc 'run specs'
6
+ task :specs do
7
+ $LOAD_PATH << "specs"
8
+
9
+ Dir['specs/*_spec.rb'].each do |f|
10
+ require File.basename( f.sub(/.rb$/, '' ) )
11
+ end
12
+ end
13
+
14
+ task :headers do
15
+ require 'copyright_header'
16
+
17
+ s = Gem::Specification.load( Dir["*gemspec"].first )
18
+
19
+ args = {
20
+ :license => s.license,
21
+ :copyright_software => s.name,
22
+ :copyright_software_description => s.description,
23
+ :copyright_holders => s.authors,
24
+ :copyright_years => [Time.now.year],
25
+ :add_path => "lib",
26
+ :output_dir => './'
27
+ }
28
+
29
+ command_line = CopyrightHeader::CommandLine.new( args )
30
+ command_line.execute
31
+ end
32
+
33
+ # vim: syntax=Ruby
data/Readme.md CHANGED
@@ -1,26 +1,53 @@
1
1
  # jar-dependencies #
2
2
 
3
- manage jar dependencies for gems and keep track which jar was already loaded using maven artifact coordinates. it warns on version conflicts and loads only ONE jar assuming the first one is compatible to the second one otherwise your project needs to lock down the right version.
4
-
5
- via environment variable or system properties the jar loading can be switched of completely, allowing the servlet container or jbundler or any other container to take care of the jar loading.
6
-
7
- in case the jars are vendored using the following path convention
8
-
9
- **{group\_id}/{artifact\_id}-{version}.jar**
10
-
11
- it will be loaded in case the local maven repository does not have it (maybe the preference should be the other way around ?).
12
-
13
- the gem is tiny on purpose since the all gems with jar dependencies should use and funny double loaded jars can be avoided in future. also java project using the jruby ScriptingContainer can manage their jar dependencies including those coming from the gem files.
14
-
15
- # create a gem with jar dependencies #
16
-
17
- see add you jar dependency declaration in gemspec via the **requirements**, see [example.gemspec](example/example.gemspec). create an extension **ext/extconf.rb** and use the **setup** from [ruby-maven](http://rubygems.org/gem/ruby-maven) to install the jar dependencies on installation of the gem - see [ext/extconf.rb](example/ext/extconf.rb). this setup will create **{gem.name}\_jars.rb** inside the lib directory (**require_path** of the gemspec) of your gem .
18
-
19
- note: you need ruby-maven-3.1.1.0.3.dev or newer for the GemSetup class
20
-
21
- your gem just need require this **{gem.name}_jars.rb** in your code whenever you want to load these jars (see [lib/example.rb](example/lib/example.rb)).
22
-
23
- the gem itself also needs the **jar-dependencies** gem as runtime-dependency since that is used to load the jar or let [jbundler](http://rubygems.org/gem/jbundler) or similar frameworks deal with the jar dependencies.
3
+ * [![Build Status](https://secure.travis-ci.org/mkristian/jar-dependencies.png)](http://travis-ci.org/mkristian/jar-dependencies)
4
+ * [![Code Climate](https://codeclimate.com/github/mkristian/jar-dependencies.png)](https://codeclimate.com/github/mkristian/jar-dependencies)
5
+
6
+ add gem dependencies for jar files to ruby gems.
7
+
8
+ ## features ##
9
+
10
+ * vendors jar dependencies during installion of the gem
11
+ * jar dependencies are declared in the gemspec of the gem
12
+ * jar declaration uses the same notation as jbundler
13
+ * transitive jar dependencies will be resolved as well using (ruby-)maven
14
+ * when there are two gems with different versions of the same jar dependency an warning will be given and the first version wins, i.e. **only one** version of the a library inside the jruby-classloader
15
+ * it hooks into gem, i.e. once the jar-dependency gem is installed the feature can be used by any gem
16
+ * offer 'bundle-with-jars' command which hooks the jar_installer into rubytems before delegating all arguments to bundler
17
+ * it integrates with an existing maven local repository and obeys the maven setup in ~/.m2/settings.xml, like mirrors, proxieds, etc
18
+
19
+ ## some drawbacks ##
20
+
21
+ * first you need to install the jar-dependency gem with its development dependencies installed (then ruby-maven gets installed as well)
22
+ * bundler does not install the jar-dependencies
23
+ * gems need an extra dependency on jar-dependencies during runtime and for development and installation you need ruby-maven installed as well (which you get via the development dependencies)
24
+
25
+ ## just look at the example ##
26
+
27
+ the [readme.md](example/Readme.md) walks you through an example and shows how development works and shows what happens during installation.
28
+
29
+ # configuration #
30
+
31
+ <table border='1'>
32
+ <tr>
33
+ <td>ENV</td><td>java system property</td><td>default</td><td>description</td>
34
+ </tr>
35
+ <tr>
36
+ <td>`JARS_DEBUG`</td><td>jars.debug</td><td>false</td><td>if set to true it will produce lots of debug out (maven -X switch)</td>
37
+ </tr>
38
+ <tr>
39
+ <td>`JARS_VERBOSE`</td><td>jars.verbose</td><td>false</td><td>if set to true it will produce some extra output</td>
40
+ </tr>
41
+ <tr>
42
+ <td>`JARS_HOME`</td><td>jars.home</td><td>$HOME/.m2/repository</td><td>filesystem location where to store the jar files and some metadata</td>
43
+ </tr>
44
+ <tr>
45
+ <td>`JARS_MAVEN_SETTINGS`</td><td>jars.maven.settings</td><td>$HOME/.m2/settings.xml</td><td>setting.xml for maven to use</td>
46
+ </tr>
47
+ <tr>
48
+ <td>`JARS_VENDOR`</td><td>jars.vendor</td><td>true</td><td>set to true means that the jars will be stored in JARS_HOME only</td>
49
+ </tr>
50
+ </table>
24
51
 
25
52
  # motivation #
26
53
 
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ if defined?( JRUBY_VERSION ) && Gem.post_install_hooks.empty?
4
+ Gem.post_install do |gem_installer|
5
+ require 'jar_installer'
6
+ ::JarInstaller.new( gem_installer.spec ).vendor_jars
7
+ end
8
+ end
9
+
10
+ load Gem.bin_path('bundler', 'bundle')
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'jar-dependencies'
5
- s.version = "0.0.2"
5
+ s.version = "0.0.3"
6
6
  s.author = 'christian meier'
7
7
  s.email = [ 'mkristian@web.de' ]
8
8
  s.summary = 'manage jar dependencies for gems'
@@ -10,13 +10,16 @@ Gem::Specification.new do |s|
10
10
 
11
11
  s.license = 'MIT'
12
12
 
13
+ s.executable = 'bundle-with-jars'
14
+
13
15
  s.files = Dir[ 'lib/*rb' ]
16
+ s.files += Dir[ '*file' ]
14
17
  s.files += [ 'Readme.md', 'jar-dependencies.gemspec', 'MIT-LICENSE' ]
15
18
 
16
19
  s.description = 'manage jar dependencies for gems and keep track which jar was already loaded using maven artifact coordinates. it warns on version conflicts and loads only ONE jar assuming the first one is compatible to the second one otherwise your project needs to lock down the right version.'
17
20
 
18
- s.add_runtime_dependency 'rake', '~> 10.2.2'
19
- s.add_runtime_dependency 'ruby-maven', '~> 3.1.1.0'
21
+ s.add_development_dependency 'rake', '~> 10.2.2'
22
+ s.add_development_dependency 'ruby-maven', '~> 3.1.1.0'
20
23
  end
21
24
 
22
25
  # vim: syntax=Ruby
@@ -19,39 +19,113 @@
19
19
  # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
20
  #
21
21
 
22
- def require_jar( group_id, artifact_id, *classifier_version )
23
- require_jarfile( nil, group_id, artifact_id, *classifier_version )
24
- end
22
+ module Jars
23
+ HOME = 'JARS_HOME'
24
+ MAVEN_SETTINGS = 'JARS_MAVEN_SETTINGS'
25
+
26
+ if defined? JRUBY_VERSION
27
+ def self.to_prop( key )
28
+ java.lang.System.getProperty( key.downcase.gsub( /_/, '.' ) ) ||
29
+ ENV[key.upcase.gsub( /[.]/, '_' ) ]
30
+ end
31
+ else
32
+ def self.to_prop( key )
33
+ ENV[ key.upcase.gsub( /[.]/, '_' ) ]
34
+ end
35
+ end
25
36
 
26
- def require_jarfile( file, group_id, artifact_id, *classifier_version )
27
- skip = java.lang.System.get_property( 'jruby.jars.skip' ) || ENV[ 'JRUBY_JARS_SKIP' ] || java.lang.System.get_property( 'jbundler.skip' ) || ENV[ 'JBUNDLER_SKIP' ]
28
- return false if skip == 'true'
37
+ def self.absolute( file )
38
+ File.expand_path( file ) if file
39
+ end
40
+
41
+ def self.reset
42
+ @_jars_maven_settings_ = nil
43
+ @_jars_home_ = nil
44
+ @@jars ||= {}
45
+ @@jars.clear
46
+ end
29
47
 
30
- version = classifier_version[ -1 ]
31
- classifier = classifier_version[ -2 ]
48
+ def self.maven_settings
49
+ if @_jars_maven_settings_.nil?
50
+ unless @_jars_maven_settings_ = absolute( to_prop( MAVEN_SETTINGS ) )
51
+ # use maven default settings
52
+ @_jars_maven_settings_ = File.join( ENV[ 'HOME' ],
53
+ '.m2', 'settings.xml' )
54
+ end
55
+ end
56
+ @_jars_maven_settings_
57
+ end
32
58
 
33
- # if no file given than it is vendored
34
- # if the file does not exists we assume it is vendored
35
- if file.nil? || !File.exists?( file )
59
+ def self.home
60
+ if @_jars_home_.nil?
61
+ unless @_jars_home_ = absolute( to_prop( HOME ) )
62
+ begin
63
+ require 'rexml/document'
64
+ doc = REXML::Document.new( File.read( maven_settings ) )
65
+ REXML::XPath.first( doc, "//settings/localRepository").tap do |e|
66
+ @_jars_home_ = e.text.sub( /\\/, '/') if e
67
+ end
68
+ rescue
69
+ # ignore
70
+ end
71
+ end
72
+ # use maven default repository
73
+ @_jars_home_ ||= File.join( ENV[ 'HOME' ], '.m2', 'repository' )
74
+ end
75
+ @_jars_home_
76
+ end
77
+
78
+ def self.require_jar( group_id, artifact_id, *classifier_version )
79
+ version = classifier_version[ -1 ]
80
+ classifier = classifier_version[ -2 ]
81
+
82
+ @@jars ||= {}
83
+ coordinate = "#{group_id}:#{artifact_id}"
84
+ coordinate += ":#{classifier}" if classifier
85
+ if @@jars.key? coordinate
86
+ if @@jars[ coordinate ] == version
87
+ false
88
+ else
89
+ # version of already registered jar
90
+ @@jars[ coordinate ]
91
+ end
92
+ else
93
+ do_require( group_id, artifact_id, version, classifier )
94
+ @@jars[ coordinate ] = version
95
+ return true
96
+ end
97
+ end
98
+
99
+ private
100
+
101
+ def self.to_jar( group_id, artifact_id, version, classifier )
36
102
  file = "#{group_id.gsub( /\./, '/' )}/#{artifact_id}/#{version}/#{artifact_id}-#{version}"
37
103
  file += "-#{classifier}" if classifier
38
104
  file += '.jar'
105
+ file
39
106
  end
40
107
 
41
- @@jars ||= {}
42
- coordinate = "#{group_id}:#{artifact_id}"
43
- coordinate += ":#{classifier}" if classifier
44
- if @@jars.key? coordinate
45
- if @@jars[ coordinate ] != version
46
- warn "coordinate #{coordinate} already loaded with version #{@@jars[ coordinate ]}"
108
+ def self.do_require( *args )
109
+ jar = to_jar( *args )
110
+ file = File.join( home, jar )
111
+ # use jar from local repository if exists
112
+ if File.exists?( file )
113
+ require file
114
+ else
115
+ # otherwise try to find it on the load path
116
+ require jar
47
117
  end
48
- false
49
- else
50
- require file
51
- @@jars[ coordinate ] = version
52
- true
53
118
  end
119
+ end
120
+
121
+ def require_jar( *args )
122
+ result = Jars.require_jar( *args )
123
+ if result.is_a? String
124
+ warn "jar coordinate #{args[0..-2].join( ':' )} already loaded with version #{result}"
125
+ return false
126
+ end
127
+ result
54
128
  rescue LoadError => e
55
- warn 'you might need to reinstall the gem which depends on the missing jar'
129
+ warn 'you might need to reinstall the gem which depends on the missing jar.'
56
130
  raise e
57
131
  end
data/lib/jar_installer.rb CHANGED
@@ -1,153 +1,206 @@
1
- class JarInstaller
1
+ require 'jar_dependencies'
2
+ module Jars
3
+ class JarInstaller
2
4
 
3
- class Dependency
4
-
5
- attr_reader :path, :file, :gav, :scope, :type, :coord
5
+ class Dependency
6
+
7
+ attr_reader :path, :file, :gav, :scope, :type, :coord
8
+
9
+ def self.new( line )
10
+ if line.match /:jar:|:pom:/
11
+ super
12
+ end
13
+ end
6
14
 
7
- def self.new( line )
8
- if line.match /:jar:|:pom:/
9
- super
15
+ def setup_type( line )
16
+ if line.match /:pom:/
17
+ @type = :pom
18
+ elsif line.match /: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
10
34
  end
35
+ private :setup_scope
36
+
37
+ def initialize( line )
38
+ setup_type( line )
39
+
40
+ line.sub!( /^\s+/, '' )
41
+ @coord = line.sub( /:[^:]+:[^:]+$/, '' )
42
+ first, second = line.sub( /:[^:]+:[^:]+$/, '' ).split( /:#{type}:/ )
43
+ group_id, artifact_id = first.split( /:/ )
44
+ parts = group_id.split( '.' )
45
+ parts << artifact_id
46
+ parts << second.split( /:/ )[ -1 ]
47
+ parts << File.basename( line.sub /.:/, '' )
48
+ @path = File.join( parts ).strip
49
+
50
+ setup_scope( line )
51
+
52
+ line.gsub!( /:jar:|:pom:|:test:|:compile:|:runtime:|:provided:/, ':' )
53
+ @file = line.sub( /^.*:/, '' ).strip
54
+ @gav = line.sub( /:[^:]+$/, '' )
55
+ end
56
+ end
57
+
58
+ def self.install_jars
59
+ new.install_jars
11
60
  end
12
61
 
13
- def initialize( line )
14
- if line.match /:pom:/
15
- @type = :pom
16
- elsif line.match /:jar:/
17
- @type = :jar
62
+ def self.load_from_maven( file )
63
+ result = []
64
+ File.read( file ).each_line do |line|
65
+ dep = Dependency.new( line )
66
+ result << dep if dep
18
67
  end
19
- line.sub!( /^\s+/, '' )
20
- @coord = line.sub( /:[^:]+:[^:]+$/, '' )
21
- first, second = line.sub( /:[^:]+:[^:]+$/, '' ).split( /:#{type}:/ )
22
- group_id, artifact_id = first.split( /:/ )
23
- parts = group_id.split( '.' )
24
- parts << artifact_id
25
- parts << second.split( /:/ )[ -1 ]
26
- parts << File.basename( line.sub /.:/, '' )
27
- @path = File.join( parts ).strip
28
-
29
- @scope =
30
- case line
31
- when /:provided:/
32
- :provided
33
- when /:test:/
34
- :test
35
- else
36
- :runtime
37
- end
38
- line.gsub!( /:jar:|:pom:|:test:|:compile:|:runtime:|:provided:/, ':' )
39
- @file = line.sub( /^.*:/, '' ).strip
40
- @gav = line.sub( /:[^:]+$/, '' )
68
+ result
41
69
  end
42
- end
43
70
 
44
- def self.install_jars
45
- new.install_jars
46
- end
71
+ def self.write_require_file( require_filename )
72
+ FileUtils.mkdir_p( File.dirname( require_filename ) )
73
+ comment = '# this is a generated file, to avoid over-writing it just delete this comment'
74
+ if ! File.exists?( require_filename ) || File.read( require_filename ).match( comment )
75
+ f = File.open( require_filename, 'w' )
76
+ f.puts comment
77
+ f.puts "require 'jar_dependencies'"
78
+ f.puts
79
+ f
80
+ end
81
+ end
47
82
 
48
- def self.load_from_maven( file )
49
- result = []
50
- File.read( file ).each_line do |line|
51
- dep = Dependency.new( line )
52
- result << dep if dep
83
+ def self.vendor_file( dir, dep )
84
+ vendored = File.join( dir, dep.path )
85
+ FileUtils.mkdir_p( File.dirname( vendored ) )
86
+ FileUtils.cp( dep.file, vendored )
53
87
  end
54
- result
55
- end
56
88
 
57
- def self.install_deps( deps, dir, require_filename, vendor )
58
- FileUtils.mkdir_p( File.dirname( require_filename ) )
59
- File.open( require_filename, 'w' ) do |f|
60
- f.puts "require 'jar_dependencies'"
61
- f.puts
89
+ def self.install_deps( deps, dir, require_filename, vendor )
90
+ f = write_require_file( require_filename ) if require_filename
62
91
  deps.each do |dep|
63
92
  next if dep.type != :jar || dep.scope != :runtime
64
93
  args = dep.gav.gsub( /:/, "', '" )
65
- if vendor
66
- vendored = File.join( dir, dep.path )
67
- FileUtils.mkdir_p( File.dirname( vendored ) )
68
- FileUtils.cp( dep.file, vendored )
69
- f.puts( "require_jar( '#{args}' )" )
70
- else
71
- f.puts( "require_jarfile( '#{dep.file}', '#{args}' )" )
72
- end
94
+ vendor_file( dir, dep ) if vendor
95
+ f.puts( "require_jar( '#{args}' )" ) if f
73
96
  end
97
+ ensure
98
+ f.close if f
74
99
  end
75
- end
76
100
 
77
- def initialize( spec = nil )
78
- if spec.nil?
101
+ def find_spec
79
102
  specs = Dir[ '*.gemspec' ]
80
103
  case specs.size
81
104
  when 0
82
105
  raise 'no gemspec found'
83
106
  when 1
84
- spec = specs.first
107
+ specs.first
85
108
  else
86
109
  raise 'more then one gemspec found. please specify a specfile'
87
110
  end
88
111
  end
89
- if spec.is_a? String
90
- @basedir = File.dirname( File.expand_path( spec ) )
91
- @specfile = spec
92
- spec = eval( File.read( spec ) )
93
- else
94
- @basedir = spec.gem_dir
95
- @specfile = spec.spec_file
112
+ private :find_spec
113
+
114
+ def initialize( spec = nil )
115
+ spec ||= find_spec
116
+
117
+ case spec
118
+ when String
119
+ @basedir = File.dirname( File.expand_path( spec ) )
120
+ @specfile = spec
121
+ spec = eval( File.read( spec ) )
122
+ else
123
+ @basedir = spec.gem_dir
124
+ @specfile = spec.spec_file
125
+ end
126
+
127
+ @spec = spec
96
128
  end
97
- @spec = spec
98
- end
99
129
 
100
- def vendor_jars
101
- return if @spec.requirements.empty?
102
- really_vendor = java.lang.System.get_property( 'jruby.jars.vendor' ) || ENV[ 'JRUBY_JARS_VENDOR' ] || 'true'
103
- do_install( really_vendor == 'true' )
104
- end
130
+ def vendor_jars
131
+ return if @spec.requirements.empty?
132
+ really_vendor = Jars.to_prop( "JARS_VENDOR" ) || 'true'
133
+ do_install( really_vendor == 'true', false )
134
+ end
105
135
 
106
- def install_jars
107
- return if @spec.requirements.empty?
108
- do_install( false )
109
- end
136
+ def install_jars
137
+ return if @spec.requirements.empty?
138
+ do_install( false, true )
139
+ end
110
140
 
111
- private
141
+ private
112
142
 
113
- def do_install( vendor )
114
- vendor_dir = File.join( @basedir, @spec.require_path )
115
- jars_file = File.join( vendor_dir, "#{@spec.name}_jars.rb" )
143
+ def do_install( vendor, write_require_file )
144
+ vendor_dir = File.join( @basedir, @spec.require_path )
145
+ if write_require_file
146
+ jars_file = File.join( vendor_dir, "#{@spec.name}_jars.rb" )
116
147
 
117
- return if File.exists?( jars_file ) &&
118
- File.mtime( @specfile ) < File.mtime( jars_file )
148
+ # do not generate file if specfile is older then the generated file
149
+ if File.exists?( jars_file ) &&
150
+ File.mtime( @specfile ) < File.mtime( jars_file )
151
+ jars_file = nil
152
+ end
153
+ end
154
+ self.class.install_deps( install_dependencies, vendor_dir,
155
+ jars_file, vendor )
156
+ end
119
157
 
120
- self.class.install_deps( install_dependencies, vendor_dir,
121
- jars_file, vendor )
122
- end
158
+ def setup_arguments( deps )
159
+ args = [ 'dependency:list', "-DoutputFile=#{deps}", '-DincludeScope=runtime', '-DoutputAbsoluteArtifactFilename=true', '-DincludeTypes=jar', '-DoutputScope=true', '-f', @specfile ]
160
+
161
+ verbose = Jars.to_prop( 'JARS_VERBOSE' ) == 'true'
162
+ debug = Jars.to_prop( 'JARS_DEBUG' ) == 'true'
123
163
 
124
- def install_dependencies
125
- deps = File.join( @basedir, 'deps.lst' )
164
+ if debug
165
+ args << '-X'
166
+ elsif ! verbose
167
+ args << '--quiet'
168
+ end
126
169
 
127
- # lazy load ruby-maven
128
- begin
170
+ args << "-Dmaven.repo.local=#{java.io.File.new( Jars.home ).absolute_path}"
171
+ args
172
+ end
129
173
 
174
+ def lazy_load_maven
130
175
  require 'maven/ruby/maven'
131
-
132
176
  rescue LoadError
133
- raise 'please install ruby-maven gem so the jar dependencies can be installed'
177
+ raise "please install ruby-maven gem which is needed to install the jar dependencies\n\n\tgem install ruby-maven\n\n"
134
178
  end
135
-
136
- # monkey patch to NOT include gem dependencies
137
- require 'maven/tools/gemspec_dependencies'
138
- eval <<EOF
179
+
180
+ def monkey_path_gem_dependencies
181
+ # monkey patch to NOT include gem dependencies
182
+ require 'maven/tools/gemspec_dependencies'
183
+ eval <<EOF
139
184
  class ::Maven::Tools::GemspecDependencies
140
185
  def runtime; []; end
141
186
  def development; []; end
142
187
  end
143
188
  EOF
189
+ end
144
190
 
145
- maven = Maven::Ruby::Maven.new
146
- maven.exec 'dependency:list', "-DoutputFile=#{deps}", '-DincludeScope=runtime', '-DoutputAbsoluteArtifactFilename=true', '-DincludeTypes=jar', '-DoutputScope=true', '-f', @specfile, '--quiet'
191
+ def install_dependencies
192
+ lazy_load_maven
193
+
194
+ monkey_path_gem_dependencies
195
+
196
+ deps = File.join( @basedir, 'deps.lst' )
197
+
198
+ maven = Maven::Ruby::Maven.new
199
+ maven.exec( *setup_arguments( deps ) )
147
200
 
148
- self.class.load_from_maven( deps )
149
- ensure
150
- FileUtils.rm_f( deps ) if deps
201
+ self.class.load_from_maven( deps )
202
+ ensure
203
+ FileUtils.rm_f( deps ) if deps
204
+ end
151
205
  end
152
206
  end
153
-
@@ -22,6 +22,6 @@
22
22
  if defined?( JRUBY_VERSION ) && Gem.post_install_hooks.empty?
23
23
  Gem.post_install do |gem_installer|
24
24
  require 'jar_installer'
25
- ::JarInstaller.new( gem_installer.spec ).vendor_jars
25
+ Jars::JarInstaller.new( gem_installer.spec ).vendor_jars
26
26
  end
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jar-dependencies
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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-04-10 00:00:00.000000000 Z
11
+ date: 2014-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -23,7 +23,7 @@ dependencies:
23
23
  - !ruby/object:Gem::Version
24
24
  version: 10.2.2
25
25
  prerelease: false
26
- type: :runtime
26
+ type: :development
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ruby-maven
29
29
  version_requirements: !ruby/object:Gem::Requirement
@@ -37,11 +37,12 @@ dependencies:
37
37
  - !ruby/object:Gem::Version
38
38
  version: 3.1.1.0
39
39
  prerelease: false
40
- type: :runtime
40
+ type: :development
41
41
  description: manage jar dependencies for gems and keep track which jar was already loaded using maven artifact coordinates. it warns on version conflicts and loads only ONE jar assuming the first one is compatible to the second one otherwise your project needs to lock down the right version.
42
42
  email:
43
43
  - mkristian@web.de
44
- executables: []
44
+ executables:
45
+ - bundle-with-jars
45
46
  extensions: []
46
47
  extra_rdoc_files: []
47
48
  files:
@@ -49,6 +50,9 @@ files:
49
50
  - lib/jar_installer.rb
50
51
  - lib/jar-dependencies.rb
51
52
  - lib/rubygems_plugin.rb
53
+ - bin/bundle-with-jars
54
+ - Rakefile
55
+ - Gemfile
52
56
  - Readme.md
53
57
  - jar-dependencies.gemspec
54
58
  - MIT-LICENSE