bee_java 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/bin/gendeps CHANGED
@@ -18,7 +18,7 @@
18
18
 
19
19
  require 'erb'
20
20
 
21
- DEFAULT_REPOSITORY = 'http://mirrors.ibiblio.org/pub/mirrors/maven2'
21
+ DEFAULT_REPOSITORY = 'http://mirrors.ibiblio.org/maven2'
22
22
 
23
23
  TEMPLATE = ERB.new('- group: "<%= group %>"
24
24
  artifact: "<%= artifact %>"
data/build/README CHANGED
@@ -20,4 +20,4 @@ or go to URL http://www.apache.org/licenses/LICENSE-2.0).
20
20
 
21
21
  = Copyright
22
22
 
23
- Bee_java version 0.0.5 (C) Michel Casabianca - 2008-2012
23
+ Bee_java version 0.0.6 (C) Michel Casabianca - 2008-2012
@@ -1,4 +1,4 @@
1
- - repository: http://mirrors.ibiblio.org/pub/mirrors/maven2
1
+ - repository: http://mirrors.ibiblio.org/maven2
2
2
 
3
3
  - group: "junit"
4
4
  artifact: "junit"
@@ -3,6 +3,8 @@
3
3
  extends:
4
4
  - ":java:java.yml"
5
5
  - tomcat.yml
6
+ alias:
7
+ run: ~
6
8
 
7
9
  - properties:
8
10
  name: "<%= name %>"
@@ -1,4 +1,4 @@
1
- - repository: http://mirrors.ibiblio.org/pub/mirrors/maven2
1
+ - repository: http://mirrors.ibiblio.org/maven2
2
2
 
3
3
  - group: junit
4
4
  artifact: junit
data/egg/tiny/build.erb CHANGED
@@ -1,6 +1,8 @@
1
1
  - build: <%= name %>
2
2
  description: Build file for project <%= name.capitalize %>
3
3
  extends: ":java:java.yml"
4
+ alias:
5
+ test: ~
4
6
 
5
7
  - properties:
6
8
  name: "<%= name %>"
@@ -1,4 +1,4 @@
1
- - repository: http://mirrors.ibiblio.org/pub/mirrors/maven2
1
+ - repository: http://mirrors.ibiblio.org/maven2
2
2
 
3
3
  #- group: junit
4
4
  # artifact: junit
data/egg/xmlrpc/build.yml CHANGED
@@ -2,14 +2,14 @@
2
2
  description: Build file for project <%= name.capitalize %>
3
3
  extends:
4
4
  - ":java:java.yml"
5
+ alias:
6
+ test: ~
5
7
 
6
8
  - properties:
7
9
  name: "<%= name %>"
8
10
  version: "0.0.1"
9
11
  jv_main: "test.Server"
10
- jv_res:
11
- root: :jv_src
12
- includes: "**/*.properties"
12
+ jv_res: :jv_src
13
13
  client_main: "test.Client"
14
14
 
15
15
  - target: client
@@ -1,4 +1,4 @@
1
- - repository: http://mirrors.ibiblio.org/pub/mirrors/maven2
1
+ - repository: http://mirrors.ibiblio.org/maven2
2
2
 
3
3
  - group: org.apache.xmlrpc
4
4
  artifact: xmlrpc-common
data/java.yml CHANGED
@@ -28,14 +28,20 @@
28
28
  jv_classes: "#{jv_build_dir}/classes"
29
29
  # directory where are generated class files for unit tests
30
30
  jv_test_classes: "#{jv_build_dir}/test_classes"
31
+ # directories to add to compile classpath
32
+ jv_cp_comp_dirs: [:jv_classes]
33
+ # directories to add to test classpath
34
+ jv_cp_test_dirs: [:jv_classes, :jv_test_classes]
35
+ # directories to add to runtime classpath
36
+ jv_cp_run_dirs: [:jv_classes]
31
37
  # glob for unit tests to include
32
38
  jv_test_includes: ["**/*Test.java"]
33
39
  # glob for unit tests to exclude
34
40
  jv_test_excludes: []
35
41
  # directory where are resources to include in classpath
36
- jv_res: []
42
+ jv_res: ~
37
43
  # directory where are resources to include in test classpath
38
- jv_test_res: []
44
+ jv_test_res: ~
39
45
  # java main class to run
40
46
  jv_main: ~
41
47
  # command line arguments for main class
@@ -48,7 +54,9 @@
48
54
  jv_clean_dirs: [:jv_build_dir]
49
55
  # files to clean
50
56
  jv_clean_files: []
51
-
57
+ # JUnit version
58
+ jv_junit_version: '4'
59
+
52
60
  - target: jv_classpath
53
61
  description: Build Java compile, test and runtime classpath
54
62
  script:
@@ -56,18 +64,18 @@
56
64
  file: :jv_dep_file
57
65
  type: :jv_dep_type
58
66
  classpath: jv_compile_cp
59
- directories: :jv_classes
67
+ directories: :jv_cp_comp_dirs
60
68
  - java.classpath:
61
69
  file: :jv_dep_file
62
70
  type: :jv_dep_type
63
71
  classpath: jv_test_cp
64
- directories: [:jv_classes, :jv_test_classes]
72
+ directories: :jv_cp_test_dirs
65
73
  scope: test
66
74
  - java.classpath:
67
75
  file: :jv_dep_file
68
76
  type: :jv_dep_type
69
77
  classpath: jv_runtime_cp
70
- directories: :jv_classes
78
+ directories: :jv_cp_run_dirs
71
79
  scope: runtime
72
80
 
73
81
  - target: jv_compile
@@ -78,7 +86,7 @@
78
86
  src: :jv_src
79
87
  dest: :jv_classes
80
88
  classpath: :jv_compile_cp
81
- - if: jv_res
89
+ - if: defined?(jv_res) and File.exists?(jv_res)
82
90
  then:
83
91
  - copy:
84
92
  root: :jv_res
@@ -92,7 +100,7 @@
92
100
  src: :jv_test_src
93
101
  dest: :jv_test_classes
94
102
  classpath: :jv_test_cp
95
- - if: jv_test_res
103
+ - if: defined?(jv_test_res) and File.exists?(jv_test_res)
96
104
  then:
97
105
  - copy:
98
106
  root: :jv_test_res
@@ -107,6 +115,7 @@
107
115
  includes: :jv_test_includes
108
116
  excludes: :jv_test_excludes
109
117
  classpath: :jv_test_cp
118
+ version: :jv_junit_version
110
119
 
111
120
  - target: jv_run
112
121
  depends: jv_compile
data/lib/bee_task_java.rb CHANGED
@@ -349,6 +349,11 @@ module Bee
349
349
  # class files for classes under test and unit tests themselves.
350
350
  # - skip: tells if we should skip test. Optional, defaults to false.
351
351
  # - options: custom options to use on command line (optional).
352
+ # - version: the JUnit version (defaults to 4 and later). This may
353
+ # be important for 3 and earlier versions where runner is in
354
+ # 'junit.runner' package instead of 'org.junit.runner'. Note that
355
+ # for JUnit 3 and earlier, JUnit test runner will run once for
356
+ # each test class.
352
357
  #
353
358
  # Example
354
359
  #
@@ -366,7 +371,9 @@ module Bee
366
371
  :dependencies => { :mandatory => false, :type => :string_or_array },
367
372
  :skip => { :mandatory => false, :type => :boolean,
368
373
  :default => false },
369
- :options => { :mandatory => false, :type => :string }
374
+ :options => { :mandatory => false, :type => :string },
375
+ :version => { :mandatory => false, :type => :string,
376
+ :default => '4' }
370
377
  }
371
378
  check_parameters(params, params_desc)
372
379
  src = params[:src]
@@ -376,6 +383,7 @@ module Bee
376
383
  dependencies = params[:dependencies]
377
384
  skip = params[:skip]
378
385
  options = params[:options]
386
+ version = params[:version]
379
387
  for dir in src
380
388
  error "junit 'src' directory was not found" unless
381
389
  File.exists?(dir) and File.directory?(dir)
@@ -398,14 +406,31 @@ module Bee
398
406
  "\"#{file}\""
399
407
  end
400
408
  # run command line
401
- puts "Running JUnit on #{files.length} test file(s)"
402
- command = "java "
403
- command += "#{options} " if options
404
- command += "-classpath #{path} " if path
405
- command += "org.junit.runner.JUnitCore #{classes.join(' ')}"
406
- puts "Running command '#{command}'" if @verbose
407
- ok = system(command)
408
- error "Error running JUnit" unless ok
409
+ major_version = version.split('.')[0].to_i
410
+ if major_version > 3
411
+ main_class = 'org.junit.runner.JUnitCore'
412
+ puts "Running JUnit on #{files.length} test file(s)"
413
+ command = "java "
414
+ command += "#{options} " if options
415
+ command += "-classpath #{path} " if path
416
+ command += "#{main_class} #{classes.join(' ')}"
417
+ puts "Running command '#{command}'" if @verbose
418
+ ok = system(command)
419
+ error "Error running JUnit" unless ok
420
+ else
421
+ main_class = 'junit.textui.TestRunner'
422
+ for test_class in classes
423
+ puts "Running JUnit on '#{test_class}' test class"
424
+ command = "java "
425
+ command += "#{options} " if options
426
+ command += "-classpath #{path} " if path
427
+ command += "#{main_class} #{test_class}"
428
+ puts "Running command '#{command}'" if @verbose
429
+ ok = system(command)
430
+ error "Error running JUnit" unless ok
431
+ end
432
+ end
433
+ # run command line
409
434
  else
410
435
  puts "Skipping unit tests!!!"
411
436
  end
@@ -176,13 +176,13 @@ module Bee
176
176
  File.open(tofile, 'wb') { |file| file.write(binary) }
177
177
  end
178
178
 
179
- # Maximum number of HTTP redirections.
180
- HTTP_REDIRECTIONS_LIMIT = 10
179
+ # Maximum number of HTTP redirection.
180
+ HTTP_REDIRECTION_LIMIT = 10
181
181
 
182
182
  # Get a given URL.
183
183
  # - url: URL to get.
184
- # - limit: redirectrion limit (defaults to HTTP_REDIRECTIONS_LIMIT).
185
- def fetch(url, limit = HTTP_REDIRECTIONS_LIMIT)
184
+ # - limit: redirection limit (defaults to HTTP_REDIRECTION_LIMIT).
185
+ def fetch(url, limit = HTTP_REDIRECTION_LIMIT)
186
186
  puts "Fetching '#{url}'..." if @verbose
187
187
  raise 'HTTP redirect too deep' if limit == 0
188
188
  response = Net::HTTP.get_response(URI.parse(url))
@@ -190,7 +190,8 @@ module Bee
190
190
  when Net::HTTPSuccess
191
191
  response.body
192
192
  when Net::HTTPRedirection
193
- fetch(response['location'], limit - 1)
193
+ when Net::HTTPMovedPermanently
194
+ fetch(build_url(url, response['location']), limit - 1)
194
195
  else
195
196
  response.error!
196
197
  end
@@ -199,16 +200,21 @@ module Bee
199
200
  # Get a given URL and save body in a file.
200
201
  # - url: URL to get.
201
202
  # - file: the file where to save the body.
202
- # - limit: redirectrion limit (defaults to HTTP_REDIRECTIONS_LIMIT).
203
- def fetch_save(url, file, limit = HTTP_REDIRECTIONS_LIMIT)
203
+ # - limit: redirection limit (defaults to HTTP_REDIRECTION_LIMIT).
204
+ def fetch_save(url, file, limit = HTTP_REDIRECTION_LIMIT)
204
205
  puts "Fetching '#{url}'..." if @verbose
205
- raise 'HTTP redirect too deep' if limit == 0
206
+ raise 'HTTP redirect too deep' if limit <= 0
206
207
  directory = File.dirname(file)
207
208
  FileUtils.makedirs(directory) if not File.exists?(directory)
208
209
  uri = URI.parse(url)
209
- Net::HTTP.start(uri.host, uri.port) do |http|
210
+ Net::HTTP.start(uri.host, uri.port) do |http|
210
211
  http.request_get(uri.path) do |response|
211
- raise "Bad status code '#{response.code}'" if !response.is_a?(Net::HTTPSuccess)
212
+ if response.is_a?(Net::HTTPRedirection) or response.is_a?(Net::HTTPMovedPermanently)
213
+ fetch_save(build_url(url, response['location']), file, limit - 1)
214
+ return
215
+ elsif !response.is_a?(Net::HTTPSuccess)
216
+ raise "Bad status code '#{response.code}'"
217
+ end
212
218
  File.open(file,'wb') do |f|
213
219
  response.read_body do |segment|
214
220
  f.write(segment)
@@ -220,6 +226,15 @@ module Bee
220
226
  end
221
227
  end
222
228
 
229
+ def build_url(base, path)
230
+ if path =~ /^http:\/\//
231
+ return path
232
+ else
233
+ uri = URI(base)
234
+ return "#{uri.scheme}://#{uri.host}#{path}"
235
+ end
236
+ end
237
+
223
238
  end
224
239
 
225
240
  # Bee dependency resolver.
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bee_java
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michel Casabianca
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-09-04 00:00:00 Z
18
+ date: 2012-10-04 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: bee