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 +1 -1
- data/build/README +1 -1
- data/egg/lib/dependencies.yml +1 -1
- data/egg/servlet/build.yml +2 -0
- data/egg/servlet/dependencies.yml +1 -1
- data/egg/tiny/build.erb +2 -0
- data/egg/tiny/dependencies.yml +1 -1
- data/egg/xmlrpc/build.yml +3 -3
- data/egg/xmlrpc/dependencies.yml +1 -1
- data/java.yml +17 -8
- data/lib/bee_task_java.rb +34 -9
- data/lib/dependency_resolver.rb +25 -10
- metadata +4 -4
data/bin/gendeps
CHANGED
data/build/README
CHANGED
data/egg/lib/dependencies.yml
CHANGED
data/egg/servlet/build.yml
CHANGED
data/egg/tiny/build.erb
CHANGED
data/egg/tiny/dependencies.yml
CHANGED
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
|
data/egg/xmlrpc/dependencies.yml
CHANGED
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: :
|
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:
|
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: :
|
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
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
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
|
data/lib/dependency_resolver.rb
CHANGED
@@ -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
|
180
|
-
|
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:
|
185
|
-
def fetch(url, 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
|
-
|
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:
|
203
|
-
def fetch_save(url, file, 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
|
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
|
-
|
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:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
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-
|
18
|
+
date: 2012-10-04 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: bee
|