jar-dependencies 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Mavenfile +20 -11
- data/jar-dependencies.gemspec +2 -1
- data/lib/jar_dependencies.rb +55 -20
- data/lib/jars/classpath.rb +17 -15
- data/lib/jars/installer.rb +3 -3
- data/lib/jars/lock.rb +8 -11
- data/lib/jars/maven_exec.rb +14 -12
- data/lib/jars/version.rb +1 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5eec8cd538aef1d82692bc4c955a3c3836530fae
|
4
|
+
data.tar.gz: 0f3c2d90c39f9b162e0cde6e48b2b3a1555ad694
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c306e7d5452f34d951982e0614ea333f7c3c634803371b45051b72095e3a68b456fa4cb4162d3e6df73a30f05e4be2471e7e6dfae927d65d0fe81bdda9ca46f
|
7
|
+
data.tar.gz: 27bfde1dbc03629636af5e140a1deabaa3714370ca7016df96e7df021ba8dbb5740631672df12d80e838aa124758c4acee591eaaee592825ddbd14fd3cc1a204
|
data/Mavenfile
CHANGED
@@ -10,14 +10,19 @@ jruby_plugin( :minitest, :minispecDirectory => "specs/*_spec.rb" ) do
|
|
10
10
|
gem 'ruby-maven', '${ruby-maven.version}'
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
# retrieve the ruby-maven version
|
14
|
+
pro = @model.profiles.detect { |p| p.id.to_sym == :gemfile } || @model
|
15
|
+
ruby_maven = pro.dependencies.detect { |d| d.artifact_id == 'ruby-maven' }
|
16
|
+
|
17
|
+
properties( 'jruby.versions' => ['1.7.12', '${jruby.version}', '9.0.0.0.rc1'
|
14
18
|
].join(','),
|
15
19
|
'jruby.modes' => ['1.9', '2.0', '2.1'].join(','),
|
16
20
|
# just lock the version
|
17
21
|
'bundler.version' => '1.9.2',
|
18
|
-
'ruby-maven.version' =>
|
22
|
+
'ruby-maven.version' => ruby_maven.version,
|
19
23
|
'jruby.version' => '1.7.20',
|
20
|
-
'jruby.plugins.version' => '1.0.9'
|
24
|
+
'jruby.plugins.version' => '1.0.9',
|
25
|
+
'push.skip' => true )
|
21
26
|
|
22
27
|
plugin :invoker, '1.8' do
|
23
28
|
execute_goals( :install, :run,
|
@@ -38,21 +43,25 @@ end
|
|
38
43
|
|
39
44
|
distribution_management do
|
40
45
|
repository :id => :ossrh, :url => 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
plugin :deploy, '2.8.2' do
|
45
|
-
execute_goal :deploy, :phase => :deploy, :id => 'deploy gem to maven central'
|
46
46
|
end
|
47
47
|
|
48
48
|
profile :id => :release do
|
49
|
-
properties 'maven.test.skip' => true, 'invoker.skip' => true
|
50
|
-
|
51
|
-
|
49
|
+
properties 'maven.test.skip' => true, 'invoker.skip' => true, 'push.skip' => false
|
50
|
+
|
51
|
+
distribution_management do
|
52
|
+
repository :id => :ossrh, :url => 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
|
52
53
|
end
|
54
|
+
|
53
55
|
build do
|
54
56
|
default_goal :deploy
|
55
57
|
end
|
58
|
+
|
59
|
+
plugin :gpg, '1.5' do
|
60
|
+
execute_goal :sign, :id => 'sign artifacts', :phase => :verify
|
61
|
+
end
|
62
|
+
plugin :deploy, '2.8.2' do
|
63
|
+
execute_goal :deploy, :phase => :deploy, :id => 'deploy gem to maven central'
|
64
|
+
end
|
56
65
|
end
|
57
66
|
|
58
67
|
# vim: syntax=Ruby
|
data/jar-dependencies.gemspec
CHANGED
@@ -23,7 +23,8 @@ Gem::Specification.new do |s|
|
|
23
23
|
|
24
24
|
s.add_development_dependency 'minitest', '~> 5.3'
|
25
25
|
s.add_development_dependency 'rake', '~> 10.2'
|
26
|
-
s.add_development_dependency 'ruby-maven', '~> 3.
|
26
|
+
s.add_development_dependency 'ruby-maven', '~> 3.3.0'
|
27
|
+
s.add_development_dependency 'ruby-maven-libs', '~> 3.3.0'
|
27
28
|
end
|
28
29
|
|
29
30
|
# vim: syntax=Ruby
|
data/lib/jar_dependencies.rb
CHANGED
@@ -28,7 +28,9 @@ module Jars
|
|
28
28
|
HOME = 'JARS_HOME'.freeze
|
29
29
|
# skip the gem post install hook
|
30
30
|
SKIP = 'JARS_SKIP'.freeze
|
31
|
-
#
|
31
|
+
# do not require any jars if set to false
|
32
|
+
REQUIRE = 'JARS_REQUIRE'.freeze
|
33
|
+
# @private
|
32
34
|
NO_REQUIRE = 'JARS_NO_REQUIRE'.freeze
|
33
35
|
# no more warnings on conflict. this still requires jars but will
|
34
36
|
# not warn. it is needed to load jars from (default) gems which
|
@@ -59,21 +61,34 @@ module Jars
|
|
59
61
|
end
|
60
62
|
|
61
63
|
def to_boolean( key )
|
62
|
-
prop = to_prop( key )
|
63
|
-
|
64
|
+
return nil if ( prop = to_prop( key ) ).nil?
|
65
|
+
prop.empty? || prop.eql?('true')
|
64
66
|
end
|
65
67
|
|
66
68
|
def skip?
|
67
69
|
to_boolean( SKIP )
|
68
70
|
end
|
69
71
|
|
70
|
-
def
|
71
|
-
|
72
|
+
def require?
|
73
|
+
@require = nil unless instance_variable_defined?(:@require)
|
74
|
+
if @require.nil?
|
75
|
+
if ( require = to_boolean( REQUIRE ) ).nil?
|
76
|
+
no_require = to_boolean( NO_REQUIRE )
|
77
|
+
@require = no_require.nil? ? true : ! no_require
|
78
|
+
else
|
79
|
+
@require = require
|
80
|
+
end
|
81
|
+
end
|
82
|
+
@require
|
72
83
|
end
|
84
|
+
attr_writer :require
|
73
85
|
|
74
86
|
def quiet?
|
75
87
|
( @silent ||= false ) || to_boolean( QUIET )
|
76
88
|
end
|
89
|
+
|
90
|
+
# @deprecated
|
91
|
+
def no_require?; ! require? end
|
77
92
|
|
78
93
|
def verbose?
|
79
94
|
to_boolean( VERBOSE )
|
@@ -96,13 +111,20 @@ module Jars
|
|
96
111
|
end
|
97
112
|
|
98
113
|
def freeze_loading
|
99
|
-
|
114
|
+
self.require = false
|
100
115
|
end
|
101
116
|
|
102
117
|
def lock
|
103
118
|
to_prop( LOCK ) || 'Jars.lock'
|
104
119
|
end
|
105
120
|
|
121
|
+
def lock_path( basedir = nil )
|
122
|
+
deps = self.lock
|
123
|
+
return deps if File.exists?( deps )
|
124
|
+
deps = File.join( basedir || '.', self.lock )
|
125
|
+
deps if File.exists?( deps )
|
126
|
+
end
|
127
|
+
|
106
128
|
def local_maven_repo
|
107
129
|
to_prop( LOCAL_MAVEN_REPO ) || home
|
108
130
|
end
|
@@ -119,7 +141,7 @@ module Jars
|
|
119
141
|
if ( @_jars_maven_user_settings_ ||= nil ).nil?
|
120
142
|
if settings = absolute( to_prop( MAVEN_SETTINGS ) )
|
121
143
|
unless File.exists?(settings)
|
122
|
-
warn "configured ENV['#{MAVEN_SETTINGS}'] = '#{settings}' not found"
|
144
|
+
warn "configured ENV['#{MAVEN_SETTINGS}'] = '#{settings}' not found"
|
123
145
|
settings = false
|
124
146
|
end
|
125
147
|
else # use maven default (user) settings
|
@@ -156,12 +178,12 @@ module Jars
|
|
156
178
|
end
|
157
179
|
|
158
180
|
def require_jars_lock!( scope = :runtime )
|
159
|
-
|
160
|
-
# and finds it as gem instead of the LOAD_PATH
|
161
|
-
require 'jars/classpath' unless defined? Jars::Classpath
|
162
|
-
classpath = Jars::Classpath.new
|
163
|
-
if jars_lock = classpath.jars_lock
|
181
|
+
if jars_lock = Jars.lock_path
|
164
182
|
@@jars_lock = jars_lock
|
183
|
+
# funny error during spec where it tries to load it again
|
184
|
+
# and finds it as gem instead of the LOAD_PATH
|
185
|
+
require 'jars/classpath' unless defined? Jars::Classpath
|
186
|
+
classpath = Jars::Classpath.new( nil, jars_lock )
|
165
187
|
classpath.require( scope )
|
166
188
|
no_more_warnings
|
167
189
|
end
|
@@ -175,9 +197,25 @@ module Jars
|
|
175
197
|
end
|
176
198
|
end
|
177
199
|
|
200
|
+
def mark_as_required( group_id, artifact_id, *classifier_version )
|
201
|
+
require_jar_with_block( group_id, artifact_id, *classifier_version ) do
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
178
205
|
def require_jar( group_id, artifact_id, *classifier_version )
|
179
206
|
require_jars_lock
|
207
|
+
require_jar_with_block( group_id, artifact_id, *classifier_version ) do |group_id, artifact_id, version, classifier|
|
208
|
+
do_require( group_id, artifact_id, version, classifier )
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
def warn(msg)
|
213
|
+
Kernel.warn(msg) unless quiet?
|
214
|
+
end
|
215
|
+
|
216
|
+
private
|
180
217
|
|
218
|
+
def require_jar_with_block( group_id, artifact_id, *classifier_version )
|
181
219
|
version = classifier_version[ -1 ]
|
182
220
|
classifier = classifier_version[ -2 ]
|
183
221
|
|
@@ -188,18 +226,15 @@ module Jars
|
|
188
226
|
if @@jars[ coordinate ] == version
|
189
227
|
false
|
190
228
|
else
|
191
|
-
# version of already registered jar
|
192
|
-
@@jars[ coordinate ]
|
229
|
+
@@jars[ coordinate ] # version of already registered jar
|
193
230
|
end
|
194
231
|
else
|
195
|
-
|
232
|
+
yield group_id, artifact_id, version, classifier
|
196
233
|
@@jars[ coordinate ] = version
|
197
234
|
return true
|
198
235
|
end
|
199
236
|
end
|
200
237
|
|
201
|
-
private
|
202
|
-
|
203
238
|
def absolute( file )
|
204
239
|
File.expand_path( file ) if file
|
205
240
|
end
|
@@ -216,7 +251,7 @@ module Jars
|
|
216
251
|
|
217
252
|
def detect_local_repository(settings)
|
218
253
|
return nil unless settings
|
219
|
-
|
254
|
+
|
220
255
|
doc = File.read( settings )
|
221
256
|
# TODO filter out xml comments
|
222
257
|
local_repo = doc.sub( /<\/localRepository>.*/m, '' ).sub( /.*<localRepository>/m, '' )
|
@@ -259,10 +294,10 @@ module Jars
|
|
259
294
|
end
|
260
295
|
|
261
296
|
def require_jar( *args )
|
262
|
-
return
|
297
|
+
return nil unless Jars.require?
|
263
298
|
result = Jars.require_jar( *args )
|
264
299
|
if result.is_a? String
|
265
|
-
warn "jar coordinate #{args[0..-2].join( ':' )} already loaded with version #{result}"
|
300
|
+
Jars.warn "jar coordinate #{args[0..-2].join( ':' )} already loaded with version #{result}"
|
266
301
|
return false
|
267
302
|
end
|
268
303
|
result
|
data/lib/jars/classpath.rb
CHANGED
@@ -6,27 +6,24 @@ module Jars
|
|
6
6
|
|
7
7
|
class Classpath
|
8
8
|
|
9
|
-
def initialize( spec = nil )
|
10
|
-
@
|
9
|
+
def initialize( spec = nil, deps = nil )
|
10
|
+
@spec = spec
|
11
|
+
@deps = deps
|
11
12
|
end
|
12
13
|
|
13
|
-
def
|
14
|
-
|
15
|
-
dir if File.directory?( dir )
|
14
|
+
def mvn
|
15
|
+
@mvn ||= MavenExec.new( @spec )
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
deps = File.join( @mvn.basedir || '.', Jars.lock )
|
22
|
-
deps if File.exists?( deps )
|
18
|
+
def workdir( dirname )
|
19
|
+
dir = File.join( mvn.basedir, dirname )
|
20
|
+
dir if File.directory?( dir )
|
23
21
|
end
|
24
22
|
|
25
23
|
def dependencies_list
|
26
|
-
deps
|
27
|
-
|
28
|
-
@
|
29
|
-
deps
|
24
|
+
if @deps ||= Jars.lock_path( mvn.basedir )
|
25
|
+
mvn.resolve_dependencies( @deps ) if Jars.resolve?
|
26
|
+
@deps
|
30
27
|
else
|
31
28
|
resolve_dependencies
|
32
29
|
end
|
@@ -37,7 +34,7 @@ module Jars
|
|
37
34
|
def resolve_dependencies
|
38
35
|
basedir = workdir( 'pkg' ) || workdir( 'target' ) || workdir( '' )
|
39
36
|
deps = File.join( basedir, DEPENDENCY_LIST )
|
40
|
-
|
37
|
+
mvn.resolve_dependencies_list( deps )
|
41
38
|
deps
|
42
39
|
end
|
43
40
|
private :resolve_dependencies
|
@@ -50,6 +47,11 @@ module Jars
|
|
50
47
|
require_jar( *jar.gacv )
|
51
48
|
end
|
52
49
|
end
|
50
|
+
if scope == nil || scope == :runtime
|
51
|
+
process( :provided ) do |jar|
|
52
|
+
Jars.mark_as_required( *jar.gacv )
|
53
|
+
end
|
54
|
+
end
|
53
55
|
end
|
54
56
|
|
55
57
|
def classpath( scope = nil )
|
data/lib/jars/installer.rb
CHANGED
@@ -151,10 +151,10 @@ module Jars
|
|
151
151
|
# first look if there are any requirements in the spec
|
152
152
|
# and then if gem depends on jar-dependencies for runtime.
|
153
153
|
# only then install the jars declared in the requirements
|
154
|
-
result = spec && ! spec.requirements.empty? &&
|
155
|
-
|
154
|
+
result = ( spec = self.spec ) && ! spec.requirements.empty? &&
|
155
|
+
spec.dependencies.detect { |d| d.name == 'jar-dependencies' && d.type == :runtime } != nil
|
156
156
|
if result && spec.platform.to_s != 'java'
|
157
|
-
warn "\njar dependencies found on non-java platform gem - do not install jars\n"
|
157
|
+
Jars.warn "\njar dependencies found on non-java platform gem - do not install jars\n"
|
158
158
|
false
|
159
159
|
else
|
160
160
|
result
|
data/lib/jars/lock.rb
CHANGED
@@ -8,18 +8,14 @@ module Jars
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def file
|
11
|
-
|
12
|
-
|
13
|
-
path
|
14
|
-
else
|
15
|
-
f
|
16
|
-
end
|
11
|
+
file = self[ -1 ].strip
|
12
|
+
file.empty? ? path : file
|
17
13
|
end
|
18
14
|
|
19
15
|
def group_id
|
20
16
|
self[ 0 ]
|
21
17
|
end
|
22
|
-
|
18
|
+
|
23
19
|
def artifact_id
|
24
20
|
self[ 1 ]
|
25
21
|
end
|
@@ -33,7 +29,7 @@ module Jars
|
|
33
29
|
end
|
34
30
|
|
35
31
|
def gacv
|
36
|
-
classifier ? self[ 0..3 ] : self[ 0..2 ]
|
32
|
+
classifier ? self[ 0..3 ] : self[ 0..2 ]
|
37
33
|
end
|
38
34
|
|
39
35
|
def path
|
@@ -58,15 +54,16 @@ module Jars
|
|
58
54
|
scope ||= :runtime
|
59
55
|
File.read( @file ).each_line do |line|
|
60
56
|
next if not line =~ /:.+:/
|
61
|
-
jar = JarDetails.new( line.strip
|
62
|
-
.sub( /:jar:/, ':' )
|
63
|
-
.sub( /:$/, ': ' ).split( /:/ ) )
|
57
|
+
jar = JarDetails.new( line.strip.sub( /:jar:/, ':' ).sub( /:$/, ': ' ).split( /:/ ) )
|
64
58
|
case scope
|
65
59
|
when :all
|
66
60
|
yield jar
|
67
61
|
when :compile
|
68
62
|
# jar.scope is maven scope
|
69
63
|
yield jar if jar.scope != :test
|
64
|
+
when :provided
|
65
|
+
# jar.scope is maven scope
|
66
|
+
yield jar if jar.scope == :provided
|
70
67
|
when :runtime
|
71
68
|
# jar.scope is maven scope
|
72
69
|
yield jar if jar.scope != :test and jar.scope != :provided
|
data/lib/jars/maven_exec.rb
CHANGED
@@ -78,14 +78,14 @@ module Jars
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def setup_arguments( pom, *goals )
|
81
|
-
args =
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
81
|
+
args = goals.dup
|
82
|
+
args << '-DoutputAbsoluteArtifactFilename=true'
|
83
|
+
args << '-DincludeTypes=jar'
|
84
|
+
args << '-DoutputScope=true'
|
85
|
+
args << '-DuseRepositoryLayout=true'
|
86
|
+
args << "-DoutputDirectory=#{Jars.home}"
|
87
|
+
args << '-f' << "#{File.dirname( __FILE__ )}/#{pom}"
|
88
|
+
args << "-Djars.specfile=#{@specfile}"
|
89
89
|
|
90
90
|
if Jars.debug?
|
91
91
|
args << '-X'
|
@@ -113,8 +113,8 @@ module Jars
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def lazy_load_maven
|
116
|
-
add_gem_to_load_path( 'ruby-maven' )
|
117
116
|
add_gem_to_load_path( 'ruby-maven-libs' )
|
117
|
+
add_gem_to_load_path( 'ruby-maven' )
|
118
118
|
require 'maven/ruby/maven'
|
119
119
|
end
|
120
120
|
|
@@ -130,8 +130,10 @@ module Jars
|
|
130
130
|
# just install gem if needed and add it to the load_path
|
131
131
|
# and leave activated gems as they are
|
132
132
|
unless spec = find_spec_via_rubygems( name )
|
133
|
-
install_gem( name )
|
134
|
-
|
133
|
+
spec = install_gem( name )
|
134
|
+
end
|
135
|
+
unless spec
|
136
|
+
raise "failed to resolve gem '#{name}' if you're using Bundler add it as a dependency"
|
135
137
|
end
|
136
138
|
$LOAD_PATH << File.join( spec.full_gem_path, spec.require_path )
|
137
139
|
end
|
@@ -142,7 +144,7 @@ module Jars
|
|
142
144
|
dep = jars.dependencies.detect { |d| d.name == name }
|
143
145
|
req = dep.nil? ? Gem::Requirement.create( '>0' ) : dep.requirement
|
144
146
|
inst = Gem::DependencyInstaller.new( @options ||= {} )
|
145
|
-
inst.install name, req
|
147
|
+
inst.install( name, req ).first
|
146
148
|
rescue => e
|
147
149
|
warn e.backtrace.join( "\n" ) if Jars.verbose?
|
148
150
|
raise "there was an error installing '#{name}'. please install it manually: #{e.inspect}"
|
data/lib/jars/version.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- christian meier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -44,12 +44,26 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 3.
|
47
|
+
version: 3.3.0
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
requirements:
|
50
50
|
- - ~>
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: 3.
|
52
|
+
version: 3.3.0
|
53
|
+
prerelease: false
|
54
|
+
type: :development
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: ruby-maven-libs
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.3.0
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ~>
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 3.3.0
|
53
67
|
prerelease: false
|
54
68
|
type: :development
|
55
69
|
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 by providing a Jars.lock file.
|