raven 1.2 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -57,14 +57,17 @@ module Raven
57
57
  rel_url = match[2]
58
58
  rel_url = rel_url + '/' if rel_url[-1..-1] != '/'
59
59
  else
60
- server = 'www.ibiblio.org'
60
+ # Use the default maven2 repository.
61
+ # Info on maven2 mirrors can be found here:
62
+ # http://maven.apache.org/guides/mini/guide-mirror-settings.html
63
+ server = 'repo1.maven.org'
61
64
  rel_url = '/maven2/'
62
65
  end
63
- puts "Using server #{server} and url #{rel_url}"
66
+ puts "Connecting to Maven2 repository at http://#{server}#{rel_url}."
64
67
  builder = Raven::GemRepoBuilder.new(server, 80, rel_url, Raven::Command.parse_proxy(proxy_url))
65
68
  if (rest.size > 1)
66
69
  rest.shift
67
- puts "Packages #{rest}"
70
+ puts "Packages: #{rest.join(' ')}"
68
71
  builder.group_filters = rest
69
72
  end
70
73
  builder.build
@@ -136,4 +139,4 @@ module Raven
136
139
  end
137
140
  end
138
141
  end
139
- end
142
+ end
@@ -54,6 +54,14 @@ module Raven
54
54
  #
55
55
  # See also Raven::MavenLocalRepoImport and Raven::GemRepoBuilder to
56
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
57
65
  class DependencyTask < Rake::Task
58
66
  attr_reader :gem_deps
59
67
 
@@ -84,6 +92,13 @@ module Raven
84
92
  def deps
85
93
  @deps ||= []
86
94
  end
95
+
96
+ def libs
97
+ @libs ||= []
98
+ end
99
+ def libs=(l)
100
+ @libs = l
101
+ end
87
102
  end
88
103
 
89
104
  # Calls Gem installer to install a Gem (very predictible behaviour).
@@ -87,6 +87,10 @@ module Raven
87
87
  end
88
88
  end
89
89
 
90
+ # The JUnit task runs all your test cases located in src/test/java or the
91
+ # build_path that you can set. JUnit inherits from the JavacTask so it
92
+ # accepts every configuration that JavacTask accepts. In addition you can
93
+ # provide an array containing your test classes (default pattern is **/Test*.java).
90
94
  class JUnitTask < JavacTask
91
95
  def execute
92
96
  @build_path = ["src/test/java"] unless @build_path
@@ -290,9 +294,9 @@ module Raven
290
294
  # group name default to the current directory name and its parent
291
295
  # directory name respectively. Convenient if you follow the classic
292
296
  # project/module directory structure. Otherwise, just set the
293
- # <em>artifact</em> and <em>group</em> to any value that suits you.
297
+ # <em>artifact</em> and <em>project</em> to any value that suits you.
294
298
  class GemWrapTask < Rake::Task
295
- attr_writer :version, :artifact, :group
299
+ attr_writer :version, :artifact, :project
296
300
 
297
301
  def execute
298
302
  super
@@ -343,12 +347,17 @@ module Raven
343
347
  def self.build_cp(prerequisites)
344
348
  classpath = []
345
349
  Raven.prereq_filter(prerequisites, :gem_deps) do |dep_task|
346
- dep_task.gem_deps.each do |gempath|
347
- Dir.foreach(gempath + '/ext') do |file|
348
- next if file == '.' || file == '..'
349
- classpath << gempath + '/ext/' + file
350
+ if (dep_task.gem_deps)
351
+ dep_task.gem_deps.each do |gempath|
352
+ Dir.foreach(gempath + '/ext') do |file|
353
+ next if file == '.' || file == '..'
354
+ classpath << gempath + '/ext/' + file
355
+ end
350
356
  end
351
357
  end
358
+ if (dep_task.libs)
359
+ classpath.concat(dep_task.libs.flatten)
360
+ end
352
361
  end
353
362
  classpath
354
363
  end
@@ -364,6 +373,9 @@ module Raven
364
373
  FileUtils.copy(gempath + '/ext/' + file, target)
365
374
  end
366
375
  end
376
+ dep_task.libs.flatten.each do |libpath|
377
+ FileUtils.copy(libpath, target)
378
+ end
367
379
  end
368
380
  end
369
381
 
@@ -96,11 +96,26 @@ module Raven
96
96
 
97
97
  def read_page(http, url, regexp, start=51, crop=4)
98
98
  response = http.get(url, nil)
99
- if response.message == "OK"
99
+ if response.is_a? Net::HTTPSuccess
100
100
  response.body.scan(regexp) do |line|
101
101
  groupId = line[start..(line.length - crop)]
102
102
  yield(url, groupId)
103
103
  end
104
+ else
105
+ STDERR.puts "Error connecting to repository: #{response.message}"
106
+ if response.is_a?(Net::HTTPRedirection) && response["location"]
107
+ puts "Location: #{response['location']}"
108
+ else
109
+ puts "------ RESPONSE CODE -----------------------------"
110
+ puts "Response code: #{response.code}"
111
+ puts "------ HEADERS -----------------------------------"
112
+ response.each_header do |key, value|
113
+ puts "#{key}: #{value}"
114
+ end
115
+ puts "------ CONTENT -----------------------------------"
116
+ puts response.body
117
+ puts '-' * 50
118
+ end
104
119
  end
105
120
  end
106
121
  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: 2006-12-18 00:00:00 -08:00
6
+ version: 1.2.1
7
+ date: 2007-01-11 00:00:00 -08:00
8
8
  summary: Java build system based on Rake and Gem.
9
9
  require_paths:
10
10
  - lib
@@ -33,7 +33,6 @@ files:
33
33
  - bin/raven
34
34
  - lib/raven
35
35
  - lib/raven.rb
36
- - lib/raven/java_tasks.rb~
37
36
  - lib/raven/deps_tasks.rb
38
37
  - lib/raven/gem_init.rb
39
38
  - lib/raven/java_tasks.rb
@@ -1,459 +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 'rake'
18
- require 'fileutils'
19
- require 'set'
20
-
21
- # Monkey patching FileUtils to support filtering in copy.
22
- module FileUtils
23
- class Entry_
24
- alias original copy
25
- def copy(dest)
26
- unless path['.svn'] || path['.cvs']
27
- original(dest)
28
- end
29
- end
30
- end
31
- end
32
-
33
- module Raven
34
- CP_SEP = PLATFORM['mswin'] ? ';' : ':'
35
-
36
- # Executes Javac by passing it everything it needs. Stuff like a
37
- # classpath and sources. The classpath is built by checking the
38
- # prerequisites of the javac task. When a prerequisite is a dependency
39
- # declaration (dependency task), it takes each declared Gems and
40
- # adds the jar files found in them to the classpath.
41
- #
42
- # Can be customized by adding directories to the <em>build_path</em>
43
- # using the << operator (if none defined, default is src/main/java).
44
- class JavacTask < Rake::Task
45
-
46
- def execute
47
- super
48
- @classpath = Raven.build_cp(prerequisites)
49
- @classpath << "target/classes"
50
- @build_path = ["src/main/java"] unless @build_path
51
-
52
- puts "Building path #{@build_path.join(' ')}" if RakeFileUtils.verbose_flag
53
-
54
- Dir.mkdir("target") unless File.exist?("target")
55
- Dir.mkdir("target/classes") unless File.exist?("target/classes")
56
- # Getting the source files to compile. Filtrating sources already
57
- # compiled having a fresh enough class
58
- source_files = @build_path.collect do |d|
59
- Dir.glob("#{d}/**/*.java").select do |java|
60
- classfile = 'target/classes/' + java[d.length, (java.length - 5 - d.length)] + '.class'
61
- File.exist?(classfile) ? File.stat(java).mtime > File.stat(classfile).mtime : true
62
- end
63
- end.flatten
64
-
65
- if (source_files.size > 0)
66
- # Getting only package names, it shortens the command line
67
- source_pkg = Set.new
68
- source_files.each { |src| source_pkg << File.join(File.dirname(src), '*.java') }
69
- # Executing javac
70
- puts "javac -classpath \"#{@classpath.join(CP_SEP)}\" -sourcepath \"#{@build_path.join(CP_SEP)}\" -d target/classes #{source_pkg.to_a.join(' ')}" if RakeFileUtils.verbose_flag
71
- `javac -classpath "#{@classpath.join(CP_SEP)}" -sourcepath "#{@build_path.join(CP_SEP)}" -d target/classes #{source_pkg.to_a.join(' ')}`
72
- unless $?.exitstatus == 0
73
- puts "Build failed, see above errors."
74
- exit
75
- end
76
- else
77
- puts 'All class files are up to date.' if RakeFileUtils.verbose_flag
78
- end
79
- end
80
-
81
- def build_path
82
- @build_path ||= []
83
- end
84
-
85
- def build_path=(p)
86
- @build_path = [p]
87
- end
88
- end
89
-
90
- class JUnitTask < JavacTask
91
- def execute
92
- @build_path = ["src/test/java"] unless @build_path
93
- super
94
- unless @test_classes
95
- puts "IN"
96
- tests = @build_path.collect { |d| Dir.glob("#{d}/**/Test*.java").collect { |sd| sd[d.size+1..-1] } }
97
- puts tests
98
- @test_classes = tests.flatten.collect { |d| d.gsub('/', '.')[0..-6] }
99
- puts @test_classes
100
- end
101
- failures = false
102
- @test_classes.flatten.each do |tc|
103
- puts "Running test #{tc}"
104
- result = `java -classpath "#{@classpath.join(CP_SEP)}" junit.textui.TestRunner #{tc}`
105
- puts result
106
- failures = true if /FAILURES/ =~ result || /ERRORS/ =~ result
107
- end
108
- if failures
109
- puts "There were failures!"
110
- exit(1)
111
- end
112
- end
113
-
114
- def test_classes
115
- @test_classes ||= []
116
- end
117
-
118
- def test_classes=(c)
119
- @test_classes = [c]
120
- end
121
- end
122
-
123
- # Builds a jar file from your compiled sources. The jarfile produced
124
- # will have the same name as your jar task.
125
- class JarTask < Rake::Task
126
- def execute
127
- super
128
- latest = Raven.latest_file('target/classes')
129
-
130
- # Manifest inclusion
131
- mfest_param = @manifest ? "-m #{@manifest}" : ""
132
-
133
- if !File.exist?("target/#{name}") || File.stat("target/#{name}").mtime < latest
134
- `jar -cf target/#{name} #{mfest_param} -C target/classes .`
135
- puts "Built jar file #{name}." if RakeFileUtils.verbose_flag
136
- else
137
- puts 'Nothing to do, jar is fresh enough.' if RakeFileUtils.verbose_flag
138
- end
139
- end
140
-
141
- def manifest=(f)
142
- @manifest = f
143
- end
144
- end
145
-
146
- # Builds a jar file from your sources. Customized by adding directories
147
- # to the <em>source_path</em> just like the JavacTask.
148
- class JarSourceTask < Rake::Task
149
- def execute
150
- super
151
- # Checking if any of our prerequisites is a JavacTask, if
152
- # so we'll just use the build path to construct the jar.
153
- Raven.prereq_filter(prerequisites, :build_path) do |javac_task|
154
- (@source_path ||= []) << javac_task.build_path
155
- end
156
-
157
- # Initializing source path
158
- @source_path = ["src/main/java"] unless @source_path
159
- @source_path.flatten!
160
-
161
- latest = Time.at(0)
162
- @source_path.each do |dir|
163
- dir_latest = Raven.latest_file(dir)
164
- latest = dir_latest if dir_latest > latest
165
- end
166
-
167
- # Manifest inclusion
168
- mfest_param = @manifest ? "-m #{@manifest}" : ""
169
-
170
- # Building the jar from all sources
171
- if !File.exist?("target/#{name}") || File.stat("target/#{name}").mtime < latest
172
- `jar -cf target/#{name} #{mfest_param} -C #{@source_path.pop} .`
173
- while (p = @source_path.pop)
174
- `jar -uf target/#{name} -C #{p} .`
175
- end
176
- end
177
- end
178
-
179
- def source_path
180
- @source_path ||= []
181
- end
182
-
183
- def manifest=(f)
184
- @manifest = f
185
- end
186
- end
187
-
188
- # Produces a WAR from a web application directory. Includes the libraries
189
- # needed in WEB-INF/lib (as long as the corresponding dependency task is
190
- # declared as a prerequisite) and the compiled classes (if there are).
191
- #
192
- # Can be customized by setting <em>webapp_dir</em> to the directory
193
- # containing your web application resources (web.xml, jsp, images, ...).
194
- # The default is src/main/webapp.
195
- class WarTask < Rake::Task
196
- DEFAULT_TARGET = 'target/webapp/'
197
- LIB_SUBDIR = 'WEB-INF/lib/'
198
- CLASSES_SUBDIR = 'WEB-INF/classes/'
199
-
200
- def execute
201
- super
202
-
203
- # Build target structure
204
- @webapp_dir = @webapp_dir || 'src/main/webapp'
205
- Raven.mkdir_recurse(DEFAULT_TARGET)
206
-
207
- puts "Using web application directory #{@webapp_dir}" if RakeFileUtils.verbose_flag
208
-
209
- FileUtils.cp_r(@webapp_dir, DEFAULT_TARGET)
210
-
211
- # Eventually add classes compiled by javac
212
- if (File.exist?('target/classes'))
213
- Raven.mkdir_recurse(DEFAULT_TARGET + CLASSES_SUBDIR)
214
- FileUtils.cp_r('target/classes/.', DEFAULT_TARGET + CLASSES_SUBDIR)
215
- end
216
-
217
- # Make lib directory with all dependencies
218
- Raven.mkdir_recurse(DEFAULT_TARGET + LIB_SUBDIR)
219
- Raven.mk_libs(DEFAULT_TARGET + LIB_SUBDIR, prerequisites)
220
-
221
- # Build the war
222
- `jar -cf target/#{name} -C #{DEFAULT_TARGET} .`
223
- end
224
-
225
- def webapp_dir=(param)
226
- @webapp_dir = param
227
- end
228
- end
229
-
230
- # Places all the dependencies in a given directory (useful mostly to
231
- # build a distribution). The dependencies are selected from the
232
- # prerequisites (using declared dependency tasks). The default
233
- # directory is lib. Can be customized by setting <em>target</em>.
234
- class LibDirTask < Rake::Task
235
- def execute
236
- super
237
- puts "Copying libraries in #{@target}" if RakeFileUtils.verbose_flag
238
- @target = @target || 'lib'
239
- Raven.mk_libs(@target, prerequisites)
240
- end
241
-
242
- def target=(param)
243
- @target = param
244
- end
245
- end
246
-
247
- # Executes JavaDoc by passing it everything it needs. Stuff like a
248
- # classpath and sources. The result is generated in target/jdoc. Can
249
- # be customized exactly in the same way as the javac task.
250
- class JavaDocTask < Rake::Task
251
-
252
- def execute
253
- super
254
- classpath = Raven.build_cp(prerequisites)
255
- classpath << "target/classes"
256
- @build_path = ["src/main/java"] unless @build_path
257
-
258
- puts "Executing JavaDoc using source path #{@build_path.join(' ')}" if RakeFileUtils.verbose_flag
259
-
260
- Dir.mkdir("target") unless File.exist?("target")
261
- Dir.mkdir("target/jdoc") unless File.exist?("target/jdoc")
262
-
263
- packages = Set[]
264
- @build_path.each do |d|
265
- Dir.glob("#{d}/**/*.java").each do |java|
266
- packages << java[(d.length + 1)..(java.rindex('/') - 1)].gsub(%r{[\\/]}, '.')
267
- end
268
- end
269
- packages = packages.to_a
270
-
271
- if (packages.size > 0)
272
- puts "javadoc -classpath #{classpath.join(CP_SEP)} -sourcepath #{@build_path.join(CP_SEP)} -d target/jdoc #{packages.join(' ')}" if RakeFileUtils.verbose_flag
273
- `javadoc -classpath #{classpath.join(CP_SEP)} -sourcepath #{@build_path.join(CP_SEP)} -d target/jdoc #{packages.join(' ')}`
274
- unless $?.exitstatus == 0
275
- puts "Javadoc failed, see above errors."
276
- exit
277
- end
278
- end
279
- end
280
-
281
- def build_path
282
- @build_path ||= []
283
- end
284
-
285
- def build_path=(p)
286
- @build_path = [p]
287
- end
288
- end
289
-
290
- # Wraps a jar file around a Gem. Useful for distributing it around.
291
- # The jar is taken from the target directory. You must at least
292
- # specify <em>version</em> to produce the Gem. The artifact name and
293
- # group name default to the current directory name and its parent
294
- # directory name respectively. Convenient if you follow the classic
295
- # project/module directory structure. Otherwise, just set the
296
- # <em>artifact</em> and <em>group</em> to any value that suits you.
297
- class GemWrapTask < Rake::Task
298
- attr_writer :version, :artifact, :group
299
-
300
- def execute
301
- super
302
- puts "Wrapping jar in a Gem" if RakeFileUtils.verbose_flag
303
- unless @version
304
- puts "A version must be provided to produce a Gem!"
305
- end
306
- pwd = Dir.pwd
307
- @artifact = pwd[(pwd.rindex('/') + 1)..pwd.length] unless @artifact
308
- pwd = pwd[0..pwd.rindex('/') - 1]
309
- @group = pwd[(pwd.rindex('/') + 1)..pwd.length] unless @group
310
- Raven.mkdir_recurse('target/gem/ext')
311
- FileUtils.cp(Dir.glob('target/*.jar'), 'target/gem/ext')
312
-
313
- Dir.chdir('target/gem') do
314
- spec = Gem::Specification.new do |s|
315
- s.platform = Gem::Platform::JAVA
316
- s.summary = "Raven wrapped library #{@artifact} from project #{@group}."
317
- s.name = "#{@group}-#{@artifact}"
318
- s.version = @version
319
- s.requirements << 'none'
320
- s.require_path = 'ext'
321
- s.autorequire = 'rake'
322
- s.files = Dir.glob("{ext}/**/*")
323
- end
324
- Gem::Builder.new(spec).build
325
- end
326
- FileUtils.mv("target/gem/#{@group}-#{@artifact}-#{@version}-java.gem", 'target')
327
- end
328
- end
329
-
330
- # Wraps a jar file around a Gem and automatically installs it in your
331
- # local Gem repository. See the gem wrap task for more info (same rules
332
- # apply).
333
- class GemInstallTask < GemWrapTask
334
- def execute
335
- super
336
- params = [false]
337
- params << RAVEN_HOME if defined?(GEMS_IN_HOME)
338
- Gem::Installer.new("target/#{@group}-#{@artifact}-#{@version}-java.gem").install(*params)
339
- end
340
- end
341
-
342
- private
343
-
344
- # Builds the classpath by getting the path to the jars bundled
345
- # in each gem dependency.
346
- def self.build_cp(prerequisites)
347
- classpath = []
348
- Raven.prereq_filter(prerequisites, :gem_deps) do |dep_task|
349
- dep_task.gem_deps.each do |gempath|
350
- Dir.foreach(gempath + '/ext') do |file|
351
- next if file == '.' || file == '..'
352
- classpath << gempath + '/ext/' + file
353
- end
354
- end
355
- end
356
- classpath
357
- end
358
-
359
- # Copies the jars corresponding to each Gem dependency to a given
360
- # directory.
361
- def self.mk_libs(target, prereq)
362
- Raven.mkdir_recurse(target)
363
- Raven.prereq_filter(prereq, :gem_deps) do |dep_task|
364
- dep_task.gem_deps.each do |gempath|
365
- Dir.foreach(gempath + '/ext') do |file|
366
- next if file == '.' || file == '..'
367
- FileUtils.copy(gempath + '/ext/' + file, target)
368
- end
369
- end
370
- end
371
- end
372
-
373
- # Duck typing selection of prerequisites
374
- def self.prereq_filter(prerequisites, respond_to)
375
- prerequisites.each do |prereq|
376
- prereq_task = Rake::Task[prereq]
377
- if prereq_task.respond_to?(respond_to)
378
- yield(prereq_task)
379
- end
380
- end
381
- end
382
-
383
- # Recursively creates a directory
384
- def self.mkdir_recurse(dir)
385
- if dir.rindex('/')
386
- parent = dir[0, dir.rindex('/')]
387
- mkdir_recurse(parent) unless File.exist?(parent)
388
- end
389
- Dir.mkdir(dir) unless File.exist?(dir)
390
- end
391
-
392
- # Receursively browse a directory yielding on each file found.
393
- def self.browse_files(root)
394
- queue = [root]
395
- while !queue.empty?
396
- filename = queue.pop
397
- if File.file?(filename)
398
- yield(filename)
399
- else
400
- Dir.new(filename).each do |child|
401
- unless ['..', '.', '.svn', '.cvs'].include?(child)
402
- queue.push(filename + "/" + child)
403
- end
404
- end
405
- end
406
- end
407
- end
408
-
409
- # Returns the latest file timestamp in a directory structure
410
- def self.latest_file(dir)
411
- latest = Time.at(0)
412
- Raven.browse_files(dir) do |f|
413
- change = File.stat(f).mtime
414
- latest = change if change > latest
415
- end
416
- latest
417
- end
418
-
419
- end
420
-
421
-
422
- # Shortcut to the Javac task creation. Makes it handy.
423
- def javac(args, &block)
424
- Raven::JavacTask.define_task(args, &block)
425
- end
426
-
427
- # Shortcut to jar. Only 3 letters, isn't that beautiful?
428
- def jar(args, &block)
429
- Raven::JarTask.define_task(args, &block)
430
- end
431
-
432
- # I think you've got it now.
433
- def jar_source(args, &block)
434
- Raven::JarSourceTask.define_task(args, &block)
435
- end
436
-
437
- def junit(args, &block)
438
- Raven::JUnitTask.define_task(args, &block)
439
- end
440
-
441
- def lib_dir(args, &block)
442
- Raven::LibDirTask.define_task(args, &block)
443
- end
444
-
445
- def war(args, &block)
446
- Raven::WarTask.define_task(args, &block)
447
- end
448
-
449
- def javadoc(args, &block)
450
- Raven::JavaDocTask.define_task(args, &block)
451
- end
452
-
453
- def gem_wrap(args, &block)
454
- Raven::GemWrapTask.define_task(args, &block)
455
- end
456
-
457
- def gem_wrap_inst(args, &block)
458
- Raven::GemInstallTask.define_task(args, &block)
459
- end