jar-dependencies 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -3
- data/Mavenfile +19 -0
- data/jar-dependencies.gemspec +3 -2
- data/lib/jar_dependencies.rb +35 -3
- data/lib/jar_installer.rb +45 -14
- data/lib/rubygems_plugin.rb +3 -1
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa36ecd310e85a018381f6f1a619c697873b7f1f
|
4
|
+
data.tar.gz: 0db8878e2c8825d1e037ac99aa07b5d7b1f065f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a2452584a7508da029a4d4c6c8bf3913e792869e3b20c03950a05975cf4f14e45d395787b22d5a082b36f2a151be129af22582cd45b9d31d42ef8d9df027336
|
7
|
+
data.tar.gz: 625eb01f0d0aaed9d4d017f1dbb11167ab087e2230b4553c337737710592f434ad581aae72f12c17316047164fa83102d8059114825217bb44fba306dfa73d69
|
data/Gemfile
CHANGED
data/Mavenfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#-*- mode: ruby -*-
|
2
|
+
|
3
|
+
gemfile
|
4
|
+
|
5
|
+
jruby_plugin( :minitest, :minispecDirectory => "specs/*_spec.rb" ) do
|
6
|
+
execute_goals(:spec)
|
7
|
+
end
|
8
|
+
|
9
|
+
snapshot_repository :jruby, 'http://ci.jruby.org/snapshots/maven'
|
10
|
+
|
11
|
+
# (jruby-1.6.8 produces a lot of yaml errors parsing gemspecs)
|
12
|
+
properties( 'jruby.versions' => ['1.6.8', '1.7.13','9000.dev-SNAPSHOT'].join(','),
|
13
|
+
'jruby.modes' => ['1.9', '2.0','2.1'].join(','),
|
14
|
+
# just lock the version
|
15
|
+
'jruby.version' => '1.7.13',
|
16
|
+
'tesla.dump.pom' => 'pom.xml',
|
17
|
+
'tesla.dump.readonly' => true )
|
18
|
+
|
19
|
+
# vim: syntax=Ruby
|
data/jar-dependencies.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'jar-dependencies'
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.4"
|
6
6
|
s.author = 'christian meier'
|
7
7
|
s.email = [ 'mkristian@web.de' ]
|
8
8
|
s.summary = 'manage jar dependencies for gems'
|
@@ -18,7 +18,8 @@ Gem::Specification.new do |s|
|
|
18
18
|
|
19
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.'
|
20
20
|
|
21
|
-
s.add_development_dependency '
|
21
|
+
s.add_development_dependency 'minitest', '~> 5.3'
|
22
|
+
s.add_development_dependency 'rake', '~> 10.2'
|
22
23
|
s.add_development_dependency 'ruby-maven', '~> 3.1.1.0'
|
23
24
|
end
|
24
25
|
|
data/lib/jar_dependencies.rb
CHANGED
@@ -22,6 +22,10 @@
|
|
22
22
|
module Jars
|
23
23
|
HOME = 'JARS_HOME'
|
24
24
|
MAVEN_SETTINGS = 'JARS_MAVEN_SETTINGS'
|
25
|
+
SKIP = 'JARS_SKIP'
|
26
|
+
VERBOSE = 'JARS_VERBOSE'
|
27
|
+
DEBUG = 'JARS_DEBUG'
|
28
|
+
VENDOR = 'JARS_VENDOR'
|
25
29
|
|
26
30
|
if defined? JRUBY_VERSION
|
27
31
|
def self.to_prop( key )
|
@@ -34,6 +38,30 @@ module Jars
|
|
34
38
|
end
|
35
39
|
end
|
36
40
|
|
41
|
+
def self.to_boolean( key )
|
42
|
+
prop = to_prop( key )
|
43
|
+
# prop == nil => false
|
44
|
+
# prop == 'false' => false
|
45
|
+
# anything else => true
|
46
|
+
prop == '' or prop == 'true'
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.skip?
|
50
|
+
to_boolean( SKIP )
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.verbose?
|
54
|
+
to_boolean( VERBOSE )
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.debug?
|
58
|
+
to_boolean( DEBUG )
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.vendor?
|
62
|
+
to_boolean( VENDOR )
|
63
|
+
end
|
64
|
+
|
37
65
|
def self.absolute( file )
|
38
66
|
File.expand_path( file ) if file
|
39
67
|
end
|
@@ -115,17 +143,21 @@ module Jars
|
|
115
143
|
# otherwise try to find it on the load path
|
116
144
|
require jar
|
117
145
|
end
|
146
|
+
rescue LoadError => e
|
147
|
+
raise "\n\n\tyou might need to reinstall the gem which depends on the missing jar\n\n" + e.message + " (LoadError)"
|
148
|
+
end
|
149
|
+
|
150
|
+
def self.freeze_loading
|
151
|
+
ENV[ SKIP ] = 'true'
|
118
152
|
end
|
119
153
|
end
|
120
154
|
|
121
155
|
def require_jar( *args )
|
156
|
+
return false if Jars.skip?
|
122
157
|
result = Jars.require_jar( *args )
|
123
158
|
if result.is_a? String
|
124
159
|
warn "jar coordinate #{args[0..-2].join( ':' )} already loaded with version #{result}"
|
125
160
|
return false
|
126
161
|
end
|
127
162
|
result
|
128
|
-
rescue LoadError => e
|
129
|
-
warn 'you might need to reinstall the gem which depends on the missing jar.'
|
130
|
-
raise e
|
131
163
|
end
|
data/lib/jar_installer.rb
CHANGED
@@ -94,6 +94,7 @@ module Jars
|
|
94
94
|
vendor_file( dir, dep ) if vendor
|
95
95
|
f.puts( "require_jar( '#{args}' )" ) if f
|
96
96
|
end
|
97
|
+
yield f if block_given?
|
97
98
|
ensure
|
98
99
|
f.close if f
|
99
100
|
end
|
@@ -119,27 +120,42 @@ module Jars
|
|
119
120
|
@basedir = File.dirname( File.expand_path( spec ) )
|
120
121
|
@specfile = spec
|
121
122
|
spec = eval( File.read( spec ) )
|
122
|
-
|
123
|
-
|
124
|
-
|
123
|
+
when
|
124
|
+
if File.exists?( spec.spec_file )
|
125
|
+
@basedir = spec.gem_dir
|
126
|
+
@specfile = spec.spec_file
|
127
|
+
else
|
128
|
+
initialize( nil )
|
129
|
+
end
|
125
130
|
end
|
126
131
|
|
127
132
|
@spec = spec
|
128
133
|
end
|
129
134
|
|
135
|
+
def ruby_maven_install_options=( options )
|
136
|
+
@options = options
|
137
|
+
end
|
138
|
+
|
130
139
|
def vendor_jars
|
131
|
-
return
|
132
|
-
|
133
|
-
do_install(
|
140
|
+
return unless has_jars?
|
141
|
+
# do not vendor only if set explicitly via ENV/system-properties
|
142
|
+
do_install( Jars.to_prop( Jars::VENDOR ) != 'false', false )
|
134
143
|
end
|
135
144
|
|
136
145
|
def install_jars
|
137
|
-
return
|
146
|
+
return unless has_jars?
|
138
147
|
do_install( false, true )
|
139
148
|
end
|
140
149
|
|
141
150
|
private
|
142
151
|
|
152
|
+
def has_jars?
|
153
|
+
# first look if there are any requirements in the spec
|
154
|
+
# and then if gem depends on jar-dependencies
|
155
|
+
# only then install the jars declared in the requirements
|
156
|
+
! @spec.requirements.empty? && @spec.dependencies.detect { |d| d.name == 'jar-dependencies' }
|
157
|
+
end
|
158
|
+
|
143
159
|
def do_install( vendor, write_require_file )
|
144
160
|
vendor_dir = File.join( @basedir, @spec.require_path )
|
145
161
|
if write_require_file
|
@@ -158,23 +174,38 @@ module Jars
|
|
158
174
|
def setup_arguments( deps )
|
159
175
|
args = [ 'dependency:list', "-DoutputFile=#{deps}", '-DincludeScope=runtime', '-DoutputAbsoluteArtifactFilename=true', '-DincludeTypes=jar', '-DoutputScope=true', '-f', @specfile ]
|
160
176
|
|
161
|
-
|
162
|
-
debug = Jars.to_prop( 'JARS_DEBUG' ) == 'true'
|
163
|
-
|
164
|
-
if debug
|
177
|
+
if Jars.debug?
|
165
178
|
args << '-X'
|
166
|
-
elsif
|
179
|
+
elsif not Jars.verbose?
|
167
180
|
args << '--quiet'
|
168
181
|
end
|
169
182
|
|
170
|
-
|
183
|
+
if defined? JRUBY_VERSION
|
184
|
+
args << "-Dmaven.repo.local=#{java.io.File.new( Jars.home ).absolute_path}"
|
185
|
+
else
|
186
|
+
args << "-Dmaven.repo.local=#{File.expand_path( Jars.home )}"
|
187
|
+
end
|
188
|
+
|
171
189
|
args
|
172
190
|
end
|
173
191
|
|
174
192
|
def lazy_load_maven
|
175
193
|
require 'maven/ruby/maven'
|
176
194
|
rescue LoadError
|
177
|
-
|
195
|
+
install_ruby_maven
|
196
|
+
require 'maven/ruby/maven'
|
197
|
+
end
|
198
|
+
|
199
|
+
def install_ruby_maven
|
200
|
+
require 'rubygems/dependency_installer'
|
201
|
+
jars = Gem.loaded_specs[ 'jar-dependencies' ]
|
202
|
+
dep = jars.dependencies.detect { |d| d.name == 'ruby-maven' }
|
203
|
+
req = dep ? Gem::Requirement.create( '>0' ) : dep.requirement
|
204
|
+
inst = Gem::DependencyInstaller.new( @options || {} )
|
205
|
+
inst.install 'ruby-maven', req
|
206
|
+
rescue => e
|
207
|
+
warn e.backtrace.join( "\n" ) if Jars.verbose?
|
208
|
+
raise "there was an error installing 'ruby-maven'. please install it manually: " + e.message
|
178
209
|
end
|
179
210
|
|
180
211
|
def monkey_path_gem_dependencies
|
data/lib/rubygems_plugin.rb
CHANGED
@@ -22,6 +22,8 @@
|
|
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
|
-
Jars::JarInstaller.new( gem_installer.spec )
|
25
|
+
jars = Jars::JarInstaller.new( gem_installer.spec )
|
26
|
+
jars.ruby_maven_install_options = gem_installer.options
|
27
|
+
jars.vendor_jars
|
26
28
|
end
|
27
29
|
end
|
metadata
CHANGED
@@ -1,27 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jar-dependencies
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
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-
|
11
|
+
date: 2014-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: minitest
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.3'
|
20
|
+
requirement: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ~>
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '5.3'
|
25
|
+
prerelease: false
|
26
|
+
type: :development
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rake
|
15
29
|
version_requirements: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - ~>
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version: 10.2
|
33
|
+
version: '10.2'
|
20
34
|
requirement: !ruby/object:Gem::Requirement
|
21
35
|
requirements:
|
22
36
|
- - ~>
|
23
37
|
- !ruby/object:Gem::Version
|
24
|
-
version: 10.2
|
38
|
+
version: '10.2'
|
25
39
|
prerelease: false
|
26
40
|
type: :development
|
27
41
|
- !ruby/object:Gem::Dependency
|
@@ -52,6 +66,7 @@ files:
|
|
52
66
|
- lib/rubygems_plugin.rb
|
53
67
|
- bin/bundle-with-jars
|
54
68
|
- Rakefile
|
69
|
+
- Mavenfile
|
55
70
|
- Gemfile
|
56
71
|
- Readme.md
|
57
72
|
- jar-dependencies.gemspec
|