raven 1.0 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/raven +1 -1
- data/bin/raven~ +5 -0
- data/lib/raven.rb +84 -39
- data/lib/raven/deps_tasks.rb +1 -1
- data/lib/raven/gem_init.rb +3 -2
- data/lib/raven/java_tasks.rb +1 -1
- data/lib/raven/repo_builder.rb +66 -41
- data/lib/raven/search_install.rb +233 -0
- metadata +4 -2
data/bin/raven
CHANGED
data/bin/raven~
ADDED
data/lib/raven.rb
CHANGED
@@ -20,6 +20,7 @@ require 'raven/gem_init'
|
|
20
20
|
require 'raven/deps_tasks'
|
21
21
|
require 'raven/repo_builder'
|
22
22
|
require 'raven/java_tasks'
|
23
|
+
require 'raven/search_install'
|
23
24
|
require 'raven/index_gem_repository'
|
24
25
|
|
25
26
|
require 'optparse'
|
@@ -28,51 +29,95 @@ module Raven
|
|
28
29
|
module Command
|
29
30
|
def self.run(args)
|
30
31
|
opts = OptionParser.new
|
31
|
-
opts.banner = "Usage: raven [options] (import | repository * | server)"
|
32
|
-
repo_url = ''
|
33
|
-
opts.on('-m=ARG', '--mavenrepo repo_url') { |val|
|
32
|
+
opts.banner = "Usage: raven [options] (import | repository * | server | install *)"
|
33
|
+
repo_url, index_url, all, groupId, allver = '', '', false, nil, false
|
34
|
+
opts.on('-m=ARG', '--mavenrepo repo_url', '[repository] Maven repository to build your gem repository from.') { |val| repo_url = val }
|
35
|
+
opts.on('-i=ARG', '--index index_url', '[install] URL of a directory containing repository indices.') { |val| index_url = val }
|
36
|
+
opts.on('-g=ARG', '--group', '[install] Install artifacts in the provided group.') { |val| groupId = val }
|
37
|
+
opts.on('-a', '--all', '[install] Install all selected artifacts.') { |val| all = true }
|
38
|
+
opts.on('-v', '--allversions', '[install] Select all versions, not only the latest.') { |val| allver = true }
|
34
39
|
|
35
|
-
|
40
|
+
begin
|
41
|
+
rest = opts.parse(*args)
|
42
|
+
rescue ArgumentError
|
43
|
+
puts 'Wrong option.'
|
44
|
+
end
|
36
45
|
|
37
|
-
ARGV.pop while ARGV.length > 0
|
38
|
-
|
46
|
+
ARGV.pop while ARGV.length > 0
|
47
|
+
|
48
|
+
case rest[0]
|
49
|
+
when 'import'
|
39
50
|
Raven::MavenLocalRepoImport.run()
|
40
|
-
|
41
|
-
if (
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
rel_url = rel_url + '/' if rel_url[-1..-1] != '/'
|
48
|
-
else
|
49
|
-
server = 'www.ibiblio.org'
|
50
|
-
rel_url = '/maven2/'
|
51
|
-
end
|
52
|
-
|
53
|
-
puts "Using server #{server} and url #{rel_url}"
|
54
|
-
builder = Raven::GemRepoBuilder.new(server, rel_url)
|
55
|
-
if (rest.size > 1)
|
56
|
-
rest.shift
|
57
|
-
puts "Packages #{rest}"
|
58
|
-
builder.group_filters = rest
|
59
|
-
end
|
60
|
-
builder.build
|
61
|
-
main_index(ARGV)
|
51
|
+
when 'repository'
|
52
|
+
if (repo_url.length > 0)
|
53
|
+
puts 'repodef'
|
54
|
+
match = repo_url.match('http://([^/]*)(/.*)')
|
55
|
+
server = match[1]
|
56
|
+
rel_url = match[2]
|
57
|
+
rel_url = rel_url + '/' if rel_url[-1..-1] != '/'
|
62
58
|
else
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
59
|
+
server = 'www.ibiblio.org'
|
60
|
+
rel_url = '/maven2/'
|
61
|
+
end
|
62
|
+
puts "Using server #{server} and url #{rel_url}"
|
63
|
+
builder = Raven::GemRepoBuilder.new(server, rel_url)
|
64
|
+
if (rest.size > 1)
|
65
|
+
rest.shift
|
66
|
+
puts "Packages #{rest}"
|
67
|
+
builder.group_filters = rest
|
68
|
+
end
|
69
|
+
builder.build
|
70
|
+
main_index(ARGV)
|
71
|
+
when 'server'
|
72
|
+
require 'webrick'
|
73
|
+
include WEBrick
|
74
|
+
s = HTTPServer.new(
|
75
|
+
:Port => 2233,
|
76
|
+
:DocumentRoot => Dir.pwd )
|
77
|
+
trap("INT") { s.shutdown }
|
78
|
+
s.start
|
79
|
+
when 'install'
|
80
|
+
params = ['raven.rubyforge.org', '80', '/indices/']
|
81
|
+
if (index_url.length > 0)
|
82
|
+
params = Raven::Command.parse_url(index_url)
|
83
|
+
params[2] = '/' if params[2].empty?
|
84
|
+
end
|
85
|
+
installer = Raven::GemSearchInstaller.new(*params)
|
86
|
+
# Refreshes local gem indices if needed
|
87
|
+
installer.get_indices
|
88
|
+
|
89
|
+
rest.shift
|
90
|
+
rest << '' if (rest.empty? && groupId)
|
91
|
+
rest.each do |artifact|
|
92
|
+
av = artifact.match(/([^:]*):?(.*)/).to_a
|
93
|
+
# Trock to see if we've been passed a version number or an artifact
|
94
|
+
begin
|
95
|
+
Integer(av[1][0..0])
|
96
|
+
av[2] = av[1]
|
97
|
+
av[1] = ''
|
98
|
+
rescue
|
99
|
+
end
|
100
|
+
begin
|
101
|
+
installer.install(av[1].length > 0 ? av[1] : nil,
|
102
|
+
groupId, av[2].length > 0 ? av[2] : nil, all, allver)
|
103
|
+
rescue GemTooManyInstallError => toomany
|
104
|
+
puts "Couldn't install a gem from name #{av[1]||groupId}, more than on potential"
|
105
|
+
puts "gem was found for this name. If this is intentional and you want to"
|
106
|
+
puts "install all these Gems please run again with the --all option."
|
107
|
+
toomany.artifacts.each { |a| puts " #{a.to_s}"}
|
73
108
|
end
|
74
109
|
end
|
75
|
-
|
110
|
+
when 'build_index'
|
111
|
+
RepoIndexBuilder.new('m2_central', 'repo1.maven.org', '/maven2/').build_idx
|
112
|
+
else
|
113
|
+
puts opts.to_s
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def self.parse_url(url)
|
118
|
+
parsed = /http:\/\/([^\/:]*):?([^\/]*)(\/?.*)/.match(url).to_a
|
119
|
+
parsed.shift
|
120
|
+
parsed
|
76
121
|
end
|
77
122
|
end
|
78
123
|
end
|
data/lib/raven/deps_tasks.rb
CHANGED
@@ -102,7 +102,7 @@ module Raven
|
|
102
102
|
unless hems[1]
|
103
103
|
installer = Gem::RemoteInstaller.new
|
104
104
|
params = [gem_spec.name, gem_spec.version.to_s, false]
|
105
|
-
params <<
|
105
|
+
params << RAVEN_HOME if defined?(GEMS_IN_HOME)
|
106
106
|
gem_spec = installer.install(*params)[0]
|
107
107
|
end
|
108
108
|
gem_spec.full_gem_path
|
data/lib/raven/gem_init.rb
CHANGED
@@ -54,8 +54,9 @@ set_sources(["http://localhost:2233"])
|
|
54
54
|
# under the user home directory.
|
55
55
|
GEMS_IN_HOME = true
|
56
56
|
USER_HOME = ENV['HOME'] ? ENV['HOME'] : ENV['USERPROFILE']
|
57
|
-
|
58
|
-
|
57
|
+
RAVEN_HOME = USER_HOME + '/.raven/'
|
58
|
+
FileUtils.mkdir(RAVEN_HOME) unless File.exist?(RAVEN_HOME)
|
59
|
+
Dir.glob(RAVEN_HOME + "/specifications/*.gemspec").each do |file_name|
|
59
60
|
gemspec = Gem::SourceIndex.load_specification(file_name.untaint)
|
60
61
|
Gem::cache.add_spec(gemspec) if gemspec
|
61
62
|
end
|
data/lib/raven/java_tasks.rb
CHANGED
@@ -278,7 +278,7 @@ module Raven
|
|
278
278
|
def execute
|
279
279
|
super
|
280
280
|
params = [false]
|
281
|
-
params <<
|
281
|
+
params << RAVEN_HOME if defined?(GEMS_IN_HOME)
|
282
282
|
Gem::Installer.new("target/#{@group}-#{@artifact}-#{@version}-java.gem").install(*params)
|
283
283
|
end
|
284
284
|
end
|
data/lib/raven/repo_builder.rb
CHANGED
@@ -25,9 +25,29 @@ module Raven
|
|
25
25
|
# all the groupId and artifactId crap.
|
26
26
|
class Artifact
|
27
27
|
attr_reader :groupId, :artifactId, :versionId, :path
|
28
|
+
attr_accessor :server
|
28
29
|
def initialize(groupId, artifactId, versionId, path)
|
29
30
|
@groupId, @artifactId, @versionId, @path = groupId, artifactId, versionId, path
|
30
31
|
end
|
32
|
+
|
33
|
+
def to_yaml_properties
|
34
|
+
%w{ @groupId @artifactId @versionId @path }
|
35
|
+
end
|
36
|
+
|
37
|
+
def ==(art) eql?(art); end
|
38
|
+
def ===(art) eql?(art); end
|
39
|
+
def eql?(art)
|
40
|
+
false if art.class != Artifact
|
41
|
+
art.groupId == @groupId && art.artifactId == @artifactId && art.versionId == @versionId
|
42
|
+
end
|
43
|
+
|
44
|
+
def hash
|
45
|
+
@groupId.hash ^ (@artifactId.hash << 1) ^ (@versionId.hash << 2)
|
46
|
+
end
|
47
|
+
|
48
|
+
def to_s
|
49
|
+
"#{artifactId} v#{versionId} (module #{groupId})"
|
50
|
+
end
|
31
51
|
end
|
32
52
|
|
33
53
|
# Enumerates on a Maven repository by scraping HTML. Yields on every
|
@@ -41,12 +61,12 @@ module Raven
|
|
41
61
|
@group_filters
|
42
62
|
end
|
43
63
|
|
44
|
-
def initialize(server, url)
|
45
|
-
@server, @url = server, url
|
64
|
+
def initialize(server, url, port="80")
|
65
|
+
@server, @url, @port = server, url, port
|
46
66
|
end
|
47
67
|
|
48
68
|
def each
|
49
|
-
http = Net::HTTP.new(@server,
|
69
|
+
http = Net::HTTP.new(@server, @port)
|
50
70
|
folder_regexp = /<img src="\/icons\/folder.gif" alt="\[DIR\]"> <a href="[^\/]*\/">/
|
51
71
|
file_regexp = /<img src="\/icons\/unknown.gif" alt="\[ \]"> <a href="[^"]*">/
|
52
72
|
read_page(http, @url, folder_regexp) do |url1, groupId|
|
@@ -84,7 +104,7 @@ module Raven
|
|
84
104
|
class GemRepoBuilder
|
85
105
|
attr_writer :group_filters
|
86
106
|
|
87
|
-
def initialize(server, url)
|
107
|
+
def initialize(server, port, url)
|
88
108
|
@server, @url = server, url
|
89
109
|
end
|
90
110
|
|
@@ -97,43 +117,34 @@ module Raven
|
|
97
117
|
|
98
118
|
Dir.chdir('gems') do
|
99
119
|
repo.each do |artifact, http|
|
100
|
-
|
101
|
-
if !File.exist?(gemname) || overwrite
|
102
|
-
with(artifact, 'ext', http) do
|
103
|
-
# The fileset is computed when gemspec is created, file must be there
|
104
|
-
gemspec = Raven.create_gemspec(artifact)
|
105
|
-
Gem::Builder.new(gemspec).build
|
106
|
-
end
|
107
|
-
end
|
120
|
+
Raven.install_remote_gem(artifact, http, @url, overwrite)
|
108
121
|
end
|
109
122
|
end
|
110
123
|
|
111
124
|
end
|
112
|
-
|
113
|
-
def with(artifact, subdir, http)
|
114
|
-
response = http.get(@url + artifact.path, nil)
|
115
|
-
file = File.new(subdir + "/#{artifact.artifactId}-#{artifact.versionId}.jar", 'wb')
|
116
|
-
file.write(response.body)
|
117
|
-
file.close
|
118
|
-
yield
|
119
|
-
File.delete(subdir + "/#{artifact.artifactId}-#{artifact.versionId}.jar")
|
120
|
-
end
|
121
125
|
end
|
122
126
|
|
123
|
-
def self.
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
s.autorequire = 'rake'
|
132
|
-
s.files = Dir.glob("{ext}/**/*")
|
127
|
+
def self.install_remote_gem(artifact, http, base_url, overwrite=true)
|
128
|
+
gemname = "#{artifact.groupId}-#{artifact.artifactId}-#{artifact.versionId}-java.gem"
|
129
|
+
if !File.exist?(gemname) || overwrite
|
130
|
+
Raven.with(artifact, 'ext', http, base_url) do
|
131
|
+
# The fileset is computed when gemspec is created, file must be there
|
132
|
+
gemspec = Raven.create_gemspec(artifact)
|
133
|
+
Gem::Builder.new(gemspec).build
|
134
|
+
end
|
133
135
|
end
|
136
|
+
gemname
|
134
137
|
end
|
135
|
-
|
136
|
-
|
138
|
+
|
139
|
+
def self.with(artifact, subdir, http, base_url)
|
140
|
+
response = http.get(base_url + artifact.path, nil)
|
141
|
+
file = File.new(subdir + "/#{artifact.artifactId}-#{artifact.versionId}.jar", 'wb')
|
142
|
+
file.write(response.body)
|
143
|
+
file.close
|
144
|
+
yield
|
145
|
+
File.delete(subdir + "/#{artifact.artifactId}-#{artifact.versionId}.jar")
|
146
|
+
end
|
147
|
+
|
137
148
|
class M2LocalRepository
|
138
149
|
def initialize(dir)
|
139
150
|
@dir = dir
|
@@ -232,7 +243,7 @@ module Raven
|
|
232
243
|
Gem::Builder.new(gemspec).build
|
233
244
|
# Installing Gem
|
234
245
|
params = [false]
|
235
|
-
params <<
|
246
|
+
params << RAVEN_HOME if defined?(GEMS_IN_HOME)
|
236
247
|
Gem::Installer.new("#{artifact.groupId}-#{artifact.artifactId}-#{artifact.versionId}-java.gem").install(*params)
|
237
248
|
# Cleaning up for next iteration
|
238
249
|
FileUtils.rm(Dir.glob('ext/*'))
|
@@ -249,7 +260,7 @@ module Raven
|
|
249
260
|
nil
|
250
261
|
end
|
251
262
|
end
|
252
|
-
|
263
|
+
|
253
264
|
def self.dir_each(path)
|
254
265
|
Dir.foreach(path) do |elmt|
|
255
266
|
next if DIR_EXCL.include?(elmt)
|
@@ -257,10 +268,24 @@ module Raven
|
|
257
268
|
end
|
258
269
|
end
|
259
270
|
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
#
|
271
|
+
def self.create_gemspec(artifact)
|
272
|
+
spec = Gem::Specification.new do |s|
|
273
|
+
s.platform = Gem::Platform::JAVA
|
274
|
+
s.summary = "Raven wrapped library #{artifact.artifactId} from project #{artifact.groupId}."
|
275
|
+
s.name = "#{artifact.groupId}-#{artifact.artifactId}"
|
276
|
+
s.version = artifact.versionId
|
277
|
+
s.requirements << 'none'
|
278
|
+
s.require_path = 'ext'
|
279
|
+
s.autorequire = 'rake'
|
280
|
+
s.files = Dir.glob("{ext}/**/*")
|
281
|
+
end
|
282
|
+
end
|
265
283
|
|
266
|
-
|
284
|
+
class GemTooManyInstallError < RuntimeError
|
285
|
+
attr_reader :artifacts
|
286
|
+
def initialize(arts)
|
287
|
+
@artifacts = arts
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
end
|
@@ -0,0 +1,233 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Copyright 2006 Matthieu Riou
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require 'net/http'
|
18
|
+
|
19
|
+
module Raven
|
20
|
+
|
21
|
+
class RepoIndexBuilder
|
22
|
+
def initialize(name, server, base_url, port='80')
|
23
|
+
@name, @server, @base_url, @port = name, server, base_url, port
|
24
|
+
end
|
25
|
+
|
26
|
+
def build_idx
|
27
|
+
require 'yaml'
|
28
|
+
require 'zlib'
|
29
|
+
Zlib::GzipWriter.open("#{@name}.mvnidx.gz") do |f|
|
30
|
+
f << @server + "#" + @port + "#" + @base_url + "\n"
|
31
|
+
Raven::Maven2Repository.new(@server, @base_url, @port).each do |artifact, http|
|
32
|
+
f << YAML.dump(artifact)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class GemSearchInstaller
|
39
|
+
def initialize(server, port, base_url)
|
40
|
+
@server, @base_url, @port = server, base_url, port
|
41
|
+
end
|
42
|
+
|
43
|
+
def list_indices
|
44
|
+
indices = []
|
45
|
+
http = Net::HTTP.new(@server, @port)
|
46
|
+
response = http.get(@base_url, nil)
|
47
|
+
expr = /HREF="([^"]*idx.gz)"/
|
48
|
+
if response.message.strip == "OK"
|
49
|
+
response.body.each_line do |line|
|
50
|
+
if expr =~ line
|
51
|
+
indices << expr.match(line)[1]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
else
|
55
|
+
puts "Got a bad response from server http://#{@server}:#{@port}/#{@base_url}, couldn't update local index"
|
56
|
+
end
|
57
|
+
indices
|
58
|
+
end
|
59
|
+
|
60
|
+
def get_indices
|
61
|
+
require 'stringio'
|
62
|
+
http = Net::HTTP.new(@server, @port)
|
63
|
+
|
64
|
+
list_indices.each do |file|
|
65
|
+
http_fn, fs_fn = @base_url + file, RAVEN_HOME + file[0..-4]
|
66
|
+
|
67
|
+
# Checking file size to see if it changed
|
68
|
+
header = http.head(http_fn)
|
69
|
+
zipsize = header["content-length"]
|
70
|
+
oldsize = File.exist?(fs_fn) ? File.new(fs_fn).readline.chomp : '0'
|
71
|
+
|
72
|
+
unless (zipsize.to_i == oldsize.to_i)
|
73
|
+
puts "Refreshing index file #{file[0..-4]}"
|
74
|
+
response = StringIO.new(http.get(@base_url + file, nil).body)
|
75
|
+
zlib = Zlib::GzipReader.new(response)
|
76
|
+
file = File.new(RAVEN_HOME + file[0..-4], 'wb')
|
77
|
+
file << zipsize + "\n"
|
78
|
+
file.write(zlib.read)
|
79
|
+
file.close
|
80
|
+
zlib.close
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def search(artifactId, groupId=nil, versionId=nil)
|
86
|
+
idx_files = Dir[RAVEN_HOME + '*.mvnidx']
|
87
|
+
found = []
|
88
|
+
idx_files.each do |idx_file|
|
89
|
+
puts "Searching in #{idx_file}..."
|
90
|
+
f = File.new(idx_file)
|
91
|
+
found.concat(search_index(f, artifactId, groupId, versionId))
|
92
|
+
end
|
93
|
+
found
|
94
|
+
end
|
95
|
+
|
96
|
+
def search_index(idx_file, artifactId, groupId, versionId)
|
97
|
+
# Removing gz file size header
|
98
|
+
idx_file.gets
|
99
|
+
# Getting server name and gz file size header
|
100
|
+
server_addr = idx_file.gets.chomp.split("#")
|
101
|
+
aid_line = /artifactId: (.*#{artifactId}.*)/
|
102
|
+
gid_line = /groupId: (.*#{groupId}.*)/
|
103
|
+
vid_line = /versionId: "?(#{versionId})"?/
|
104
|
+
|
105
|
+
# a, a+v, a+g, g, v+g, a+v+g
|
106
|
+
found = []
|
107
|
+
while (lines = read_lines(idx_file, 5))
|
108
|
+
ma, mg, mv = false, false, false
|
109
|
+
ma = lines[2].strip =~ aid_line if artifactId
|
110
|
+
mg = lines[1].strip =~ gid_line if groupId
|
111
|
+
mv = lines[3].strip =~ vid_line if versionId
|
112
|
+
if ((ma && groupId.nil? && versionId.nil?) ||
|
113
|
+
(ma && mg && versionId.nil?) ||
|
114
|
+
(ma && mv && groupId.nil?) ||
|
115
|
+
(ma && mg && mv) ||
|
116
|
+
(mg && mv && artifactId.nil?) ||
|
117
|
+
(mg && artifactId.nil? && versionId.nil?))
|
118
|
+
artifact = YAML.load(lines.join("\n"))
|
119
|
+
artifact.server = server_addr
|
120
|
+
found << artifact
|
121
|
+
end
|
122
|
+
end
|
123
|
+
found
|
124
|
+
end
|
125
|
+
|
126
|
+
def read_lines(file, size)
|
127
|
+
lines = []
|
128
|
+
0.upto(size-1) { |m| lines[m] = file.gets }
|
129
|
+
return nil if lines[size-1].nil?
|
130
|
+
lines
|
131
|
+
end
|
132
|
+
|
133
|
+
def install(artifactId, groupId, versionId, all=false, all_versions=false)
|
134
|
+
artifacts = search(artifactId, groupId, versionId).uniq
|
135
|
+
|
136
|
+
if (versionId.nil? && !all_versions)
|
137
|
+
artifacts = filtrate_latest(artifacts)
|
138
|
+
puts artifacts
|
139
|
+
end
|
140
|
+
|
141
|
+
# Selected several artifacts but supposed to have only one
|
142
|
+
if (artifacts.nil?)
|
143
|
+
puts "Gem indices couldn't be found properly (either you provided a wrong URL or the main site is down)."
|
144
|
+
return
|
145
|
+
end
|
146
|
+
raise GemTooManyInstallError.new(artifacts), "Too many artifacts" if (!all && artifacts.size > 1)
|
147
|
+
|
148
|
+
if (artifacts.empty?)
|
149
|
+
puts "Nothing found."
|
150
|
+
else
|
151
|
+
# TODO install from the servers returned by search
|
152
|
+
# Proceeding with installation
|
153
|
+
FileUtils.mkdir('ext')
|
154
|
+
puts "Installing Gems:"
|
155
|
+
artifacts.each do |artifact|
|
156
|
+
http = Net::HTTP.new(artifact.server[0], artifact.server[1])
|
157
|
+
puts " - #{artifact.to_s}"
|
158
|
+
gemname = Raven.install_remote_gem(artifact, http, artifact.server[2], true)
|
159
|
+
params = [false]
|
160
|
+
params << RAVEN_HOME if defined?(GEMS_IN_HOME)
|
161
|
+
Gem::Installer.new(gemname).install(*params)
|
162
|
+
FileUtils.rm(gemname)
|
163
|
+
end
|
164
|
+
FileUtils.rm_rf('ext')
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def filtrate_latest(artifacts)
|
169
|
+
# Create a hash with all versions of each artifact
|
170
|
+
arth = {}
|
171
|
+
artifacts.each do |art|
|
172
|
+
key = "#{art.groupId}%#{art.artifactId}"
|
173
|
+
arth[key] ||= []
|
174
|
+
arth[key] << Version.new(art.versionId)
|
175
|
+
end
|
176
|
+
|
177
|
+
arth.keys.collect do |key|
|
178
|
+
last_ver = arth[key].sort[-1].version
|
179
|
+
find_artifact(artifacts, *(key.split('%') << last_ver))
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def find_artifact(artifacts, groupId, artifactId, versionId)
|
184
|
+
artifacts.select do |art|
|
185
|
+
art if art.artifactId == artifactId &&
|
186
|
+
art.groupId == groupId && art.versionId == versionId
|
187
|
+
end[0]
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
# Structured version class used to try to make some sense
|
192
|
+
# out of Maven version numbers. A difficult task indeed.
|
193
|
+
class Version
|
194
|
+
include Comparable
|
195
|
+
attr_reader :timestamp, :ver_struct, :version
|
196
|
+
|
197
|
+
def initialize(version)
|
198
|
+
@version = version
|
199
|
+
elmts = @version.split(/\.|-/)
|
200
|
+
@timestamp = elmts[0].length > 3 ? true : false
|
201
|
+
@ver_struct = elmts.collect do |elmt|
|
202
|
+
val = ''
|
203
|
+
begin
|
204
|
+
val = Integer(elmt)
|
205
|
+
rescue ArgumentError
|
206
|
+
val = elmt
|
207
|
+
end
|
208
|
+
val
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
def <=>(ver)
|
213
|
+
false if !(Version === ver)
|
214
|
+
return -1 if @timestamp && !ver.timestamp
|
215
|
+
return 1 if !@timestamp && ver.timestamp
|
216
|
+
# Setting string elements to 0 (mostly weaker) if they need
|
217
|
+
# to be compared to an int otherwise <=> could produce nil
|
218
|
+
@me, you = @ver_struct.dup, ver.ver_struct.dup
|
219
|
+
(0..@me.size).each do |m|
|
220
|
+
if (m < you.size && @me[m].class != you[m].class)
|
221
|
+
@me[m] = 0 if String === @me[m]
|
222
|
+
you[m] = 0 if String === you[m]
|
223
|
+
end
|
224
|
+
end
|
225
|
+
@me <=> you
|
226
|
+
end
|
227
|
+
|
228
|
+
def to_s
|
229
|
+
puts "v#{@version}, ts #{timestamp}, #{ @ver_struct.collect{ |v| v.class }.join('/') }"
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: raven
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: "1.
|
7
|
-
date: 2006-
|
6
|
+
version: "1.1"
|
7
|
+
date: 2006-11-02 00:00:00 -08:00
|
8
8
|
summary: Java build system based on Rake and Gem.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -29,6 +29,7 @@ post_install_message:
|
|
29
29
|
authors:
|
30
30
|
- Matthieu Riou
|
31
31
|
files:
|
32
|
+
- bin/raven~
|
32
33
|
- bin/raven
|
33
34
|
- lib/raven
|
34
35
|
- lib/raven.rb
|
@@ -36,6 +37,7 @@ files:
|
|
36
37
|
- lib/raven/gem_init.rb
|
37
38
|
- lib/raven/java_tasks.rb
|
38
39
|
- lib/raven/repo_builder.rb
|
40
|
+
- lib/raven/search_install.rb
|
39
41
|
- lib/raven/index_gem_repository.rb
|
40
42
|
- README.rdoc
|
41
43
|
- LICENSE
|