30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# File 'lib/raven.rb', line 30
def self.run(args)
opts = OptionParser.new
opts.banner = "Usage: raven [options] (import | repository * | server | install *)"
repo_url, proxy_url, index_url, all, groupId, allver = '', '', '', false, nil, false
opts.on('-m=ARG', '--mavenrepo repo_url', '[repository] Maven repository to build your gem repository from.') { |val| repo_url = val }
opts.on('-p=ARG', '--proxy proxy_url', '[repository|install] Proxy url (http://<p_user>:<p_pwd>@<p_host>:<p_port>) for access outside corporate firewalls.') { |val| proxy_url = val }
opts.on('-i=ARG', '--index index_url', '[install] URL of a directory containing repository indices.') { |val| index_url = val }
opts.on('-p=ARG', '--project group_id', '[install] Install artifacts in the provided project.') { |val| groupId = val }
opts.on('-a', '--all', '[install] Install all selected artifacts.') { |val| all = true }
opts.on('-v', '--allversions', '[install] Select all versions, not only the latest.') { |val| allver = true }
begin
rest = opts.parse(*args)
rescue ArgumentError
puts 'Wrong option.'
end
ARGV.pop while ARGV.length > 0
case rest[0]
when 'import'
Raven::MavenLocalRepoImport.run()
when 'repository'
if (repo_url.length > 0)
puts 'repodef'
match = repo_url.match('http://([^/]*)(/.*)')
server = match[1]
rel_url = match[2]
rel_url = rel_url + '/' if rel_url[-1..-1] != '/'
else
server = 'repo1.maven.org'
rel_url = '/maven2/'
end
puts "Connecting to Maven2 repository at http://#{server}#{rel_url}."
builder = Raven::GemRepoBuilder.new(server, 80, rel_url, Raven::Command.parse_proxy(proxy_url))
if (rest.size > 1)
rest.shift
puts "Packages: #{rest.join(' ')}"
builder.group_filters = rest
end
builder.build
main_index(ARGV)
when 'server'
require 'webrick'
include WEBrick
s = HTTPServer.new(
:Port => 2233,
:DocumentRoot => Dir.pwd )
trap("INT") { s.shutdown }
s.start
when 'install'
params = ['raven.rubyforge.org', 80, '/indices/']
if (index_url.length > 0)
params = Raven::Command.parse_url(index_url)
params[2] = '/' if params[2].empty?
end
params << Raven::Command.parse_proxy(proxy_url)
installer = Raven::GemSearchInstaller.new(*params)
installer.get_indices
rest.shift
rest << '' if (rest.empty? && groupId)
rest.each do |artifact|
av = artifact.match(/([^:]*):?(.*)/).to_a
begin
aint = Integer(av[1][0..0])
if aint != 0
av[2] = av[1]
av[1] = ''
end
rescue
end
begin
installer.install(av[1].length > 0 ? av[1] : nil,
groupId, av[2].length > 0 ? av[2] : nil, all, allver)
rescue GemTooManyInstallError => toomany
puts "Couldn't install a gem from name #{av[1]||groupId}, more than one potential"
puts "gem was found for this name. If this is intentional and you want to"
puts "install all these gems please run again with the --all option."
toomany.artifacts.each { |a| puts " #{a.to_s}"}
end
end
when 'build_index'
RepoIndexBuilder.new('m2_central', 'repo1.maven.org', '/maven2/', Raven::Command.parse_proxy(proxy_url)).build_idx
else
puts opts.to_s
end
end
|