naether 0.13.8 → 0.14.0

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: a7c037cdec7803dbf78021ed5bf38f64bd829748
4
- data.tar.gz: d2de25e2ea21a13253d444eb2389be2c8ccf3be0
3
+ metadata.gz: d2ad6d62db5306141a5d0f1e4dd48ed98baaefa6
4
+ data.tar.gz: c27debdda22817dc0120390b06dbd96bb795ef18
5
5
  SHA512:
6
- metadata.gz: 715eccbb21bec67e8d51b68ced6ea8e15898c4e097fef3a3b2ea5a09ef068c41f69147950c34d38af3b5b87f5c66adf4ba674a1947d3c1274c0eccf68a795da7
7
- data.tar.gz: 173f0d347e7758bcb98a4dd9a12cb94726c52794f80173e0a19ff857a480120ce80ed2da968b35bcc2bd393aabc893b28183d3aa5c2dcf10c7c8e42f1853f5c5
6
+ metadata.gz: 8703cd80aace1d1bf7aece60e0e320095549388c4da134845f6bad7eb871ac5e92ad4074f4ba637b1e139eb0dba3bc74e7d9c59d24fb2e5a6f51e8f309f8df03
7
+ data.tar.gz: bd1a090d6860b1dbf2af7f67c48e72d5f427dfb12a3e3257f7f4bcbfbdfa6b43d5f021257e353d0b094ebed4d65fa4317aa823383f2dea01c1792257c1dc6d73
data/Gemfile CHANGED
@@ -1,5 +1,7 @@
1
1
  source "http://rubygems.org"
2
2
 
3
+ gem 'httpclient'
4
+
3
5
  platform = $platform || RUBY_PLATFORM[/java/] || 'ruby'
4
6
  if platform != 'java'
5
7
  gem 'rjb', '~> 1.4.0'
@@ -19,6 +19,7 @@ GEM
19
19
  oauth2
20
20
  hashie (3.3.2)
21
21
  highline (1.6.21)
22
+ httpclient (2.6.0.1)
22
23
  jeweler (2.0.1)
23
24
  builder
24
25
  bundler (>= 1.0)
@@ -67,6 +68,7 @@ PLATFORMS
67
68
  ruby
68
69
 
69
70
  DEPENDENCIES
71
+ httpclient
70
72
  jeweler (~> 2.0.0)
71
73
  kramdown
72
74
  rjb (~> 1.4.0)
data/README.md CHANGED
@@ -18,6 +18,12 @@ JRuby is natively supported. Vanilla Ruby uses [Rjb](http://rjb.rubyforge.org) t
18
18
  gem install naether
19
19
 
20
20
  The jar dependencies for Naether will automatically be downloaded when the gem installs.
21
+
22
+ #### Custom Maven Repo
23
+
24
+ You can override the default Maven Repo used to download jar dependencies by setting the _NAETHER_MIRROR_ environment variable.
25
+
26
+ NAETHER_MIRROR=http://my.local.repo/m2 gem install naether
21
27
 
22
28
  ### Java
23
29
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.13.8
1
+ 0.14.0
@@ -4,27 +4,35 @@ require "#{File.dirname(__FILE__)}/configuration"
4
4
  require 'yaml'
5
5
  require 'open-uri'
6
6
  require 'fileutils'
7
+ require 'httpclient'
7
8
 
8
9
  module Naether
9
-
10
+
10
11
  #
11
12
  # Helper for bootstrapping Naether
12
13
  #
13
14
  # @author Michael Guymon
14
15
  #
15
16
  class Bootstrap
16
-
17
+
17
18
  @@dependencies = nil
18
-
19
+
19
20
  class << self
20
-
21
+
21
22
  # Default local repo of ENV['M2_REPO'] or ~/.m2/repository
22
23
  #
23
24
  # @return [String]
24
25
  def default_local_repo
25
26
  ENV['M2_REPO'] || File.expand_path('~/.m2/repository')
26
27
  end
27
-
28
+
29
+ # Maven URL to fetch jars from, ENV['NAETHER_MIRROR'] or
30
+ #
31
+ # @return [String]
32
+ def maven_url
33
+ ENV['NAETHER_MIRROR'] || 'http://repo1.maven.org/maven2'
34
+ end
35
+
28
36
  # Write bootstrap dependencies to yaml file
29
37
  def write_dependencies( dest = 'jar_dependencies.yml' )
30
38
  deps = {};
@@ -33,32 +41,32 @@ module Naether
33
41
  else
34
42
  bootstrap = Rjb::import('com.tobedevoured.naether.Bootstrap')
35
43
  deps[:dependencies] = bootstrap.dependencies.toArray().map{ |dep| dep.toString() }
36
- end
37
-
44
+ end
45
+
38
46
  File.open( dest, 'w' ) do |out|
39
47
  YAML.dump( deps, out )
40
48
  end
41
49
  end
42
-
50
+
43
51
  # List of Java dependencies for Naether from yaml dependency file. Caches
44
52
  # result after first run.
45
- #
53
+ #
46
54
  # @param [String] dep_file path, defaults to Naether::Configuration.dependencies_yml
47
55
  # @return [List]
48
56
  def dependencies( dep_file=nil )
49
-
57
+
50
58
  if @@dependencies
51
59
  return @@dependencies
52
60
  end
53
-
61
+
54
62
  if dep_file.nil?
55
63
  dep_file = Naether::Configuration.dependencies_yml
56
64
  end
57
-
58
- dep = YAML.load_file( dep_file )
65
+
66
+ dep = YAML.load_file( dep_file )
59
67
  @@dependencies = dep[:dependencies]
60
68
  end
61
-
69
+
62
70
 
63
71
  #
64
72
  # Bootstrap the local repo by downloading Naether's dependencies
@@ -67,26 +75,22 @@ module Naether
67
75
  #
68
76
  def bootstrap_local_repo(local_repo = nil, opts = {} )
69
77
  local_repo = local_repo || default_local_repo
70
-
78
+
71
79
  opts[:local_repo] = local_repo
72
-
80
+
73
81
  temp_naether_dir = File.join( local_repo, ".naether" )
74
-
75
-
82
+
76
83
  deps = download_dependencies( temp_naether_dir, opts )
77
-
84
+
78
85
  jars = (deps[:exists] + deps[:downloaded]).map {|jar| jar.values.first }
79
-
86
+
80
87
  jars = Naether::Java.internal_load_paths( jars )
81
-
88
+
82
89
  if ( deps[:downloaded].size > 0)
83
90
  install_dependencies_to_local_repo( deps[:downloaded], jars, opts )
84
91
  end
85
-
86
- #raise Naether::Java.internal_loaded_paths.inspect
87
-
88
92
  end
89
-
93
+
90
94
  #
91
95
  # Download Naether dependencies
92
96
  #
@@ -94,112 +98,119 @@ module Naether
94
98
  # @param [Hash] opts
95
99
  # @return [Hash] with status of missing, downloaded, exists dependencies
96
100
  def download_dependencies( dest, opts = {} )
97
-
101
+
98
102
  if !File.exists? dest
99
103
  FileUtils.mkdir_p( dest )
100
104
  end
101
-
105
+
102
106
  deps = {}
103
-
107
+
104
108
  if opts[:deps]
105
- deps[:missing] = opts[:deps]
109
+ deps[:missing] = opts[:deps]
106
110
  else
107
111
  deps = check_local_repo_for_deps( opts[:local_repo], opts )
108
112
  end
109
-
113
+
110
114
  deps[:downloaded] = []
111
-
115
+
112
116
  if deps[:missing].size > 0
113
-
117
+ http_client = HTTPClient.new
118
+
114
119
  deps[:missing].each do |dep|
115
120
  notation = dep.split(":")
116
121
  group = notation[0].gsub("\.", File::SEPARATOR)
117
122
  artifact = notation[1]
118
123
  type = notation[2]
119
124
  version = notation[3]
120
-
125
+
121
126
  jar = "#{artifact}-#{version}.#{type}"
122
-
127
+
123
128
  maven_path = "#{dest}#{File::SEPARATOR}#{jar}"
124
-
129
+
125
130
  if !File.exists? maven_path
126
- maven_mirror = "http://repo1.maven.org/maven2/#{group}/#{artifact}/#{version}/#{jar}"
127
-
128
- open(maven_path, 'wb') do |io|
129
- io.print open(maven_mirror).read
131
+ maven_jar_url = "#{maven_url}/#{group}/#{artifact}/#{version}/#{jar}"
132
+
133
+ data = http_client.get(maven_jar_url)
134
+
135
+ if data.ok?
136
+ open(maven_path, 'wb') do |io|
137
+ io.print data.content
138
+ end
139
+ else
140
+ raise "Failed to download #{maven_jar_url}"
130
141
  end
131
-
142
+
132
143
  deps[:downloaded] << { dep => maven_path }
133
144
  else
134
145
  deps[:downloaded] << { dep => maven_path }
135
146
  end
136
147
  end
137
148
  end
138
-
149
+
139
150
  deps
140
151
  end
141
-
152
+
142
153
  #
143
154
  # Check local_repo for Naether dependencies
144
- #
155
+ #
145
156
  # @param [String] local_repo
146
157
  # @param [Hash] opts
147
158
  # @return [Hash] with status of missing, downloaded, exists dependencies
148
159
  def check_local_repo_for_deps(local_repo = nil, opts = {} )
149
-
160
+
150
161
  local_repo = local_repo || default_local_repo
151
162
  local_repo = File.expand_path(local_repo)
152
-
163
+
153
164
  #puts "Checking #{local_repo} for jars to bootstrap Naether"
154
-
165
+
155
166
  deps = {:exists => [], :missing => [], :downloaded => [] }
156
-
167
+
157
168
  dependencies( opts[:dep_yaml] ).each do |dep|
158
169
  notation = dep.split(":")
159
170
  group = notation[0].gsub("\.", File::SEPARATOR)
160
171
  artifact = notation[1].gsub("\.", File::SEPARATOR)
161
172
  type = notation[2]
162
173
  version = notation[3]
163
-
174
+
164
175
  jar = "#{artifact}-#{version}.#{type}"
165
-
176
+
166
177
  maven_path = "#{local_repo}#{File::SEPARATOR}#{group}#{File::SEPARATOR}#{artifact}#{File::SEPARATOR}#{version}#{File::SEPARATOR}#{jar}"
167
-
178
+
168
179
  if File.exists? maven_path
169
180
  deps[:exists] << { dep => maven_path }
170
181
  else
171
182
  deps[:missing] << dep
172
183
  end
173
-
174
- end
184
+
185
+ end
175
186
  deps
176
187
  end
177
-
188
+
178
189
  #
179
190
  # Install Naether Dependencies to local_repo
180
- #
181
- # @param [Array<String>] install_jars
191
+ #
192
+ # @param [Array<String>] install_jars
182
193
  # @param [Array<String>] naether_jars to bootstrap Naether. These may overlap with install_jars.
183
194
  # @param [Hash] opts
184
195
  # @return [Naether]
185
196
  #
186
197
  def install_dependencies_to_local_repo( install_jars, naether_jars, opts = {} )
187
-
198
+
188
199
  require "#{File.dirname(__FILE__)}/../naether"
189
-
200
+
190
201
  @naether = Naether.create_from_jars( naether_jars )
191
-
202
+
192
203
  if opts[:local_repo]
193
204
  @naether.local_repo_path = opts[:local_repo]
194
205
  end
195
-
206
+
196
207
  install_jars.each do |dep|
197
208
  notation, path = dep.to_a.first
198
209
  @naether.install( notation, nil, path )
199
210
  end
200
-
211
+
201
212
  @naether
202
213
  end
203
214
  end
204
215
  end
205
- end
216
+ end
@@ -2,17 +2,17 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: naether 0.13.8 ruby lib
5
+ # stub: naether 0.14.0 ruby lib
6
6
  # stub: Rakefile
7
7
 
8
8
  Gem::Specification.new do |s|
9
9
  s.name = "naether"
10
- s.version = "0.13.8"
10
+ s.version = "0.14.0"
11
11
 
12
12
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
13
13
  s.require_paths = ["lib"]
14
14
  s.authors = ["Michael Guymon"]
15
- s.date = "2015-01-13"
15
+ s.date = "2015-02-13"
16
16
  s.description = "Java dependency resolver using Maven's Aether"
17
17
  s.email = "michael@tobedevoured.com"
18
18
  s.extensions = ["Rakefile"]
@@ -27,8 +27,7 @@ Gem::Specification.new do |s|
27
27
  "README.md",
28
28
  "Rakefile",
29
29
  "VERSION",
30
- "core-0.13.7.jar",
31
- "core-0.13.8.jar",
30
+ "core-0.14.0.jar",
32
31
  "jar_dependencies.yml",
33
32
  "lib/naether.rb",
34
33
  "lib/naether/bootstrap.rb",
@@ -52,12 +51,14 @@ Gem::Specification.new do |s|
52
51
  s.specification_version = 4
53
52
 
54
53
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
54
+ s.add_runtime_dependency(%q<httpclient>, [">= 0"])
55
55
  s.add_runtime_dependency(%q<rjb>, ["~> 1.4.0"])
56
56
  s.add_development_dependency(%q<rspec>, ["> 2.9.0"])
57
57
  s.add_development_dependency(%q<jeweler>, ["~> 2.0.0"])
58
58
  s.add_development_dependency(%q<yard>, [">= 0"])
59
59
  s.add_development_dependency(%q<kramdown>, [">= 0"])
60
60
  else
61
+ s.add_dependency(%q<httpclient>, [">= 0"])
61
62
  s.add_dependency(%q<rjb>, ["~> 1.4.0"])
62
63
  s.add_dependency(%q<rspec>, ["> 2.9.0"])
63
64
  s.add_dependency(%q<jeweler>, ["~> 2.0.0"])
@@ -65,6 +66,7 @@ Gem::Specification.new do |s|
65
66
  s.add_dependency(%q<kramdown>, [">= 0"])
66
67
  end
67
68
  else
69
+ s.add_dependency(%q<httpclient>, [">= 0"])
68
70
  s.add_dependency(%q<rjb>, ["~> 1.4.0"])
69
71
  s.add_dependency(%q<rspec>, ["> 2.9.0"])
70
72
  s.add_dependency(%q<jeweler>, ["~> 2.0.0"])
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: naether
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.8
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Guymon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-13 00:00:00.000000000 Z
11
+ date: 2015-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httpclient
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rjb
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -95,8 +109,7 @@ files:
95
109
  - README.md
96
110
  - Rakefile
97
111
  - VERSION
98
- - core-0.13.7.jar
99
- - core-0.13.8.jar
112
+ - core-0.14.0.jar
100
113
  - jar_dependencies.yml
101
114
  - lib/naether.rb
102
115
  - lib/naether/bootstrap.rb
Binary file