raven 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +0 -2
- data/lib/raven.rb +2 -2
- data/lib/raven/deps_tasks.rb +11 -1
- data/lib/raven/deps_tasks.rb~ +182 -0
- data/lib/raven/gem_init.rb +28 -16
- data/lib/raven/gem_init.rb~ +85 -0
- data/lib/raven/java_tasks.rb +1 -0
- data/lib/raven/search_install.rb +4 -4
- metadata +4 -2
data/README.rdoc
CHANGED
data/lib/raven.rb
CHANGED
@@ -108,9 +108,9 @@ module Raven
|
|
108
108
|
installer.install(av[1].length > 0 ? av[1] : nil,
|
109
109
|
groupId, av[2].length > 0 ? av[2] : nil, all, allver)
|
110
110
|
rescue GemTooManyInstallError => toomany
|
111
|
-
puts "Couldn't install a gem from name #{av[1]||groupId}, more than
|
111
|
+
puts "Couldn't install a gem from name #{av[1]||groupId}, more than one potential"
|
112
112
|
puts "gem was found for this name. If this is intentional and you want to"
|
113
|
-
puts "install all these
|
113
|
+
puts "install all these gems please run again with the --all option."
|
114
114
|
toomany.artifacts.each { |a| puts " #{a.to_s}"}
|
115
115
|
end
|
116
116
|
end
|
data/lib/raven/deps_tasks.rb
CHANGED
@@ -87,6 +87,10 @@ module Raven
|
|
87
87
|
raise(RuntimeError, notfound.join($/) + $/ + ambiguous.join($/))
|
88
88
|
end
|
89
89
|
end
|
90
|
+
# Getting dependencies from eventual prerequisites
|
91
|
+
Raven.prereq_filter(prerequisites, :gem_deps) do |dep_task|
|
92
|
+
@gem_deps += dep_task.gem_deps if dep_task.gem_deps
|
93
|
+
end
|
90
94
|
end
|
91
95
|
|
92
96
|
def deps
|
@@ -138,8 +142,14 @@ module Raven
|
|
138
142
|
puts "Using local gem #{local[0].name} (#{local[0].version}) to satisfy dependency #{gemname}" if RakeFileUtils.verbose_flag && local
|
139
143
|
return local if local
|
140
144
|
begin
|
141
|
-
|
145
|
+
if (Gem::RubyGemsPackageVersion != "0.9.0")
|
146
|
+
gems = Gem::SourceInfoCache.search(/.*#{gemname}$/)
|
147
|
+
else
|
148
|
+
gems = Gem::RemoteInstaller.new().search(/.*#{gemname}$/)
|
149
|
+
end
|
142
150
|
rescue Exception => rt
|
151
|
+
puts rt.to_s
|
152
|
+
puts rt.backtrace.join("\n")
|
143
153
|
puts "The gem #{gemname} from your dependencies couldn't be found locally"
|
144
154
|
puts "and the connection to a Gem repository failed."
|
145
155
|
exit
|
@@ -0,0 +1,182 @@
|
|
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 'rubygems'
|
18
|
+
require 'rake'
|
19
|
+
require 'set'
|
20
|
+
require 'fileutils'
|
21
|
+
|
22
|
+
module Raven
|
23
|
+
|
24
|
+
class GemNotFoundException < RuntimeError; end
|
25
|
+
class AmbiguousGemException < RuntimeError; end
|
26
|
+
|
27
|
+
# Task used to declare a set of dependencies your project relies
|
28
|
+
# upon. As many dependency tasks as necessary can be declared
|
29
|
+
# (each grouping as many dependency as you like). For each declared
|
30
|
+
# dependency, a Gem is searched in your local repository and then if
|
31
|
+
# it can't be found, in the specified remote repositories (by setting
|
32
|
+
# <em>sources</em>). Gems are searched by name ENDING with the name
|
33
|
+
# you provided.
|
34
|
+
#
|
35
|
+
# As an example, specifying 'wsdl4j' will correctly find the Gem
|
36
|
+
# named wsdl4j-wsdl4j but specifying 'axis2' WILL NOT give you all
|
37
|
+
# axis2 Gems. Actually only one Gem can be selected by each of the
|
38
|
+
# specified Gem, otherwise you'll see an error asking you to be more
|
39
|
+
# specific.
|
40
|
+
#
|
41
|
+
# Once the correct Gem has been found, if it's not local it will be
|
42
|
+
# automatically be downloaded and installed.
|
43
|
+
#
|
44
|
+
# If no version is provided, and the Gem isn't present locally, the
|
45
|
+
# latest version will be fetched. If a local version can be found
|
46
|
+
# locally, this version will be used without any download.
|
47
|
+
#
|
48
|
+
# Example of dependency specification:
|
49
|
+
#
|
50
|
+
# dependency 'deps' do |t|
|
51
|
+
# t.deps << [{'commons-logging' => '1.1'}, 'commons-pool']
|
52
|
+
# t.deps << ['commons-lang', 'wsdl4j', 'log4j']
|
53
|
+
# end
|
54
|
+
#
|
55
|
+
# See also Raven::MavenLocalRepoImport and Raven::GemRepoBuilder to
|
56
|
+
# learn more about how to build a Gem repository to get started.
|
57
|
+
#
|
58
|
+
# Alternatively dependencies can be directly declared manually on
|
59
|
+
# jar files in your file system. This allows you to manage your
|
60
|
+
# dependencies yourself without using Gem or any other repository.
|
61
|
+
#
|
62
|
+
# dependency 'deps' do |t|
|
63
|
+
# t.libs = Dir.glob('lib/**/*.jar')
|
64
|
+
# end
|
65
|
+
class DependencyTask < Rake::Task
|
66
|
+
attr_reader :gem_deps
|
67
|
+
|
68
|
+
# Check dependencies and installs them sometimes.
|
69
|
+
def execute
|
70
|
+
super
|
71
|
+
ambiguous, notfound = [], []
|
72
|
+
# Installing missing Gems (if there are)
|
73
|
+
if @deps
|
74
|
+
@gem_deps = @deps.flatten.collect do |dep|
|
75
|
+
# Wrapping in an array, we might not have an array with version
|
76
|
+
# as dependency.
|
77
|
+
deparr = dep.respond_to?(:to_a) ? dep.to_a.flatten : [dep]
|
78
|
+
begin
|
79
|
+
Raven::GemInstaller.install_or_not(*deparr)
|
80
|
+
rescue GemNotFoundException => gnfe
|
81
|
+
notfound << gnfe.message
|
82
|
+
rescue AmbiguousGemException => age
|
83
|
+
ambiguous << age
|
84
|
+
end
|
85
|
+
end
|
86
|
+
unless notfound.empty? && ambiguous.empty?
|
87
|
+
raise(RuntimeError, notfound.join($/) + $/ + ambiguous.join($/))
|
88
|
+
end
|
89
|
+
end
|
90
|
+
# Getting dependencies from eventual prerequisites
|
91
|
+
Raven.prereq_filter(prerequisites, :gem_deps) do |dep_task|
|
92
|
+
@gem_deps += dep_task.gem_deps if dep_task.gem_deps
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def deps
|
97
|
+
@deps ||= []
|
98
|
+
end
|
99
|
+
|
100
|
+
def libs
|
101
|
+
@libs ||= []
|
102
|
+
end
|
103
|
+
def libs=(l)
|
104
|
+
@libs = l
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# Calls Gem installer to install a Gem (very predictible behaviour).
|
109
|
+
# Well, but if the Gem is already there, it won't be installed. This
|
110
|
+
# guy's a smart one.
|
111
|
+
module GemInstaller
|
112
|
+
|
113
|
+
# Possibly installs a Gem... or not. If it's already present installation
|
114
|
+
# will just be skipped. The path to the gem root is always returned though.
|
115
|
+
# The provided gem name is first looked up with a query in the repositories
|
116
|
+
# to support partial names (i.e only artifactId).
|
117
|
+
def self.install_or_not(gemname, version='*')
|
118
|
+
# TODO Add support for regular expressions for gem name, allows multiple
|
119
|
+
# selected gems
|
120
|
+
hems = resolve(gemname, version)
|
121
|
+
gem_spec = hems[0]
|
122
|
+
# TODO Handle Gem dependencies
|
123
|
+
unless hems[1]
|
124
|
+
installer = Gem::RemoteInstaller.new
|
125
|
+
params = [gem_spec.name, gem_spec.version.to_s, false]
|
126
|
+
params << RAVEN_HOME if defined?(GEMS_IN_HOME)
|
127
|
+
gem_spec = installer.install(*params)[0]
|
128
|
+
end
|
129
|
+
gem_spec.full_gem_path
|
130
|
+
end
|
131
|
+
|
132
|
+
# Resolves a Gem partial name (like only the artifactId) to a full name
|
133
|
+
# and eventually checks its versions. Returns an array with the found Gem
|
134
|
+
# in the first position and a boolean indicating whether the array has
|
135
|
+
# been found locally or not in second position.
|
136
|
+
def self.resolve(gemname, version)
|
137
|
+
# Search local occurences first, it's faster. Moreover we'll only
|
138
|
+
# return local versions, avoiding a constant download of latest versions
|
139
|
+
# when nothing specific is provided.
|
140
|
+
gems = Gem::cache.search(/.*#{gemname}$/)
|
141
|
+
local = select_gem(gemname, version, gems, true)
|
142
|
+
puts "Using local gem #{local[0].name} (#{local[0].version}) to satisfy dependency #{gemname}" if RakeFileUtils.verbose_flag && local
|
143
|
+
return local if local
|
144
|
+
begin
|
145
|
+
gems = Gem::SourceInfoCache.search(/.*#{gemname}$/)
|
146
|
+
rescue Exception => rt
|
147
|
+
puts rt.to_s
|
148
|
+
puts rt.backtrace.join("\n")
|
149
|
+
puts "The gem #{gemname} from your dependencies couldn't be found locally"
|
150
|
+
puts "and the connection to a Gem repository failed."
|
151
|
+
exit
|
152
|
+
end
|
153
|
+
remote = select_gem(gemname, version, gems.flatten, false)
|
154
|
+
puts "Downloading remote gem #{remote[0].name} (#{remote[0].version}) to satisfy dependency #{gemname}" if RakeFileUtils.verbose_flag && remote
|
155
|
+
return remote if remote
|
156
|
+
|
157
|
+
# Nothing found: Houston, we have a problem
|
158
|
+
raise(GemNotFoundException, "Couldn't find any Gem from name #{gemname} and version #{version}") unless remote
|
159
|
+
end
|
160
|
+
|
161
|
+
private
|
162
|
+
|
163
|
+
def self.select_gem(gemname, version, gems, local)
|
164
|
+
# We can only have different versions of the same Gem, different Gems
|
165
|
+
# is a problem.
|
166
|
+
if gems.collect{|gem| gem.name}.uniq.size > 1
|
167
|
+
raise(AmbiguousGemException, "Several different Gems can be found from name #{gemname} (#{gems.collect{|gem| gem.name}.uniq.join(' ')}), please be more specific.")
|
168
|
+
end
|
169
|
+
version_gems = Hash[*gems.collect{ |gem| [gem.version.to_s, gem] }.flatten]
|
170
|
+
# Latest one will do when no version has been given.
|
171
|
+
return [version_gems.sort.reverse[0][1], local] if (version == '*' && !version_gems.empty?)
|
172
|
+
return [version_gems[version], local] if (version_gems[version] && !version_gems.empty?)
|
173
|
+
nil
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
178
|
+
|
179
|
+
# Shortcut to the dependency task creation.
|
180
|
+
def dependency(args, &block)
|
181
|
+
Raven::DependencyTask.define_task(args, &block)
|
182
|
+
end
|
data/lib/raven/gem_init.rb
CHANGED
@@ -45,7 +45,11 @@ module Gem
|
|
45
45
|
@sources = s
|
46
46
|
end
|
47
47
|
end
|
48
|
-
|
48
|
+
if (Gem::RubyGemsPackageVersion != "0.9.0")
|
49
|
+
gem("sources")
|
50
|
+
else
|
51
|
+
require_gem("sources")
|
52
|
+
end
|
49
53
|
def sources; Gem.sources; end
|
50
54
|
def set_sources(s) Gem.sources = s; end
|
51
55
|
set_sources(["http://gems.rubyraven.org/"])
|
@@ -53,10 +57,10 @@ set_sources(["http://gems.rubyraven.org/"])
|
|
53
57
|
# To avoid polluting the regular Gem repository, we store our gems
|
54
58
|
# under the user home directory.
|
55
59
|
GEMS_IN_HOME = true
|
56
|
-
USER_HOME = ENV['HOME'] ? ENV['HOME'] : ENV['USERPROFILE']
|
57
|
-
RAVEN_HOME = USER_HOME
|
60
|
+
USER_HOME = ENV['HOME'] ? ENV['HOME'] : ENV['USERPROFILE'].gsub('\\', '/')
|
61
|
+
RAVEN_HOME = File.join(USER_HOME, '.raven')
|
58
62
|
FileUtils.mkdir(RAVEN_HOME) unless File.exist?(RAVEN_HOME)
|
59
|
-
Dir.glob(RAVEN_HOME
|
63
|
+
Dir.glob(File.join(RAVEN_HOME, "specifications", "*.gemspec")).each do |file_name|
|
60
64
|
gemspec = Gem::SourceIndex.load_specification(file_name.untaint)
|
61
65
|
Gem::cache.add_spec(gemspec) if gemspec
|
62
66
|
end
|
@@ -65,21 +69,29 @@ module Gem
|
|
65
69
|
# Making the remote installer silent. Otherwise it always asks you to
|
66
70
|
# choose the version you want to install.
|
67
71
|
class RemoteInstaller
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
72
|
+
if (Gem::RubyGemsPackageVersion != "0.9.0")
|
73
|
+
def find_gem_to_install(gem_name, version_requirement)
|
74
|
+
specs_n_sources = specs_n_sources_matching gem_name, version_requirement
|
75
|
+
# we always give exact name / version to RubyGems
|
76
|
+
specs_n_sources.first
|
77
|
+
end
|
78
|
+
else
|
79
|
+
def find_gem_to_install(gem_name, version_requirement, caches)
|
80
|
+
specs_n_sources = []
|
81
|
+
caches.each do |source, cache|
|
82
|
+
cache.each do |name, spec|
|
83
|
+
if /^#{gem_name}$/i === spec.name &&
|
84
|
+
version_requirement.satisfied_by?(spec.version) then
|
85
|
+
specs_n_sources << [spec, source]
|
86
|
+
end
|
75
87
|
end
|
76
88
|
end
|
89
|
+
if specs_n_sources.empty? then
|
90
|
+
raise GemNotFoundException.new("Could not find #{gem_name} (#{version_requirement}) in the repository")
|
91
|
+
end
|
92
|
+
specs_n_sources = specs_n_sources.sort_by { |gs,| gs.version }.reverse
|
93
|
+
specs_n_sources[0]
|
77
94
|
end
|
78
|
-
if specs_n_sources.empty? then
|
79
|
-
raise GemNotFoundException.new("Could not find #{gem_name} (#{version_requirement}) in the repository")
|
80
|
-
end
|
81
|
-
specs_n_sources = specs_n_sources.sort_by { |gs,| gs.version }.reverse
|
82
|
-
specs_n_sources[0]
|
83
95
|
end
|
84
96
|
end
|
85
97
|
end
|
@@ -0,0 +1,85 @@
|
|
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 'rubygems'
|
18
|
+
require 'fileutils'
|
19
|
+
|
20
|
+
module Gem
|
21
|
+
# Adding Gems Java platform
|
22
|
+
module Platform
|
23
|
+
JAVA = 'java'
|
24
|
+
end
|
25
|
+
|
26
|
+
# Unfortunately Maven artifacts have a rather free versioning scheme
|
27
|
+
class Version
|
28
|
+
def self.correct?(str)
|
29
|
+
true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
begin
|
35
|
+
Gem.manage_gems
|
36
|
+
rescue NoMethodError => ex
|
37
|
+
# Using rubygems prior to 0.6.1
|
38
|
+
end
|
39
|
+
|
40
|
+
# Let the user add or redefine his sources (hopefully we'll be
|
41
|
+
# able to set a default one when a good soul will be able to
|
42
|
+
# donate us space and bandwidth to host a Raven Gems repository).
|
43
|
+
module Gem
|
44
|
+
def self.sources=(s)
|
45
|
+
@sources = s
|
46
|
+
end
|
47
|
+
end
|
48
|
+
require_gem("sources")
|
49
|
+
def sources; Gem.sources; end
|
50
|
+
def set_sources(s) Gem.sources = s; end
|
51
|
+
set_sources(["http://gems.rubyraven.org/"])
|
52
|
+
|
53
|
+
# To avoid polluting the regular Gem repository, we store our gems
|
54
|
+
# under the user home directory.
|
55
|
+
GEMS_IN_HOME = true
|
56
|
+
USER_HOME = ENV['HOME'] ? ENV['HOME'] : ENV['USERPROFILE'].gsub('\\', '/')
|
57
|
+
RAVEN_HOME = File.join(USER_HOME, '.raven')
|
58
|
+
FileUtils.mkdir(RAVEN_HOME) unless File.exist?(RAVEN_HOME)
|
59
|
+
Dir.glob(File.join(RAVEN_HOME, "specifications", "*.gemspec")).each do |file_name|
|
60
|
+
gemspec = Gem::SourceIndex.load_specification(file_name.untaint)
|
61
|
+
Gem::cache.add_spec(gemspec) if gemspec
|
62
|
+
end
|
63
|
+
|
64
|
+
module Gem
|
65
|
+
# Making the remote installer silent. Otherwise it always asks you to
|
66
|
+
# choose the version you want to install.
|
67
|
+
class RemoteInstaller
|
68
|
+
def find_gem_to_install(gem_name, version_requirement, caches)
|
69
|
+
specs_n_sources = []
|
70
|
+
caches.each do |source, cache|
|
71
|
+
cache.each do |name, spec|
|
72
|
+
if /^#{gem_name}$/i === spec.name &&
|
73
|
+
version_requirement.satisfied_by?(spec.version) then
|
74
|
+
specs_n_sources << [spec, source]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
if specs_n_sources.empty? then
|
79
|
+
raise GemNotFoundException.new("Could not find #{gem_name} (#{version_requirement}) in the repository")
|
80
|
+
end
|
81
|
+
specs_n_sources = specs_n_sources.sort_by { |gs,| gs.version }.reverse
|
82
|
+
specs_n_sources[0]
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/lib/raven/java_tasks.rb
CHANGED
@@ -56,6 +56,7 @@ module Raven
|
|
56
56
|
# Getting the source files to compile. Filtrating sources already
|
57
57
|
# compiled having a fresh enough class
|
58
58
|
source_files = @build_path.collect do |d|
|
59
|
+
puts "Warning: build path #{d} doesn't exist!" unless File.exist? d
|
59
60
|
Dir.glob("#{d}/**/*.java").select do |java|
|
60
61
|
classfile = 'target/classes/' + java[d.length, (java.length - 5 - d.length)] + '.class'
|
61
62
|
File.exist?(classfile) ? File.stat(java).mtime > File.stat(classfile).mtime : true
|
data/lib/raven/search_install.rb
CHANGED
@@ -70,7 +70,7 @@ module Raven
|
|
70
70
|
end
|
71
71
|
|
72
72
|
list_indices.each do |file|
|
73
|
-
http_fn, fs_fn = @base_url + file, RAVEN_HOME
|
73
|
+
http_fn, fs_fn = @base_url + file, File.join(RAVEN_HOME, file[0..-4])
|
74
74
|
|
75
75
|
# Checking file size to see if it changed
|
76
76
|
header = http.head(http_fn)
|
@@ -81,7 +81,7 @@ module Raven
|
|
81
81
|
puts "Refreshing index file #{file[0..-4]}"
|
82
82
|
response = StringIO.new(http.get(@base_url + file, nil).body)
|
83
83
|
zlib = Zlib::GzipReader.new(response)
|
84
|
-
file = File.new(RAVEN_HOME
|
84
|
+
file = File.new(File.join(RAVEN_HOME, file[0..-4]), 'wb')
|
85
85
|
file << zipsize + "\n"
|
86
86
|
file.write(zlib.read)
|
87
87
|
file.close
|
@@ -91,7 +91,7 @@ module Raven
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def search(artifactId, groupId=nil, versionId=nil)
|
94
|
-
idx_files = Dir[RAVEN_HOME
|
94
|
+
idx_files = Dir[File.join(RAVEN_HOME, '*.mvnidx')]
|
95
95
|
found = []
|
96
96
|
idx_files.each do |idx_file|
|
97
97
|
puts "Searching in #{idx_file}..."
|
@@ -260,4 +260,4 @@ module Raven
|
|
260
260
|
end
|
261
261
|
end
|
262
262
|
|
263
|
-
end
|
263
|
+
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.2.
|
7
|
-
date: 2007-
|
6
|
+
version: 1.2.3
|
7
|
+
date: 2007-05-12 00:00:00 -07:00
|
8
8
|
summary: Java build system based on Rake and Gem.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -32,12 +32,14 @@ files:
|
|
32
32
|
- bin/raven
|
33
33
|
- lib/raven
|
34
34
|
- lib/raven.rb
|
35
|
+
- lib/raven/deps_tasks.rb~
|
35
36
|
- lib/raven/index_gem_repository.rb
|
36
37
|
- lib/raven/deps_tasks.rb
|
37
38
|
- lib/raven/java_tasks.rb
|
38
39
|
- lib/raven/gem_init.rb
|
39
40
|
- lib/raven/repo_builder.rb
|
40
41
|
- lib/raven/search_install.rb
|
42
|
+
- lib/raven/gem_init.rb~
|
41
43
|
- README.rdoc
|
42
44
|
- LICENSE
|
43
45
|
test_files: []
|