buildr 1.3.2-java → 1.3.3-java
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.
- data/CHANGELOG +66 -4
- data/{README → README.rdoc} +29 -16
- data/Rakefile +16 -20
- data/_buildr +38 -0
- data/addon/buildr/cobertura.rb +49 -45
- data/addon/buildr/emma.rb +238 -0
- data/addon/buildr/jetty.rb +1 -1
- data/addon/buildr/nailgun.rb +585 -661
- data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail.class +0 -0
- data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail.java +0 -0
- data/bin/buildr +9 -2
- data/buildr.buildfile +53 -0
- data/buildr.gemspec +21 -14
- data/doc/css/default.css +51 -48
- data/doc/css/print.css +60 -55
- data/doc/images/favicon.png +0 -0
- data/doc/images/growl-icon.tiff +0 -0
- data/doc/images/project-structure.png +0 -0
- data/doc/pages/artifacts.textile +46 -156
- data/doc/pages/building.textile +63 -323
- data/doc/pages/contributing.textile +112 -102
- data/doc/pages/download.textile +19 -27
- data/doc/pages/extending.textile +27 -81
- data/doc/pages/getting_started.textile +44 -119
- data/doc/pages/index.textile +26 -47
- data/doc/pages/languages.textile +407 -0
- data/doc/pages/more_stuff.textile +92 -173
- data/doc/pages/packaging.textile +71 -239
- data/doc/pages/projects.textile +58 -233
- data/doc/pages/recipes.textile +19 -43
- data/doc/pages/settings_profiles.textile +39 -104
- data/doc/pages/testing.textile +41 -304
- data/doc/pages/troubleshooting.textile +29 -47
- data/doc/pages/whats_new.textile +69 -167
- data/doc/print.haml +0 -1
- data/doc/print.toc.yaml +1 -0
- data/doc/scripts/buildr-git.rb +1 -1
- data/doc/site.haml +1 -0
- data/doc/site.toc.yaml +8 -5
- data/{KEYS → etc/KEYS} +0 -0
- data/etc/git-svn-authors +16 -0
- data/lib/buildr.rb +2 -5
- data/lib/buildr/core/application.rb +192 -98
- data/lib/buildr/core/build.rb +140 -91
- data/lib/buildr/core/checks.rb +5 -5
- data/lib/buildr/core/common.rb +1 -1
- data/lib/buildr/core/compile.rb +12 -10
- data/lib/buildr/core/filter.rb +151 -46
- data/lib/buildr/core/generate.rb +9 -9
- data/lib/buildr/core/progressbar.rb +1 -1
- data/lib/buildr/core/project.rb +8 -7
- data/lib/buildr/core/test.rb +51 -26
- data/lib/buildr/core/transports.rb +22 -38
- data/lib/buildr/core/util.rb +78 -26
- data/lib/buildr/groovy.rb +18 -0
- data/lib/buildr/groovy/bdd.rb +105 -0
- data/lib/buildr/groovy/compiler.rb +138 -0
- data/lib/buildr/ide/eclipse.rb +102 -71
- data/lib/buildr/ide/idea.rb +7 -12
- data/lib/buildr/ide/idea7x.rb +7 -8
- data/lib/buildr/java.rb +4 -7
- data/lib/buildr/java/ant.rb +26 -5
- data/lib/buildr/java/bdd.rb +449 -0
- data/lib/buildr/java/commands.rb +9 -9
- data/lib/buildr/java/{compilers.rb → compiler.rb} +8 -90
- data/lib/buildr/java/jruby.rb +29 -11
- data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
- data/lib/buildr/java/packaging.rb +23 -16
- data/lib/buildr/java/pom.rb +1 -1
- data/lib/buildr/java/rjb.rb +21 -8
- data/lib/buildr/java/test_result.rb +308 -0
- data/lib/buildr/java/tests.rb +324 -0
- data/lib/buildr/packaging/artifact.rb +12 -11
- data/lib/buildr/packaging/artifact_namespace.rb +7 -4
- data/lib/buildr/packaging/gems.rb +3 -3
- data/lib/buildr/packaging/zip.rb +13 -10
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/scala.rb +19 -0
- data/lib/buildr/scala/compiler.rb +109 -0
- data/lib/buildr/scala/tests.rb +203 -0
- data/rakelib/apache.rake +71 -45
- data/rakelib/doc.rake +2 -2
- data/rakelib/package.rake +3 -2
- data/rakelib/rspec.rake +23 -21
- data/rakelib/setup.rake +34 -9
- data/rakelib/stage.rake +4 -1
- data/spec/addon/cobertura_spec.rb +77 -0
- data/spec/addon/emma_spec.rb +120 -0
- data/spec/addon/test_coverage_spec.rb +255 -0
- data/spec/{application_spec.rb → core/application_spec.rb} +82 -4
- data/spec/{artifact_namespace_spec.rb → core/artifact_namespace_spec.rb} +12 -1
- data/spec/core/build_spec.rb +415 -0
- data/spec/{checks_spec.rb → core/checks_spec.rb} +2 -2
- data/spec/{common_spec.rb → core/common_spec.rb} +119 -30
- data/spec/{compile_spec.rb → core/compile_spec.rb} +17 -13
- data/spec/core/generate_spec.rb +33 -0
- data/spec/{project_spec.rb → core/project_spec.rb} +9 -6
- data/spec/{test_spec.rb → core/test_spec.rb} +222 -28
- data/spec/{transport_spec.rb → core/transport_spec.rb} +5 -9
- data/spec/groovy/bdd_spec.rb +80 -0
- data/spec/{groovy_compilers_spec.rb → groovy/compiler_spec.rb} +1 -1
- data/spec/ide/eclipse_spec.rb +243 -0
- data/spec/{java_spec.rb → java/ant.rb} +7 -17
- data/spec/java/bdd_spec.rb +358 -0
- data/spec/{java_compilers_spec.rb → java/compiler_spec.rb} +1 -1
- data/spec/java/java_spec.rb +88 -0
- data/spec/{java_packaging_spec.rb → java/packaging_spec.rb} +65 -4
- data/spec/{java_test_frameworks_spec.rb → java/tests_spec.rb} +31 -10
- data/spec/{archive_spec.rb → packaging/archive_spec.rb} +12 -2
- data/spec/{artifact_spec.rb → packaging/artifact_spec.rb} +12 -5
- data/spec/{packaging_helper.rb → packaging/packaging_helper.rb} +0 -0
- data/spec/{packaging_spec.rb → packaging/packaging_spec.rb} +1 -1
- data/spec/sandbox.rb +22 -5
- data/spec/{scala_compilers_spec.rb → scala/compiler_spec.rb} +1 -1
- data/spec/{scala_test_frameworks_spec.rb → scala/tests_spec.rb} +11 -12
- data/spec/spec_helpers.rb +38 -17
- metadata +93 -70
- data/lib/buildr/java/bdd_frameworks.rb +0 -265
- data/lib/buildr/java/groovyc.rb +0 -137
- data/lib/buildr/java/test_frameworks.rb +0 -450
- data/spec/build_spec.rb +0 -193
- data/spec/java_bdd_frameworks_spec.rb +0 -238
- data/spec/spec.opts +0 -6
data/lib/buildr/ide/idea.rb
CHANGED
|
@@ -39,12 +39,6 @@ module Buildr
|
|
|
39
39
|
idea = project.task("idea")
|
|
40
40
|
# We need paths relative to the top project's base directory.
|
|
41
41
|
root_path = lambda { |p| f = lambda { |p| p.parent ? f[p.parent] : p.base_dir }; f[p] }[project]
|
|
42
|
-
# We want the Eclipse files changed every time the Buildfile changes, but also anything loaded by
|
|
43
|
-
# the Buildfile (buildr.rb, separate file listing dependencies, etc), so we add anything required
|
|
44
|
-
# after the Buildfile. So which don't know where Buildr shows up exactly, ignore files that show
|
|
45
|
-
# in $LOADED_FEATURES that we cannot resolve.
|
|
46
|
-
sources = Buildr.application.build_files.map { |file| File.expand_path(file) }.select { |file| File.exist?(file) }
|
|
47
|
-
sources << File.expand_path(Buildr.application.buildfile, root_path) if Buildr.application.buildfile
|
|
48
42
|
|
|
49
43
|
# Find a path relative to the project's root directory.
|
|
50
44
|
relative = lambda { |path| Util.relative_path(path.to_s, project.path_to) }
|
|
@@ -57,8 +51,8 @@ module Buildr
|
|
|
57
51
|
idea.enhance [ file(task_name) ]
|
|
58
52
|
|
|
59
53
|
# The only thing we need to look for is a change in the Buildfile.
|
|
60
|
-
file(task_name=>
|
|
61
|
-
|
|
54
|
+
file(task_name=>Buildr.application.buildfile) do |task|
|
|
55
|
+
info "Writing #{task.name}"
|
|
62
56
|
|
|
63
57
|
# Idea handles modules slightly differently if they're WARs
|
|
64
58
|
idea_types = Hash.new("JAVA_MODULE")
|
|
@@ -153,8 +147,8 @@ module Buildr
|
|
|
153
147
|
task_name = project.path_to("#{project.name.gsub(':', '-')}.ipr")
|
|
154
148
|
idea.enhance [ file(task_name) ]
|
|
155
149
|
|
|
156
|
-
file(task_name=>
|
|
157
|
-
|
|
150
|
+
file(task_name=>Buildr.application.buildfile) do |task|
|
|
151
|
+
info "Writing #{task.name}"
|
|
158
152
|
|
|
159
153
|
# Generating just the little stanza that chanages from one project to another
|
|
160
154
|
partial = StringIO.new
|
|
@@ -178,8 +172,9 @@ module Buildr
|
|
|
178
172
|
template_xml = REXML::Document.new(File.open(File.dirname(__FILE__)+"/idea.ipr.template"))
|
|
179
173
|
include_xml = REXML::Document.new(partial.string)
|
|
180
174
|
template_xml.root.add_element(include_xml.root)
|
|
181
|
-
|
|
182
|
-
|
|
175
|
+
File.open task.name, 'w' do |file|
|
|
176
|
+
template_xml.write file
|
|
177
|
+
end
|
|
183
178
|
end
|
|
184
179
|
end
|
|
185
180
|
|
data/lib/buildr/ide/idea7x.rb
CHANGED
|
@@ -49,9 +49,6 @@ module Buildr
|
|
|
49
49
|
# We need paths relative to the top project's base directory.
|
|
50
50
|
root_path = lambda { |p| f = lambda { |p| p.parent ? f[p.parent] : p.base_dir }; f[p] }[project]
|
|
51
51
|
|
|
52
|
-
sources = Buildr.application.build_files.map { |file| File.expand_path(file) }.select { |file| File.exist?(file) }
|
|
53
|
-
sources << File.expand_path(Buildr.application.buildfile, root_path) if Buildr.application.buildfile
|
|
54
|
-
|
|
55
52
|
# Find a path relative to the project's root directory.
|
|
56
53
|
relative = lambda { |path| Util.relative_path(File.expand_path(path.to_s), project.path_to) }
|
|
57
54
|
|
|
@@ -63,7 +60,7 @@ module Buildr
|
|
|
63
60
|
idea7x.enhance [ file(task_name) ]
|
|
64
61
|
|
|
65
62
|
# The only thing we need to look for is a change in the Buildfile.
|
|
66
|
-
file(task_name=>
|
|
63
|
+
file(task_name=>Buildr.application.buildfile) do |task|
|
|
67
64
|
# Note: Use the test classpath since Eclipse compiles both "main" and "test" classes using the same classpath
|
|
68
65
|
deps = project.test.compile.dependencies.map(&:to_s) - [ project.compile.target.to_s ]
|
|
69
66
|
|
|
@@ -78,7 +75,7 @@ module Buildr
|
|
|
78
75
|
|
|
79
76
|
# Project type is going to be the first package type
|
|
80
77
|
if package = project.packages.first
|
|
81
|
-
|
|
78
|
+
info "Writing #{task.name}"
|
|
82
79
|
File.open(task.name, "w") do |file|
|
|
83
80
|
xml = Builder::XmlMarkup.new(:target=>file, :indent=>2)
|
|
84
81
|
xml.module(:version=>"4", :relativePaths=>"true", :type=>"JAVA_MODULE") do
|
|
@@ -104,7 +101,7 @@ module Buildr
|
|
|
104
101
|
|
|
105
102
|
# Root project aggregates all the subprojects.
|
|
106
103
|
if project.parent == nil
|
|
107
|
-
Buildr::Idea7x.generate_ipr(project, idea7x,
|
|
104
|
+
Buildr::Idea7x.generate_ipr(project, idea7x, Buildr.application.buildfile)
|
|
108
105
|
end
|
|
109
106
|
|
|
110
107
|
end # after_define
|
|
@@ -173,7 +170,7 @@ module Buildr
|
|
|
173
170
|
task_name = project.path_to("#{project.name.gsub(':', '-')}-7x.ipr")
|
|
174
171
|
idea7x.enhance [ file(task_name) ]
|
|
175
172
|
file(task_name=>sources) do |task|
|
|
176
|
-
|
|
173
|
+
info "Writing #{task.name}"
|
|
177
174
|
|
|
178
175
|
# Generating just the little stanza that chanages from one project to another
|
|
179
176
|
partial = StringIO.new
|
|
@@ -197,7 +194,9 @@ module Buildr
|
|
|
197
194
|
template_xml = REXML::Document.new(File.open(File.join(File.dirname(__FILE__), IPR_TEMPLATE)))
|
|
198
195
|
include_xml = REXML::Document.new(partial.string)
|
|
199
196
|
template_xml.root.add_element(include_xml.root)
|
|
200
|
-
|
|
197
|
+
File.open task.name, 'w' do |file|
|
|
198
|
+
template_xml.write file
|
|
199
|
+
end
|
|
201
200
|
end
|
|
202
201
|
end
|
|
203
202
|
|
data/lib/buildr/java.rb
CHANGED
|
@@ -14,13 +14,10 @@
|
|
|
14
14
|
# the License.
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
require
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
require 'buildr/java/compilers'
|
|
22
|
-
require 'buildr/java/test_frameworks'
|
|
23
|
-
require 'buildr/java/bdd_frameworks'
|
|
17
|
+
require RUBY_PLATFORM == 'java' ? 'buildr/java/jruby' : 'buildr/java/rjb'
|
|
18
|
+
require 'buildr/java/compiler'
|
|
19
|
+
require 'buildr/java/tests'
|
|
20
|
+
require 'buildr/java/bdd'
|
|
24
21
|
require 'buildr/java/packaging'
|
|
25
22
|
require 'buildr/java/commands'
|
|
26
23
|
require 'buildr/java/deprecated'
|
data/lib/buildr/java/ant.rb
CHANGED
|
@@ -23,11 +23,32 @@ module Buildr
|
|
|
23
23
|
module Ant
|
|
24
24
|
|
|
25
25
|
# Which version of Ant we're using by default.
|
|
26
|
-
VERSION = '1.7.
|
|
26
|
+
VERSION = '1.7.1'
|
|
27
|
+
|
|
28
|
+
class << self
|
|
29
|
+
# Current version of Ant being used.
|
|
30
|
+
def version
|
|
31
|
+
Buildr.settings.build['ant'] || VERSION
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Ant classpath dependencies.
|
|
35
|
+
def dependencies
|
|
36
|
+
# Ant-Trax required for running the JUnitReport task, and there's no other place
|
|
37
|
+
# to put it but the root classpath.
|
|
38
|
+
@dependencies ||= ["org.apache.ant:ant:jar:#{version}", "org.apache.ant:ant-launcher:jar:#{version}",
|
|
39
|
+
"org.apache.ant:ant-trax:jar:#{version}"]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
def const_missing(const)
|
|
44
|
+
return super unless const == :REQUIRES # TODO: remove in 1.5
|
|
45
|
+
Buildr.application.deprecated "Please use Ant.dependencies/.version instead of Ant::REQUIRES/VERSION"
|
|
46
|
+
dependencies
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
27
50
|
|
|
28
|
-
|
|
29
|
-
REQUIRES = [ "org.apache.ant:ant:jar:#{VERSION}", "org.apache.ant:ant-launcher:jar:#{VERSION}", 'xerces:xercesImpl:jar:2.6.2' ]
|
|
30
|
-
Java.classpath << REQUIRES
|
|
51
|
+
Java.classpath << lambda { Ant.dependencies }
|
|
31
52
|
|
|
32
53
|
# :call-seq:
|
|
33
54
|
# ant(name) { |AntProject| ... } => AntProject
|
|
@@ -65,7 +86,7 @@ module Buildr
|
|
|
65
86
|
|
|
66
87
|
Buildr.help do
|
|
67
88
|
Java.load
|
|
68
|
-
"\nUsing Java #{ENV_JAVA['java.version']}, Ant #{Ant
|
|
89
|
+
"\nUsing Java #{ENV_JAVA['java.version']}, Ant #{Ant.version}."
|
|
69
90
|
end
|
|
70
91
|
|
|
71
92
|
end
|
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
13
|
+
# License for the specific language governing permissions and limitations under
|
|
14
|
+
# the License.
|
|
15
|
+
|
|
16
|
+
require 'buildr/java/tests'
|
|
17
|
+
require 'buildr/java/test_result'
|
|
18
|
+
|
|
19
|
+
module Buildr
|
|
20
|
+
|
|
21
|
+
# Mixin for test frameworks using src/spec/{lang}
|
|
22
|
+
class TestFramework::JavaBDD < TestFramework::Java #:nodoc:
|
|
23
|
+
|
|
24
|
+
class << self
|
|
25
|
+
attr_reader :lang, :bdd_dir
|
|
26
|
+
end
|
|
27
|
+
attr_accessor :lang, :bdd_dir
|
|
28
|
+
|
|
29
|
+
def initialize(task, options)
|
|
30
|
+
self.bdd_dir = self.class.bdd_dir
|
|
31
|
+
project = task.project
|
|
32
|
+
project.task('test:compile').tap do |comp|
|
|
33
|
+
comp.send :associate_with, project, bdd_dir
|
|
34
|
+
self.lang = comp.language || self.class.lang
|
|
35
|
+
end
|
|
36
|
+
project.task('test:resources').tap do |res|
|
|
37
|
+
res.send :associate_with, project, bdd_dir
|
|
38
|
+
res.filter.clear
|
|
39
|
+
project.path_to(:source, bdd_dir, :resources).tap { |dir| res.from dir if File.exist?(dir) }
|
|
40
|
+
end
|
|
41
|
+
super
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
module TestFramework::JRubyBased
|
|
47
|
+
extend self
|
|
48
|
+
|
|
49
|
+
VERSION = '1.1.3'
|
|
50
|
+
|
|
51
|
+
class << self
|
|
52
|
+
def version
|
|
53
|
+
Buildr.settings.build['jruby'] || VERSION
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def jruby_artifact
|
|
57
|
+
"org.jruby:jruby-complete:jar:#{version}"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def dependencies
|
|
61
|
+
[jruby_artifact]
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def included(mod)
|
|
65
|
+
mod.extend ClassMethods
|
|
66
|
+
super
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
module ClassMethods
|
|
71
|
+
def dependencies
|
|
72
|
+
deps = super
|
|
73
|
+
unless RUBY_PLATFORM[/java/] && TestFramework::JRubyBased.jruby_installed?
|
|
74
|
+
deps |= TestFramework::JRubyBased.dependencies
|
|
75
|
+
end
|
|
76
|
+
deps
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def run(tests, dependencies)
|
|
81
|
+
maybe_install_jruby
|
|
82
|
+
dependencies |= [task.compile.target.to_s]
|
|
83
|
+
|
|
84
|
+
spec_dir = task.project.path_to(:source, :spec, :ruby)
|
|
85
|
+
report_dir = task.report_to.to_s
|
|
86
|
+
FileUtils.rm_rf report_dir
|
|
87
|
+
FileUtils.mkdir_p report_dir
|
|
88
|
+
ENV['CI_REPORTS'] = report_dir
|
|
89
|
+
|
|
90
|
+
runner = runner_config
|
|
91
|
+
runner.content = runner_content(binding)
|
|
92
|
+
|
|
93
|
+
Buildr.write(runner.file, runner.content)
|
|
94
|
+
FileUtils.rm_f runner.result
|
|
95
|
+
|
|
96
|
+
if RUBY_PLATFORM[/java/] && !options.fork
|
|
97
|
+
runtime = new_runtime
|
|
98
|
+
runtime.getObject.java.lang.System.getProperties().putAll(options[:properties] || {})
|
|
99
|
+
runtime.getLoadService.require runner.file
|
|
100
|
+
else
|
|
101
|
+
cmd_options = task.options.only(:properties, :java_args)
|
|
102
|
+
cmd_options.update(:classpath => dependencies, :project => task.project)
|
|
103
|
+
jruby runner.file, tests, cmd_options
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
result = YAML.load(File.read(runner.result))
|
|
107
|
+
if Exception === result
|
|
108
|
+
raise [result.message, result.backtrace].flatten.join("\n")
|
|
109
|
+
end
|
|
110
|
+
result.succeeded
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def jruby_home
|
|
114
|
+
@jruby_home ||= RUBY_PLATFORM =~ /java/ ? Config::CONFIG['prefix'] :
|
|
115
|
+
( ENV['JRUBY_HOME'] || File.expand_path('~/.jruby') )
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def jruby_installed?
|
|
119
|
+
!Dir.glob(File.join(jruby_home, 'lib', 'jruby*.jar')).empty?
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
protected
|
|
123
|
+
def maybe_install_jruby
|
|
124
|
+
unless jruby_installed?
|
|
125
|
+
jruby_artifact = Buildr.artifact(TestFramework::JRubyBased.jruby_artifact)
|
|
126
|
+
msg = "JRUBY_HOME is not correctly set or points to an invalid JRuby installation: #{jruby_home}"
|
|
127
|
+
say msg
|
|
128
|
+
say ''
|
|
129
|
+
say "You need to install JRuby version #{jruby_artifact.version} using your system package manager."
|
|
130
|
+
say 'Or you can just execute the following command: '
|
|
131
|
+
say ''
|
|
132
|
+
say " java -jar #{jruby_artifact} -S extract '#{jruby_home}'"
|
|
133
|
+
say ''
|
|
134
|
+
if agree('Do you want me to execute it for you? [y/N]', false)
|
|
135
|
+
jruby_artifact.invoke
|
|
136
|
+
Java::Commands.java('-jar', jruby_artifact.to_s, '-S', 'extract', jruby_home)
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
fail msg unless jruby_installed?
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def jruby(*args)
|
|
144
|
+
java_args = ['org.jruby.Main', *args]
|
|
145
|
+
java_args << {} unless Hash === args.last
|
|
146
|
+
cmd_options = java_args.last
|
|
147
|
+
project = cmd_options.delete(:project)
|
|
148
|
+
cmd_options[:classpath] ||= []
|
|
149
|
+
Dir.glob(File.join(jruby_home, 'lib', '*.jar')) { |jar| cmd_options[:classpath] << jar }
|
|
150
|
+
cmd_options[:java_args] ||= []
|
|
151
|
+
cmd_options[:java_args] << '-Xmx512m' unless cmd_options[:java_args].detect {|a| a =~ /^-Xmx/}
|
|
152
|
+
cmd_options[:properties] ||= {}
|
|
153
|
+
cmd_options[:properties]['jruby.home'] = jruby_home
|
|
154
|
+
Java::Commands.java(*java_args)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def new_runtime(cfg = {})
|
|
158
|
+
config = Java.org.jruby.RubyInstanceConfig.new
|
|
159
|
+
cfg.each_pair do |name, value|
|
|
160
|
+
config.send("#{name}=", value)
|
|
161
|
+
end
|
|
162
|
+
yield config if block_given?
|
|
163
|
+
Java.org.jruby.Ruby.newInstance config
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def jruby_gem
|
|
167
|
+
%{
|
|
168
|
+
require 'jruby'
|
|
169
|
+
def JRuby.gem(name, version = '>0', *args)
|
|
170
|
+
require 'rbconfig'
|
|
171
|
+
jruby_home = Config::CONFIG['prefix']
|
|
172
|
+
expected_version = '#{TestFramework::JRubyBased.version}'
|
|
173
|
+
unless JRUBY_VERSION >= expected_version
|
|
174
|
+
fail "Expected JRuby version \#{expected_version} installed at \#{jruby_home} but got \#{JRUBY_VERSION}"
|
|
175
|
+
end
|
|
176
|
+
require 'rubygems'
|
|
177
|
+
begin
|
|
178
|
+
Kernel.gem name, version
|
|
179
|
+
rescue LoadError, Gem::LoadError => e
|
|
180
|
+
require 'rubygems/gem_runner'
|
|
181
|
+
Gem.manage_gems
|
|
182
|
+
args = ['install', name, '--version', version] + args
|
|
183
|
+
Gem::GemRunner.new.run(args)
|
|
184
|
+
Kernel.gem name, version
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
}
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def runner_config(runner = OpenStruct.new)
|
|
191
|
+
[:requires, :gems, :output, :format].each do |key|
|
|
192
|
+
runner.send("#{key}=", options[key])
|
|
193
|
+
end
|
|
194
|
+
runner.html_report ||= File.join(task.report_to.to_s, 'report.html')
|
|
195
|
+
runner.result ||= task.project.path_to(:target, :spec, 'result.yaml')
|
|
196
|
+
runner.file ||= task.project.path_to(:target, :spec, 'runner.rb')
|
|
197
|
+
runner.requires ||= []
|
|
198
|
+
runner.requires.unshift File.join(File.dirname(__FILE__), 'test_result')
|
|
199
|
+
runner.gems ||= {}
|
|
200
|
+
runner.rspec ||= ['--format', 'progress', '--format', "html:#{runner.html_report}"]
|
|
201
|
+
runner.format.each { |format| runner.rspec << '--format' << format } if runner.format
|
|
202
|
+
runner.rspec.push '--format', "Buildr::TestFramework::TestResult::YamlFormatter:#{runner.result}"
|
|
203
|
+
runner
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
# <a href="http://rspec.info">RSpec</a> is the defacto BDD framework for ruby.
|
|
209
|
+
# To test your project with RSpec use:
|
|
210
|
+
# test.using :rspec
|
|
211
|
+
#
|
|
212
|
+
#
|
|
213
|
+
# Support the following options:
|
|
214
|
+
# * :gems -- A hash of gems to install before running the tests.
|
|
215
|
+
# The keys of this hash are the gem name, the value must be the required version.
|
|
216
|
+
# * :requires -- A list of ruby files to require before running the specs
|
|
217
|
+
# Mainly used if an rspec format needs to require some file.
|
|
218
|
+
# * :format -- A list of valid Rspec --format option values. (defaults to 'progress')
|
|
219
|
+
# * :output -- File path to output dump. @false@ to supress output
|
|
220
|
+
# * :fork -- Create a new JavaVM to run the tests on
|
|
221
|
+
# * :properties -- Hash of properties passed to the test suite.
|
|
222
|
+
# * :java_args -- Arguments passed to the JVM.
|
|
223
|
+
class RSpec < TestFramework::JavaBDD
|
|
224
|
+
@lang = :ruby
|
|
225
|
+
@bdd_dir = :spec
|
|
226
|
+
|
|
227
|
+
include TestFramework::JRubyBased
|
|
228
|
+
|
|
229
|
+
TESTS_PATTERN = [ /_spec.rb$/ ]
|
|
230
|
+
OPTIONS = [:properties, :java_args]
|
|
231
|
+
|
|
232
|
+
def self.applies_to?(project) #:nodoc:
|
|
233
|
+
!Dir[project.path_to(:source, bdd_dir, lang, '**/*_spec.rb')].empty?
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
def tests(dependencies) #:nodoc:
|
|
237
|
+
Dir[task.project.path_to(:source, bdd_dir, lang, '**/*_spec.rb')].
|
|
238
|
+
select do |name|
|
|
239
|
+
selector = ENV['SPEC']
|
|
240
|
+
selector.nil? || Regexp.new(selector) === name
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
def runner_config
|
|
245
|
+
runner = super
|
|
246
|
+
runner.gems.update 'rspec' => '>0'
|
|
247
|
+
runner.requires.unshift 'spec'
|
|
248
|
+
runner
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
def runner_content(binding)
|
|
252
|
+
runner_erb = %q{
|
|
253
|
+
<%= jruby_gem %>
|
|
254
|
+
<%= dependencies.inspect %>.each { |dep| $CLASSPATH << dep }
|
|
255
|
+
<%= runner.gems.inspect %>.each { |ary| JRuby.gem(*ary.flatten) }
|
|
256
|
+
<%= runner.requires.inspect %>.each { |rb| Kernel.require rb }
|
|
257
|
+
<% if runner.output == false %>
|
|
258
|
+
output = StringIO.new
|
|
259
|
+
<% elsif runner.output.kind_of?(String) %>
|
|
260
|
+
output = File.open(<%= result.output.inspect %>, 'w')
|
|
261
|
+
<% else %>
|
|
262
|
+
output = STDOUT
|
|
263
|
+
<% end %>
|
|
264
|
+
parser = ::Spec::Runner::OptionParser.new(output, output)
|
|
265
|
+
argv = <%= runner.rspec.inspect %> || []
|
|
266
|
+
argv.push *<%= tests.inspect %>
|
|
267
|
+
parser.order!(argv)
|
|
268
|
+
$rspec_options = parser.options
|
|
269
|
+
Buildr::TestFramework::TestResult::Error.guard('<%= runner.file %>') do
|
|
270
|
+
::Spec::Runner::CommandLine.run($rspec_options)
|
|
271
|
+
end
|
|
272
|
+
exit 0 # let buildr figure the result from the yaml file
|
|
273
|
+
}
|
|
274
|
+
Filter::Mapper.new(:erb, binding).transform(runner_erb)
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
# <a href="http://jtestr.codehaus.org/">JtestR</a> is a framework for BDD and TDD using JRuby and ruby tools.
|
|
280
|
+
# To test your project with JtestR use:
|
|
281
|
+
# test.using :jtestr
|
|
282
|
+
#
|
|
283
|
+
#
|
|
284
|
+
# Support the following options:
|
|
285
|
+
# * :config -- path to JtestR config file. defaults to @spec/ruby/jtestr_config.rb@
|
|
286
|
+
# * :gems -- A hash of gems to install before running the tests.
|
|
287
|
+
# The keys of this hash are the gem name, the value must be the required version.
|
|
288
|
+
# * :requires -- A list of ruby files to require before running the specs
|
|
289
|
+
# Mainly used if an rspec format needs to require some file.
|
|
290
|
+
# * :format -- A list of valid Rspec --format option values. (defaults to 'progress')
|
|
291
|
+
# * :output -- File path to output dump. @false@ to supress output
|
|
292
|
+
# * :fork -- Create a new JavaVM to run the tests on
|
|
293
|
+
# * :properties -- Hash of properties passed to the test suite.
|
|
294
|
+
# * :java_args -- Arguments passed to the JVM.
|
|
295
|
+
class JtestR < TestFramework::JavaBDD
|
|
296
|
+
@lang = :ruby
|
|
297
|
+
@bdd_dir = :spec
|
|
298
|
+
|
|
299
|
+
include TestFramework::JRubyBased
|
|
300
|
+
|
|
301
|
+
VERSION = '0.3.1'
|
|
302
|
+
|
|
303
|
+
# pattern for rspec stories
|
|
304
|
+
STORY_PATTERN = /_(steps|story)\.rb$/
|
|
305
|
+
# pattern for test_unit files
|
|
306
|
+
TESTUNIT_PATTERN = /(_test|Test)\.rb$|(tc|ts)[^\\\/]+\.rb$/
|
|
307
|
+
# pattern for test files using http://expectations.rubyforge.org/
|
|
308
|
+
EXPECT_PATTERN = /_expect\.rb$/
|
|
309
|
+
|
|
310
|
+
TESTS_PATTERN = [STORY_PATTERN, TESTUNIT_PATTERN, EXPECT_PATTERN] + RSpec::TESTS_PATTERN
|
|
311
|
+
|
|
312
|
+
class << self
|
|
313
|
+
|
|
314
|
+
def version
|
|
315
|
+
Buildr.settings.build['jtestr'] || VERSION
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
def dependencies
|
|
319
|
+
@dependencies ||= Array(super) + ["org.jtestr:jtestr:jar:#{version}"] +
|
|
320
|
+
JUnit.dependencies + TestNG.dependencies
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
def applies_to?(project) #:nodoc:
|
|
324
|
+
File.exist?(project.path_to(:source, bdd_dir, lang, 'jtestr_config.rb')) ||
|
|
325
|
+
Dir[project.path_to(:source, bdd_dir, lang, '**/*.rb')].any? { |f| TESTS_PATTERN.any? { |r| r === f } } ||
|
|
326
|
+
JUnit.applies_to?(project) || TestNG.applies_to?(project)
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
private
|
|
330
|
+
def const_missing(const)
|
|
331
|
+
return super unless const == :REQUIRES # TODO: remove in 1.5
|
|
332
|
+
Buildr.application.deprecated 'Please use JtestR.dependencies/.version instead of JtestR::REQUIRES/VERSION'
|
|
333
|
+
dependencies
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
def initialize(task, options) #:nodoc:
|
|
339
|
+
super
|
|
340
|
+
[:test, :spec].each do |usage|
|
|
341
|
+
java_tests = task.project.path_to(:source, usage, :java)
|
|
342
|
+
task.compile.from java_tests if File.directory?(java_tests)
|
|
343
|
+
resources = task.project.path_to(:source, usage, :resources)
|
|
344
|
+
task.resources.from resources if File.directory?(resources)
|
|
345
|
+
end
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
def user_config
|
|
349
|
+
options[:config] || task.project.path_to(:source, bdd_dir, lang, 'jtestr_config.rb')
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
def tests(dependencies) #:nodoc:
|
|
353
|
+
dependencies |= [task.compile.target.to_s]
|
|
354
|
+
types = { :story => STORY_PATTERN, :rspec => RSpec::TESTS_PATTERN,
|
|
355
|
+
:testunit => TESTUNIT_PATTERN, :expect => EXPECT_PATTERN }
|
|
356
|
+
tests = types.keys.inject({}) { |h, k| h[k] = []; h }
|
|
357
|
+
tests[:junit] = JUnit.new(task, {}).tests(dependencies)
|
|
358
|
+
tests[:testng] = TestNG.new(task, {}).tests(dependencies)
|
|
359
|
+
Dir[task.project.path_to(:source, bdd_dir, lang, '**/*.rb')].each do |rb|
|
|
360
|
+
type = types.find { |k, v| Array(v).any? { |r| r === rb } }
|
|
361
|
+
tests[type.first] << rb if type
|
|
362
|
+
end
|
|
363
|
+
@jtestr_tests = tests
|
|
364
|
+
tests.values.flatten
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
def runner_config
|
|
368
|
+
runner = super
|
|
369
|
+
# JtestR 0.3.1 comes with rspec 1.1.4 (and any other jtestr dependency) included,
|
|
370
|
+
# so the rspec version used depends on the jtestr jar.
|
|
371
|
+
runner.requires.unshift 'jtestr'
|
|
372
|
+
runner
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
def runner_content(binding)
|
|
376
|
+
runner_erb = File.join(File.dirname(__FILE__), 'jtestr_runner.rb.erb')
|
|
377
|
+
Filter::Mapper.new(:erb, binding).transform(File.read(runner_erb), runner_erb)
|
|
378
|
+
end
|
|
379
|
+
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
# JBehave is a Java BDD framework. To use in your project:
|
|
384
|
+
# test.using :jbehave
|
|
385
|
+
#
|
|
386
|
+
# This framework will search in your project for:
|
|
387
|
+
# src/spec/java/**/*Behaviour.java
|
|
388
|
+
#
|
|
389
|
+
# JMock libraries are included on runtime.
|
|
390
|
+
#
|
|
391
|
+
# Support the following options:
|
|
392
|
+
# * :properties -- Hash of properties to the test suite
|
|
393
|
+
# * :java_args -- Arguments passed to the JVM
|
|
394
|
+
class JBehave < TestFramework::JavaBDD
|
|
395
|
+
@lang = :java
|
|
396
|
+
@bdd_dir = :spec
|
|
397
|
+
|
|
398
|
+
VERSION = '1.0.1'
|
|
399
|
+
TESTS_PATTERN = [ /Behaviou?r$/ ] #:nodoc:
|
|
400
|
+
|
|
401
|
+
class << self
|
|
402
|
+
def version
|
|
403
|
+
Buildr.settings.build['jbehave'] || VERSION
|
|
404
|
+
end
|
|
405
|
+
|
|
406
|
+
def dependencies
|
|
407
|
+
@dependencies ||= ["org.jbehave:jbehave:jar:#{version}", 'cglib:cglib-full:jar:2.0.2'] +
|
|
408
|
+
JMock.dependencies + JUnit.dependencies
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
def applies_to?(project) #:nodoc:
|
|
412
|
+
%w{
|
|
413
|
+
**/*Behaviour.java **/*Behavior.java
|
|
414
|
+
}.any? { |glob| !Dir[project.path_to(:source, bdd_dir, lang, glob)].empty? }
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
private
|
|
418
|
+
def const_missing(const)
|
|
419
|
+
return super unless const == :REQUIRES # TODO: remove in 1.5
|
|
420
|
+
Buildr.application.deprecated 'Please use JBehave.dependencies/.version instead of JBehave::REQUIRES/VERSION'
|
|
421
|
+
dependencies
|
|
422
|
+
end
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
def tests(dependencies) #:nodoc:
|
|
426
|
+
filter_classes(dependencies, :class_names => TESTS_PATTERN,
|
|
427
|
+
:interfaces => %w{ org.jbehave.core.behaviour.Behaviours })
|
|
428
|
+
end
|
|
429
|
+
|
|
430
|
+
def run(tests, dependencies) #:nodoc:
|
|
431
|
+
cmd_args = ['org.jbehave.core.BehaviourRunner']
|
|
432
|
+
cmd_options = { :properties=>options[:properties], :java_args=>options[:java_args], :classpath=>dependencies }
|
|
433
|
+
tests.inject([]) do |passed, test|
|
|
434
|
+
begin
|
|
435
|
+
Java::Commands.java cmd_args, test, cmd_options
|
|
436
|
+
passed << test
|
|
437
|
+
rescue
|
|
438
|
+
passed
|
|
439
|
+
end
|
|
440
|
+
end
|
|
441
|
+
end
|
|
442
|
+
|
|
443
|
+
end
|
|
444
|
+
|
|
445
|
+
end
|
|
446
|
+
|
|
447
|
+
Buildr::TestFramework << Buildr::RSpec
|
|
448
|
+
Buildr::TestFramework << Buildr::JtestR
|
|
449
|
+
Buildr::TestFramework << Buildr::JBehave
|