raven 1.2.3 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,7 +31,7 @@ module FileUtils
31
31
  end
32
32
 
33
33
  module Raven
34
- CP_SEP = PLATFORM['mswin'] ? ';' : ':'
34
+ CP_SEP = File::PATH_SEPARATOR
35
35
 
36
36
  # Executes Javac by passing it everything it needs. Stuff like a
37
37
  # classpath and sources. The classpath is built by checking the
@@ -91,15 +91,14 @@ module Raven
91
91
  # The JUnit task runs all your test cases located in src/test/java or the
92
92
  # build_path that you can set. JUnit inherits from the JavacTask so it
93
93
  # accepts every configuration that JavacTask accepts. In addition you can
94
- # provide an array containing your test classes (default pattern is **/Test*.java).
94
+ # add a pattern for your test classes (default pattern is **/Test*.java).
95
95
  class JUnitTask < JavacTask
96
96
  def execute
97
97
  @build_path = ["src/test/java"] unless @build_path
98
98
  super
99
- unless @test_classes
100
- tests = @build_path.collect { |d| Dir.glob("#{d}/**/Test*.java").collect { |sd| sd[d.size+1..-1] } }
101
- @test_classes = tests.flatten.collect { |d| d.gsub('/', '.')[0..-6] }
102
- end
99
+ pattern = (@test_classes.nil? || @test_classes.empty?) ? "**/Test*.java" : @test_classes.first
100
+ tests = @build_path.collect { |d| Dir.glob("#{d}/#{pattern}").collect { |sd| sd[d.size+1..-1] } }
101
+ @test_classes = tests.flatten.collect { |d| d.gsub('/', '.')[0..-6] }
103
102
  failures = false
104
103
  @test_classes.flatten.each do |tc|
105
104
  puts "Running test #{tc}"
@@ -368,18 +367,22 @@ module Raven
368
367
  def self.mk_libs(target, prereq)
369
368
  Raven.mkdir_recurse(target)
370
369
  Raven.prereq_filter(prereq, :gem_deps) do |dep_task|
371
- dep_task.gem_deps.each do |gempath|
372
- Dir.foreach(gempath + '/ext') do |file|
373
- next if file == '.' || file == '..'
374
- FileUtils.copy(gempath + '/ext/' + file, target)
370
+ if (dep_task.gem_deps)
371
+ dep_task.gem_deps.each do |gempath|
372
+ Dir.foreach(gempath + '/ext') do |file|
373
+ next if file == '.' || file == '..'
374
+ FileUtils.copy(gempath + '/ext/' + file, target)
375
+ end
375
376
  end
376
377
  end
377
- dep_task.libs.flatten.each do |libpath|
378
- FileUtils.copy(libpath, target)
378
+ if (dep_task.libs)
379
+ dep_task.libs.flatten.each do |libpath|
380
+ FileUtils.copy(libpath, target)
381
+ end
379
382
  end
380
383
  end
381
384
  end
382
-
385
+
383
386
  # Duck typing selection of prerequisites
384
387
  def self.prereq_filter(prerequisites, respond_to)
385
388
  prerequisites.each do |prereq|
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
2
+ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: raven
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.2.3
7
- date: 2007-05-12 00:00:00 -07:00
6
+ version: 1.2.4
7
+ date: 2007-12-02 00:00:00 -08:00
8
8
  summary: Java build system based on Rake and Gem.
9
9
  require_paths:
10
10
  - lib
@@ -30,16 +30,14 @@ authors:
30
30
  - Matthieu Riou
31
31
  files:
32
32
  - bin/raven
33
- - lib/raven
34
33
  - lib/raven.rb
35
- - lib/raven/deps_tasks.rb~
36
- - lib/raven/index_gem_repository.rb
37
- - lib/raven/deps_tasks.rb
34
+ - lib/raven
35
+ - lib/raven/repo_builder.rb
38
36
  - lib/raven/java_tasks.rb
39
37
  - lib/raven/gem_init.rb
40
- - lib/raven/repo_builder.rb
38
+ - lib/raven/index_gem_repository.rb
39
+ - lib/raven/deps_tasks.rb
41
40
  - lib/raven/search_install.rb
42
- - lib/raven/gem_init.rb~
43
41
  - README.rdoc
44
42
  - LICENSE
45
43
  test_files: []
@@ -1,182 +0,0 @@
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
@@ -1,85 +0,0 @@
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