jar-dependencies 0.1.12 → 0.1.13

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: f8046f88d8efe9b20de38785a7f2ba5b9cafc963
4
- data.tar.gz: dcb3af6f3d1763359e5a00386582a37ebd1963c1
3
+ metadata.gz: 67596525df0c9a029290a56e4c2e0fbca74fc298
4
+ data.tar.gz: 44fe4eb030153ed7e44dc790ea65d3bbc59f0633
5
5
  SHA512:
6
- metadata.gz: f2bd6d2d4eb6139407e04d67956643b34d60e9110baa6a769d16d2cfbc7a5e7ad586b0b84fd631cafcf7becd643bff5ee8611e046ee41faf642af732507dfba2
7
- data.tar.gz: 8f52b67493e13f75cfbe93507fcfa3199631883ef05b9971de0b87f9294f0b84126725e4e5aadb709843c013109be78ebf33aa7fe9f22393693a7aa9e305da43
6
+ metadata.gz: f1ecf583501d0d4c8214c8e376100afa426db341dd8f0ea86af1478426321dfb6aaaa7512a3f0dfccc0601ed652d5f3cd2964051986c495576462f316015013d
7
+ data.tar.gz: c0f829b0e0dda85a4f9f8696c4b7d7f9a55323b2fcac1cdf1c6658c0fc424a98b521f628b9e8674edfed19b4d34b5f0d9f7ec45cd9e852fd6b0c6c747ce92980
data/Mavenfile CHANGED
@@ -25,6 +25,7 @@ plugin :invoker, '1.8' do
25
25
  :projectsDirectory => 'integration',
26
26
  :streamLogs => true,
27
27
  :goals => ['install'],
28
+ :postBuildHookScript => 'verify.bsh',
28
29
  :cloneProjectsTo => '${project.build.directory}',
29
30
  :properties => { 'jar-dependencies.version' => '${project.version}',
30
31
  'jruby.version' => '${jruby.version}',
@@ -1,10 +1,11 @@
1
1
  #-*- mode: ruby -*-
2
2
 
3
- require './lib/jars/version'
4
-
5
3
  Gem::Specification.new do |s|
6
4
  s.name = 'jar-dependencies'
7
- s.version = Jars::VERSION
5
+
6
+ path = File.expand_path('lib/jars/version.rb', File.dirname(__FILE__))
7
+ s.version = File.read(path).match( /.*VERSION\s*=\s*['"](.*)['"]/m )[1]
8
+
8
9
  s.author = 'christian meier'
9
10
  s.email = [ 'mkristian@web.de' ]
10
11
  s.summary = 'manage jar dependencies for gems'
@@ -12,15 +13,17 @@ Gem::Specification.new do |s|
12
13
 
13
14
  s.license = 'MIT'
14
15
 
15
- s.files = Dir[ 'lib/**/*rb' ]
16
- s.files += Dir[ '*file' ]
17
- s.files += [ 'Readme.md', 'jar-dependencies.gemspec', 'MIT-LICENSE' ]
16
+ s.files = `git ls-files`.split($/).select do |file|
17
+ file =~ /^lib\// ||
18
+ [ 'Mavenfile', 'Rakefile' ].include?(file) ||
19
+ [ 'Readme.md', 'jar-dependencies.gemspec', 'MIT-LICENSE' ].include?(file)
20
+ end
18
21
 
19
22
  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 by providing a Jars.lock file.'
20
23
 
21
24
  s.add_development_dependency 'minitest', '~> 5.3'
22
25
  s.add_development_dependency 'rake', '~> 10.2'
23
- s.add_development_dependency "ruby-maven", "~> 3.1.1.0.11"
26
+ s.add_development_dependency 'ruby-maven', '~> 3.1.1.0.11'
24
27
  end
25
28
 
26
29
  # vim: syntax=Ruby
@@ -195,7 +195,7 @@ module Jars
195
195
 
196
196
  @@jars ||= {}
197
197
  coordinate = "#{group_id}:#{artifact_id}"
198
- coordinate += ":#{classifier}" if classifier
198
+ coordinate << ":#{classifier}" if classifier
199
199
  if @@jars.key? coordinate
200
200
  if @@jars[ coordinate ] == version
201
201
  false
@@ -240,8 +240,8 @@ module Jars
240
240
  local_repo
241
241
  end
242
242
 
243
- def to_jar( group_id, artifact_id, version, classifier )
244
- file = "#{group_id.gsub( /\./, '/' )}/#{artifact_id}/#{version}/#{artifact_id}-#{version}"
243
+ def to_jar( group_id, artifact_id, version, classifier = nil )
244
+ file = "#{group_id.gsub( '.', '/' )}/#{artifact_id}/#{version}/#{artifact_id}-#{version}"
245
245
  file << "-#{classifier}" if classifier
246
246
  file << '.jar'
247
247
  file
@@ -15,9 +15,9 @@ module Jars
15
15
  end
16
16
 
17
17
  def setup_type( line )
18
- if line.match /:pom:/
18
+ if line.index(':pom:')
19
19
  @type = :pom
20
- elsif line.match /:jar:/
20
+ elsif line.index(':jar:')
21
21
  @type = :jar
22
22
  end
23
23
  end
@@ -39,21 +39,21 @@ module Jars
39
39
  def initialize( line )
40
40
  setup_type( line )
41
41
 
42
- line.sub!( /^\s+/, '' )
43
- @coord = line.sub( /:[^:]+:([A-Z]:\\)?[^:]+$/, '' )
42
+ line.sub!( /^\s+/, empty = '' )
43
+ @coord = line.sub( /:[^:]+:([A-Z]:\\)?[^:]+$/, empty )
44
44
  first, second = @coord.split( /:#{type}:/ )
45
45
  group_id, artifact_id = first.split( /:/ )
46
46
  parts = group_id.split( '.' )
47
47
  parts << artifact_id
48
- parts << second.split( /:/ )[ -1 ]
49
- parts << File.basename( line.sub /.:/, '' )
48
+ parts << second.split( ':' )[ -1 ]
49
+ parts << File.basename( line.sub( /.:/, empty ) )
50
50
  @path = File.join( parts ).strip
51
51
 
52
52
  setup_scope( line )
53
53
 
54
54
  reg = /:jar:|:pom:|:test:|:compile:|:runtime:|:provided:|:system:/
55
- @file = line.slice(@coord.length, line.length).sub(reg, '').strip
56
- @system = nil != (line =~ /:system:/)
55
+ @file = line.slice(@coord.length, line.length).sub(reg, empty).strip
56
+ @system = line.index(':system:') != nil
57
57
  @gav = @coord.sub(reg, ':')
58
58
  end
59
59
 
@@ -103,7 +103,7 @@ module Jars
103
103
  file.puts( "require( '#{dep.file}' )" ) if file
104
104
  elsif dep.scope == :runtime
105
105
  vendor_file( dir, dep ) if vendor
106
- file.puts( "require_jar( '#{dep.gav.gsub( /:/, "', '" )}' )" ) if file
106
+ file.puts( "require_jar( '#{dep.gav.gsub( ':', "', '" )}' )" ) if file
107
107
  end
108
108
  end
109
109
 
@@ -117,6 +117,12 @@ module Jars
117
117
  f.close if f
118
118
  end
119
119
 
120
+ def initialize( spec = nil )
121
+ @mvn = MavenExec.new( spec )
122
+ end
123
+
124
+ def spec; @mvn.spec end
125
+
120
126
  def vendor_jars( write_require_file = true )
121
127
  return unless has_jars?
122
128
  case Jars.to_prop( Jars::VENDOR )
@@ -127,7 +133,7 @@ module Jars
127
133
  else
128
134
  # if the spec_file does not exists this means it is a local gem
129
135
  # coming via bundle :path or :git
130
- do_vendor = File.exists?( @mvn.spec.spec_file )
136
+ do_vendor = File.exists?( spec.spec_file )
131
137
  end
132
138
  do_install( do_vendor, write_require_file )
133
139
  end
@@ -137,26 +143,24 @@ module Jars
137
143
  do_install( false, write_require_file )
138
144
  end
139
145
 
140
- def initialize( spec = nil )
141
- @mvn = MavenExec.new( spec )
142
- end
143
-
144
146
  def ruby_maven_install_options=( options )
145
147
  @mvn.ruby_maven_install_options=( options )
146
148
  end
147
149
 
148
- private
149
-
150
150
  def has_jars?
151
151
  # first look if there are any requirements in the spec
152
152
  # and then if gem depends on jar-dependencies
153
153
  # only then install the jars declared in the requirements
154
- @mvn.spec != nil && ! @mvn.spec.requirements.empty? && @mvn.spec.dependencies.detect { |d| d.name == 'jar-dependencies' && d.type == :runtime }
154
+ spec && ! spec.requirements.empty? &&
155
+ spec.dependencies.detect { |d| d.name == 'jar-dependencies' && d.type == :runtime }
155
156
  end
157
+ alias_method :jars?, :has_jars?
158
+
159
+ private
156
160
 
157
161
  def do_install( vendor, write_require_file )
158
- vendor_dir = File.join( @mvn.basedir, @mvn.spec.require_path )
159
- jars_file = File.join( vendor_dir, "#{@mvn.spec.name}_jars.rb" )
162
+ vendor_dir = File.join( @mvn.basedir, spec.require_path )
163
+ jars_file = File.join( vendor_dir, "#{spec.name}_jars.rb" )
160
164
 
161
165
  # write out new jars_file it write_require_file is true or
162
166
  # check timestamps:
@@ -174,7 +178,7 @@ module Jars
174
178
  def install_dependencies
175
179
  deps = File.join( @mvn.basedir, 'deps.lst' )
176
180
 
177
- puts " jar dependencies for #{@mvn.spec.spec_name} . . ." unless Jars.quiet?
181
+ puts " jar dependencies for #{spec.spec_name} . . ." unless Jars.quiet?
178
182
  @mvn.resolve_dependencies_list( deps )
179
183
 
180
184
  self.class.load_from_maven( deps )
@@ -113,22 +113,39 @@ module Jars
113
113
  end
114
114
 
115
115
  def lazy_load_maven
116
+ add_gem_to_load_path( 'ruby-maven' )
117
+ add_gem_to_load_path( 'ruby-maven-libs' )
116
118
  require 'maven/ruby/maven'
117
- rescue LoadError
118
- install_ruby_maven
119
- require 'maven/ruby/maven'
120
119
  end
121
120
 
122
- def install_ruby_maven
121
+ def find_spec_via_rubygems( name )
122
+ require 'rubygems/dependency'
123
+ dep = Gem::Dependency.new( name )
124
+ dep.matching_specs( true ).last
125
+ end
126
+
127
+ def add_gem_to_load_path( name )
128
+ # if the gem is already activated => good
129
+ return if Gem.loaded_specs[ name ]
130
+ # just install gem if needed and add it to the load_path
131
+ # and leave activated gems as they are
132
+ unless spec = find_spec_via_rubygems( name )
133
+ install_gem( name )
134
+ spec = find_spec_via_rubygems( name )
135
+ end
136
+ $LOAD_PATH << File.join( spec.full_gem_path, spec.require_path )
137
+ end
138
+
139
+ def install_gem( name )
123
140
  require 'rubygems/dependency_installer'
124
141
  jars = Gem.loaded_specs[ 'jar-dependencies' ]
125
- dep = jars.dependencies.detect { |d| d.name == 'ruby-maven' }
142
+ dep = jars.dependencies.detect { |d| d.name == name }
126
143
  req = dep.nil? ? Gem::Requirement.create( '>0' ) : dep.requirement
127
- inst = Gem::DependencyInstaller.new( @options || {} )
128
- inst.install 'ruby-maven', req
144
+ inst = Gem::DependencyInstaller.new( @options ||= {} )
145
+ inst.install name, req
129
146
  rescue => e
130
147
  warn e.backtrace.join( "\n" ) if Jars.verbose?
131
- raise "there was an error installing 'ruby-maven'. please install it manually: #{e.inspect}"
148
+ raise "there was an error installing '#{name}'. please install it manually: #{e.inspect}"
132
149
  end
133
150
  end
134
151
  end
data/lib/jars/setup.rb ADDED
@@ -0,0 +1,7 @@
1
+ # to do as bundler does and allow to load Jars.lock via
2
+ # require 'jars/setup'. can be useful via commandline -rjars/setup
3
+ # or tell bundler autorequire to load it
4
+
5
+ require 'jar_dependencies'
6
+
7
+ Jars.require_jars_lock!
data/lib/jars/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jars
2
- VERSION = '0.1.12'.freeze
2
+ VERSION = '0.1.13'.freeze
3
3
  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.1.12
4
+ version: 0.1.13
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-04-15 00:00:00.000000000 Z
11
+ date: 2015-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -59,25 +59,25 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - lib/rubygems_plugin.rb
62
+ - MIT-LICENSE
63
+ - Mavenfile
64
+ - Rakefile
65
+ - Readme.md
66
+ - jar-dependencies.gemspec
63
67
  - lib/jar-dependencies.rb
64
- - lib/jar_install_post_install_hook.rb
65
68
  - lib/jar_dependencies.rb
69
+ - lib/jar_install_post_install_hook.rb
66
70
  - lib/jar_installer.rb
67
71
  - lib/jars/classpath.rb
68
- - lib/jars/jars_lock_pom.rb
69
- - lib/jars/maven_exec.rb
70
- - lib/jars/version.rb
71
72
  - lib/jars/installer.rb
72
73
  - lib/jars/jar_pom.rb
73
- - lib/jars/post_install_hook.rb
74
+ - lib/jars/jars_lock_pom.rb
74
75
  - lib/jars/lock.rb
75
- - Mavenfile
76
- - Rakefile
77
- - Gemfile
78
- - Readme.md
79
- - jar-dependencies.gemspec
80
- - MIT-LICENSE
76
+ - lib/jars/maven_exec.rb
77
+ - lib/jars/post_install_hook.rb
78
+ - lib/jars/setup.rb
79
+ - lib/jars/version.rb
80
+ - lib/rubygems_plugin.rb
81
81
  homepage: https://github.com/mkristian/jar-dependencies
82
82
  licenses:
83
83
  - MIT
data/Gemfile DELETED
@@ -1,7 +0,0 @@
1
- #-*- mode: ruby -*-
2
- source 'https://rubygems.org'
3
-
4
- gemspec
5
-
6
- gem "copyright-header", "1.0.8", :platform => :mri, :group => :copyright
7
-