mguymon-buildr 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +1291 -0
- data/LICENSE +176 -0
- data/NOTICE +26 -0
- data/README.rdoc +134 -0
- data/Rakefile +44 -0
- data/_buildr +35 -0
- data/_jbuildr +35 -0
- data/addon/buildr/antlr.rb +65 -0
- data/addon/buildr/bnd.rb +147 -0
- data/addon/buildr/cobertura.rb +22 -0
- data/addon/buildr/drb.rb +281 -0
- data/addon/buildr/emma.rb +22 -0
- data/addon/buildr/hibernate.rb +149 -0
- data/addon/buildr/javacc.rb +85 -0
- data/addon/buildr/jaxb_xjc.rb +72 -0
- data/addon/buildr/jdepend.rb +60 -0
- data/addon/buildr/jetty.rb +248 -0
- data/addon/buildr/jibx.rb +86 -0
- data/addon/buildr/nailgun.rb +221 -0
- data/addon/buildr/openjpa.rb +88 -0
- data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
- data/addon/buildr/protobuf.rb +88 -0
- data/addon/buildr/xmlbeans.rb +93 -0
- data/bin/buildr +19 -0
- data/buildr.buildfile +58 -0
- data/buildr.gemspec +78 -0
- data/doc/_config.yml +1 -0
- data/doc/_layouts/default.html +90 -0
- data/doc/_layouts/preface.html +22 -0
- data/doc/artifacts.textile +217 -0
- data/doc/building.textile +276 -0
- data/doc/contributing.textile +268 -0
- data/doc/css/default.css +236 -0
- data/doc/css/print.css +101 -0
- data/doc/css/syntax.css +23 -0
- data/doc/download.textile +151 -0
- data/doc/extending.textile +212 -0
- data/doc/images/1442160941-frontcover.jpg +0 -0
- data/doc/images/asf-logo.gif +0 -0
- data/doc/images/asf-logo.png +0 -0
- data/doc/images/buildr-hires.png +0 -0
- data/doc/images/buildr.png +0 -0
- data/doc/images/favicon.png +0 -0
- data/doc/images/growl-icon.tiff +0 -0
- data/doc/images/note.png +0 -0
- data/doc/images/project-structure.png +0 -0
- data/doc/images/tip.png +0 -0
- data/doc/images/zbuildr.png +0 -0
- data/doc/images/zbuildr.tif +0 -0
- data/doc/index.textile +109 -0
- data/doc/installing.textile +284 -0
- data/doc/languages.textile +599 -0
- data/doc/mailing_lists.textile +29 -0
- data/doc/more_stuff.textile +845 -0
- data/doc/packaging.textile +618 -0
- data/doc/preface.textile +54 -0
- data/doc/projects.textile +276 -0
- data/doc/quick_start.textile +210 -0
- data/doc/releasing.textile +117 -0
- data/doc/scripts/buildr-git.rb +512 -0
- data/doc/scripts/gitflow.rb +296 -0
- data/doc/scripts/install-jruby.sh +44 -0
- data/doc/scripts/install-linux.sh +73 -0
- data/doc/scripts/install-osx.sh +52 -0
- data/doc/settings_profiles.textile +287 -0
- data/doc/testing.textile +247 -0
- data/etc/KEYS +189 -0
- data/lib/buildr.rb +44 -0
- data/lib/buildr/clojure.rb +34 -0
- data/lib/buildr/clojure/shell.rb +52 -0
- data/lib/buildr/core.rb +34 -0
- data/lib/buildr/core/application.rb +700 -0
- data/lib/buildr/core/build.rb +516 -0
- data/lib/buildr/core/cc.rb +166 -0
- data/lib/buildr/core/checks.rb +253 -0
- data/lib/buildr/core/common.rb +151 -0
- data/lib/buildr/core/compile.rb +622 -0
- data/lib/buildr/core/doc.rb +276 -0
- data/lib/buildr/core/environment.rb +129 -0
- data/lib/buildr/core/filter.rb +404 -0
- data/lib/buildr/core/generate.rb +197 -0
- data/lib/buildr/core/help.rb +119 -0
- data/lib/buildr/core/jrebel.rb +42 -0
- data/lib/buildr/core/linux.rb +30 -0
- data/lib/buildr/core/osx.rb +46 -0
- data/lib/buildr/core/progressbar.rb +161 -0
- data/lib/buildr/core/project.rb +975 -0
- data/lib/buildr/core/run.rb +43 -0
- data/lib/buildr/core/shell.rb +137 -0
- data/lib/buildr/core/test.rb +843 -0
- data/lib/buildr/core/transports.rb +575 -0
- data/lib/buildr/core/util.rb +537 -0
- data/lib/buildr/groovy.rb +20 -0
- data/lib/buildr/groovy/bdd.rb +106 -0
- data/lib/buildr/groovy/compiler.rb +153 -0
- data/lib/buildr/groovy/doc.rb +76 -0
- data/lib/buildr/groovy/shell.rb +57 -0
- data/lib/buildr/ide.rb +19 -0
- data/lib/buildr/ide/eclipse.rb +427 -0
- data/lib/buildr/ide/eclipse/java.rb +53 -0
- data/lib/buildr/ide/eclipse/plugin.rb +71 -0
- data/lib/buildr/ide/eclipse/scala.rb +68 -0
- data/lib/buildr/ide/idea.rb +576 -0
- data/lib/buildr/java.rb +25 -0
- data/lib/buildr/java/ant.rb +94 -0
- data/lib/buildr/java/bdd.rb +460 -0
- data/lib/buildr/java/cobertura.rb +297 -0
- data/lib/buildr/java/commands.rb +223 -0
- data/lib/buildr/java/compiler.rb +135 -0
- data/lib/buildr/java/deprecated.rb +141 -0
- data/lib/buildr/java/doc.rb +86 -0
- data/lib/buildr/java/ecj.rb +69 -0
- data/lib/buildr/java/emma.rb +244 -0
- data/lib/buildr/java/external.rb +73 -0
- data/lib/buildr/java/jruby.rb +122 -0
- data/lib/buildr/java/jtestr_result.rb +295 -0
- data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +142 -0
- data/lib/buildr/java/packaging.rb +734 -0
- data/lib/buildr/java/pom.rb +178 -0
- data/lib/buildr/java/rjb.rb +154 -0
- data/lib/buildr/java/test_result.rb +101 -0
- data/lib/buildr/java/tests.rb +362 -0
- data/lib/buildr/java/version_requirement.rb +172 -0
- data/lib/buildr/packaging.rb +25 -0
- data/lib/buildr/packaging/archive.rb +535 -0
- data/lib/buildr/packaging/artifact.rb +904 -0
- data/lib/buildr/packaging/artifact_namespace.rb +984 -0
- data/lib/buildr/packaging/artifact_search.rb +140 -0
- data/lib/buildr/packaging/gems.rb +105 -0
- data/lib/buildr/packaging/package.rb +249 -0
- data/lib/buildr/packaging/repository_array.rb +108 -0
- data/lib/buildr/packaging/tar.rb +189 -0
- data/lib/buildr/packaging/version_requirement.rb +192 -0
- data/lib/buildr/packaging/zip.rb +178 -0
- data/lib/buildr/packaging/ziptask.rb +356 -0
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/resources/completed.png +0 -0
- data/lib/buildr/resources/failed.png +0 -0
- data/lib/buildr/resources/icons-license.txt +17 -0
- data/lib/buildr/run.rb +195 -0
- data/lib/buildr/scala.rb +26 -0
- data/lib/buildr/scala/bdd.rb +118 -0
- data/lib/buildr/scala/compiler.rb +242 -0
- data/lib/buildr/scala/doc.rb +142 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
- data/lib/buildr/scala/shell.rb +52 -0
- data/lib/buildr/scala/tests.rb +171 -0
- data/lib/buildr/shell.rb +185 -0
- data/lib/buildr/version.rb +18 -0
- data/rakelib/all-in-one.rake +113 -0
- data/rakelib/checks.rake +57 -0
- data/rakelib/doc.rake +137 -0
- data/rakelib/metrics.rake +39 -0
- data/rakelib/package.rake +73 -0
- data/rakelib/release.rake +160 -0
- data/rakelib/rspec.rake +91 -0
- data/rakelib/setup.rake +66 -0
- data/rakelib/stage.rake +220 -0
- data/spec/addon/bnd_spec.rb +330 -0
- data/spec/addon/drb_spec.rb +328 -0
- data/spec/addon/jaxb_xjc_spec.rb +125 -0
- data/spec/core/application_spec.rb +631 -0
- data/spec/core/build_spec.rb +837 -0
- data/spec/core/cc_spec.rb +224 -0
- data/spec/core/checks_spec.rb +519 -0
- data/spec/core/common_spec.rb +725 -0
- data/spec/core/compile_spec.rb +658 -0
- data/spec/core/doc_spec.rb +195 -0
- data/spec/core/extension_spec.rb +201 -0
- data/spec/core/generate_spec.rb +33 -0
- data/spec/core/project_spec.rb +772 -0
- data/spec/core/run_spec.rb +93 -0
- data/spec/core/shell_spec.rb +146 -0
- data/spec/core/test_spec.rb +1320 -0
- data/spec/core/transport_spec.rb +544 -0
- data/spec/core/util_spec.rb +141 -0
- data/spec/groovy/bdd_spec.rb +80 -0
- data/spec/groovy/compiler_spec.rb +251 -0
- data/spec/groovy/doc_spec.rb +65 -0
- data/spec/ide/eclipse_spec.rb +739 -0
- data/spec/ide/idea_spec.rb +1145 -0
- data/spec/java/ant_spec.rb +37 -0
- data/spec/java/bdd_spec.rb +374 -0
- data/spec/java/cobertura_spec.rb +112 -0
- data/spec/java/commands_spec.rb +93 -0
- data/spec/java/compiler_spec.rb +252 -0
- data/spec/java/doc_spec.rb +56 -0
- data/spec/java/ecj_spec.rb +115 -0
- data/spec/java/emma_spec.rb +121 -0
- data/spec/java/external_spec.rb +56 -0
- data/spec/java/java_spec.rb +132 -0
- data/spec/java/packaging_spec.rb +1266 -0
- data/spec/java/run_spec.rb +78 -0
- data/spec/java/test_coverage_helper.rb +257 -0
- data/spec/java/tests_spec.rb +497 -0
- data/spec/packaging/archive_spec.rb +775 -0
- data/spec/packaging/artifact_namespace_spec.rb +743 -0
- data/spec/packaging/artifact_spec.rb +1074 -0
- data/spec/packaging/packaging_helper.rb +63 -0
- data/spec/packaging/packaging_spec.rb +719 -0
- data/spec/packaging/repository_array_spec.rb +109 -0
- data/spec/sandbox.rb +165 -0
- data/spec/scala/bdd_spec.rb +124 -0
- data/spec/scala/compiler_spec.rb +289 -0
- data/spec/scala/doc_spec.rb +88 -0
- data/spec/scala/scala.rb +38 -0
- data/spec/scala/tests_spec.rb +283 -0
- data/spec/spec_helpers.rb +369 -0
- data/spec/version_requirement_spec.rb +143 -0
- data/spec/xpath_matchers.rb +121 -0
- metadata +649 -0
data/lib/buildr/java.rb
ADDED
@@ -0,0 +1,25 @@
|
|
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
|
+
|
17
|
+
require RUBY_PLATFORM == 'java' ? 'buildr/java/jruby' : 'buildr/java/rjb'
|
18
|
+
require 'buildr/java/compiler'
|
19
|
+
require 'buildr/java/external'
|
20
|
+
require 'buildr/java/tests'
|
21
|
+
require 'buildr/java/bdd'
|
22
|
+
require 'buildr/java/packaging'
|
23
|
+
require 'buildr/java/commands'
|
24
|
+
require 'buildr/java/doc'
|
25
|
+
require 'buildr/java/deprecated'
|
@@ -0,0 +1,94 @@
|
|
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
|
+
|
17
|
+
gem 'atoulme-Antwrap'
|
18
|
+
autoload :Antwrap, 'antwrap'
|
19
|
+
autoload :Logger, 'logger'
|
20
|
+
require 'buildr/core/project'
|
21
|
+
require 'buildr/core/help'
|
22
|
+
|
23
|
+
|
24
|
+
module Buildr
|
25
|
+
module Ant
|
26
|
+
|
27
|
+
# Which version of Ant we're using by default.
|
28
|
+
VERSION = '1.8.0'
|
29
|
+
|
30
|
+
class << self
|
31
|
+
# Current version of Ant being used.
|
32
|
+
def version
|
33
|
+
Buildr.settings.build['ant'] || VERSION
|
34
|
+
end
|
35
|
+
|
36
|
+
# Ant classpath dependencies.
|
37
|
+
def dependencies
|
38
|
+
# Ant-Trax required for running the JUnitReport task, and there's no other place
|
39
|
+
# to put it but the root classpath.
|
40
|
+
@dependencies ||= ["org.apache.ant:ant:jar:#{version}", "org.apache.ant:ant-launcher:jar:#{version}",
|
41
|
+
"org.apache.ant:ant-trax:jar:#{version}"]
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
def const_missing(const)
|
46
|
+
return super unless const == :REQUIRES # TODO: remove in 1.5
|
47
|
+
Buildr.application.deprecated "Please use Ant.dependencies/.version instead of Ant::REQUIRES/VERSION"
|
48
|
+
dependencies
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
Java.classpath << lambda { Ant.dependencies }
|
54
|
+
|
55
|
+
# :call-seq:
|
56
|
+
# ant(name) { |AntProject| ... } => AntProject
|
57
|
+
#
|
58
|
+
# Creates a new AntProject with the specified name, yield to the block for defining various
|
59
|
+
# Ant tasks, and executes each task as it's defined.
|
60
|
+
#
|
61
|
+
# For example:
|
62
|
+
# ant("hibernatedoclet') do |doclet|
|
63
|
+
# doclet.taskdef :name=>'hibernatedoclet',
|
64
|
+
# :classname=>'xdoclet.modules.hibernate.HibernateDocletTask', :classpath=>DOCLET
|
65
|
+
# doclet.hibernatedoclet :destdir=>dest_dir, :force=>'true' do
|
66
|
+
# hibernate :version=>'3.0'
|
67
|
+
# fileset :dir=>source, :includes=>'**/*.java'
|
68
|
+
# end
|
69
|
+
# end
|
70
|
+
def ant(name, &block)
|
71
|
+
options = { :name=>name, :basedir=>Dir.pwd, :declarative=>true }
|
72
|
+
options.merge!(:logger=> Logger.new(STDOUT), :loglevel=> Logger::DEBUG) if trace?(:ant)
|
73
|
+
Java.load
|
74
|
+
Antwrap::AntProject.new(options).tap do |project|
|
75
|
+
# Set Ant logging level to debug (--trace), info (default) or error only (--quiet).
|
76
|
+
project.project.getBuildListeners().get(0).
|
77
|
+
setMessageOutputLevel((trace?(:ant) && 4) || (verbose && 2) || 0)
|
78
|
+
yield project if block_given?
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
include Ant
|
85
|
+
class Project
|
86
|
+
include Ant
|
87
|
+
end
|
88
|
+
|
89
|
+
Buildr.help do
|
90
|
+
Java.load
|
91
|
+
"\nUsing Java #{ENV_JAVA['java.version']}, Ant #{Ant.version}."
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
@@ -0,0 +1,460 @@
|
|
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
|
+
|
17
|
+
require 'buildr/java/tests'
|
18
|
+
require 'buildr/java/test_result'
|
19
|
+
|
20
|
+
module Buildr
|
21
|
+
|
22
|
+
# Mixin for test frameworks using src/spec/{lang}
|
23
|
+
class TestFramework::JavaBDD < TestFramework::Java #:nodoc:
|
24
|
+
|
25
|
+
class << self
|
26
|
+
attr_reader :lang, :bdd_dir
|
27
|
+
end
|
28
|
+
attr_accessor :lang, :bdd_dir
|
29
|
+
|
30
|
+
def initialize(task, options)
|
31
|
+
self.bdd_dir = self.class.bdd_dir
|
32
|
+
project = task.project
|
33
|
+
project.task('test:compile').tap do |comp|
|
34
|
+
comp.send :associate_with, project, bdd_dir
|
35
|
+
self.lang = comp.language || self.class.lang
|
36
|
+
end
|
37
|
+
project.task('test:resources').tap do |res|
|
38
|
+
res.send :associate_with, project, bdd_dir
|
39
|
+
res.filter.clear
|
40
|
+
project.path_to(:source, bdd_dir, :resources).tap { |dir| res.from dir if File.exist?(dir) }
|
41
|
+
end
|
42
|
+
super
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
module TestFramework::JRubyBased
|
48
|
+
extend self
|
49
|
+
|
50
|
+
VERSION = '1.5.6'
|
51
|
+
|
52
|
+
class << self
|
53
|
+
def version
|
54
|
+
Buildr.settings.build['jruby'] || VERSION
|
55
|
+
end
|
56
|
+
|
57
|
+
def jruby_artifact
|
58
|
+
"org.jruby:jruby-complete:jar:#{version}"
|
59
|
+
end
|
60
|
+
|
61
|
+
def dependencies
|
62
|
+
unless @dependencies
|
63
|
+
@dependencies = [jruby_artifact]
|
64
|
+
end
|
65
|
+
@dependencies
|
66
|
+
end
|
67
|
+
|
68
|
+
def included(mod)
|
69
|
+
mod.extend ClassMethods
|
70
|
+
super
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
module ClassMethods
|
75
|
+
def dependencies
|
76
|
+
unless @dependencies
|
77
|
+
super
|
78
|
+
unless RUBY_PLATFORM[/java/] && TestFramework::JRubyBased.jruby_installed?
|
79
|
+
@dependencies |= TestFramework::JRubyBased.dependencies
|
80
|
+
end
|
81
|
+
end
|
82
|
+
@dependencies
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def run(tests, dependencies)
|
87
|
+
maybe_install_jruby
|
88
|
+
dependencies |= [task.compile.target.to_s]
|
89
|
+
|
90
|
+
spec_dir = task.project.path_to(:source, :spec, :ruby)
|
91
|
+
report_dir = task.report_to.to_s
|
92
|
+
rm_rf report_dir
|
93
|
+
mkdir_p report_dir
|
94
|
+
ENV['CI_REPORTS'] = report_dir
|
95
|
+
|
96
|
+
runner = runner_config
|
97
|
+
runner.content = runner_content(binding)
|
98
|
+
|
99
|
+
Buildr.write(runner.file, runner.content)
|
100
|
+
rm_f runner.result
|
101
|
+
|
102
|
+
if RUBY_PLATFORM[/java/] && !options.fork
|
103
|
+
runtime = new_runtime
|
104
|
+
runtime.getObject.java.lang.System.getProperties().putAll(options[:properties] || {})
|
105
|
+
runtime.getLoadService.require runner.file
|
106
|
+
else
|
107
|
+
cmd_options = task.options.only(:properties, :java_args)
|
108
|
+
cmd_options.update(:classpath => dependencies, :project => task.project)
|
109
|
+
jruby runner.file, tests, cmd_options rescue nil
|
110
|
+
end
|
111
|
+
|
112
|
+
fail "Missing result YAML file: #{runner.result}" unless File.exist? runner.result
|
113
|
+
|
114
|
+
result = YAML.load(File.read(runner.result))
|
115
|
+
if Exception === result
|
116
|
+
raise [result.message, result.backtrace].flatten.join("\n")
|
117
|
+
end
|
118
|
+
tests - result.failed
|
119
|
+
end
|
120
|
+
|
121
|
+
def jruby_home
|
122
|
+
@jruby_home ||= RUBY_PLATFORM =~ /java/ ? Config::CONFIG['prefix'] :
|
123
|
+
( ENV['JRUBY_HOME'] || File.expand_path('~/.jruby') )
|
124
|
+
end
|
125
|
+
|
126
|
+
def jruby_installed?
|
127
|
+
!Dir.glob(File.join(jruby_home, 'lib', 'jruby*.jar')).empty?
|
128
|
+
end
|
129
|
+
|
130
|
+
protected
|
131
|
+
def maybe_install_jruby
|
132
|
+
unless jruby_installed?
|
133
|
+
jruby_artifact = Buildr.artifact(TestFramework::JRubyBased.jruby_artifact)
|
134
|
+
msg = "JRUBY_HOME is not correctly set or points to an invalid JRuby installation: #{jruby_home}"
|
135
|
+
say msg
|
136
|
+
say ''
|
137
|
+
say "You need to install JRuby version #{jruby_artifact.version} using your system package manager."
|
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.send :gem, name, version
|
179
|
+
rescue LoadError, Gem::LoadError => e
|
180
|
+
require 'rubygems/gem_runner'
|
181
|
+
args = ['install', name, '--version', version] + args
|
182
|
+
Gem::GemRunner.new.run(args)
|
183
|
+
Kernel.send :gem, name, version
|
184
|
+
end
|
185
|
+
end
|
186
|
+
}
|
187
|
+
end
|
188
|
+
|
189
|
+
def runner_config(runner = OpenStruct.new)
|
190
|
+
[:requires, :gems, :output, :format].each do |key|
|
191
|
+
runner.send("#{key}=", options[key])
|
192
|
+
end
|
193
|
+
runner.html_report ||= File.join(task.report_to.to_s, 'report.html')
|
194
|
+
runner.result ||= task.project.path_to(:target, :spec, 'result.yaml')
|
195
|
+
runner.file ||= task.project.path_to(:target, :spec, 'runner.rb')
|
196
|
+
runner.requires ||= []
|
197
|
+
runner.requires.unshift File.join(File.dirname(__FILE__), 'test_result')
|
198
|
+
runner.gems ||= {}
|
199
|
+
runner.rspec ||= ['--format', 'progress', '--format', "html:#{runner.html_report}"]
|
200
|
+
runner.format.each { |format| runner.rspec << '--format' << format } if runner.format
|
201
|
+
runner.rspec.push '--format', "Buildr::TestFramework::TestResult::YamlFormatter"
|
202
|
+
runner.rspec.push '-o', 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 suppress 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')].select do |name|
|
238
|
+
selector = ENV['SPEC']
|
239
|
+
selector.nil? || Regexp.new(selector) === name
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
def runner_config
|
244
|
+
runner = super
|
245
|
+
runner.gems.update 'rspec' => '~> 2.1.0'
|
246
|
+
runner.requires.unshift 'rspec'
|
247
|
+
runner
|
248
|
+
end
|
249
|
+
|
250
|
+
def runner_content(binding)
|
251
|
+
runner_erb = %q{
|
252
|
+
<%= jruby_gem %>
|
253
|
+
<%= dependencies.inspect %>.each { |dep| $CLASSPATH << dep }
|
254
|
+
<%= runner.gems.inspect %>.each { |ary| JRuby.gem(*ary.flatten) }
|
255
|
+
<%= runner.requires.inspect %>.each { |rb| Kernel.require rb }
|
256
|
+
<% if runner.output == false %>
|
257
|
+
output = StringIO.new
|
258
|
+
<% elsif runner.output.kind_of?(String) %>
|
259
|
+
output = File.open(<%= result.output.inspect %>, 'w')
|
260
|
+
<% else %>
|
261
|
+
output = STDOUT
|
262
|
+
<% end %>
|
263
|
+
parser = ::RSpec::Core::Parser.new
|
264
|
+
argv = <%= runner.rspec.inspect %> || []
|
265
|
+
argv.push *<%= tests.inspect %>
|
266
|
+
|
267
|
+
Buildr::TestFramework::TestResult::Error.guard('<%= runner.result %>') do
|
268
|
+
::RSpec::Core::CommandLine.new(argv).run(output, output)
|
269
|
+
end
|
270
|
+
exit 0 # let buildr figure the result from the yaml file
|
271
|
+
}
|
272
|
+
Filter::Mapper.new(:erb, binding).transform(runner_erb)
|
273
|
+
end
|
274
|
+
|
275
|
+
end
|
276
|
+
|
277
|
+
# <a href="http://jtestr.codehaus.org/">JtestR</a> is a framework for BDD and TDD using JRuby and ruby tools.
|
278
|
+
# To test your project with JtestR use:
|
279
|
+
# test.using :jtestr
|
280
|
+
#
|
281
|
+
#
|
282
|
+
# Support the following options:
|
283
|
+
# * :config -- path to JtestR config file. defaults to @spec/ruby/jtestr_config.rb@
|
284
|
+
# * :gems -- A hash of gems to install before running the tests.
|
285
|
+
# The keys of this hash are the gem name, the value must be the required version.
|
286
|
+
# * :requires -- A list of ruby files to require before running the specs
|
287
|
+
# Mainly used if an rspec format needs to require some file.
|
288
|
+
# * :format -- A list of valid Rspec --format option values. (defaults to 'progress')
|
289
|
+
# * :output -- File path to output dump. @false@ to supress output
|
290
|
+
# * :fork -- Create a new JavaVM to run the tests on
|
291
|
+
# * :properties -- Hash of properties passed to the test suite.
|
292
|
+
# * :java_args -- Arguments passed to the JVM.
|
293
|
+
class JtestR < TestFramework::JavaBDD
|
294
|
+
@lang = :ruby
|
295
|
+
@bdd_dir = :spec
|
296
|
+
|
297
|
+
include TestFramework::JRubyBased
|
298
|
+
|
299
|
+
VERSION = '0.6'
|
300
|
+
|
301
|
+
# pattern for rspec stories
|
302
|
+
STORY_PATTERN = /_(steps|story)\.rb$/
|
303
|
+
# pattern for test_unit files
|
304
|
+
TESTUNIT_PATTERN = /(_test|Test)\.rb$|(tc|ts)[^\\\/]+\.rb$/
|
305
|
+
# pattern for test files using http://expectations.rubyforge.org/
|
306
|
+
EXPECT_PATTERN = /_expect\.rb$/
|
307
|
+
|
308
|
+
TESTS_PATTERN = [STORY_PATTERN, TESTUNIT_PATTERN, EXPECT_PATTERN] + RSpec::TESTS_PATTERN
|
309
|
+
|
310
|
+
class << self
|
311
|
+
|
312
|
+
def version
|
313
|
+
Buildr.settings.build['jtestr'] || VERSION
|
314
|
+
end
|
315
|
+
|
316
|
+
def dependencies
|
317
|
+
unless @dependencies
|
318
|
+
super
|
319
|
+
@dependencies |= ["org.jtestr:jtestr:jar:#{version}"] +
|
320
|
+
JUnit.dependencies + TestNG.dependencies
|
321
|
+
end
|
322
|
+
@dependencies
|
323
|
+
end
|
324
|
+
|
325
|
+
def applies_to?(project) #:nodoc:
|
326
|
+
File.exist?(project.path_to(:source, bdd_dir, lang, 'jtestr_config.rb')) ||
|
327
|
+
Dir[project.path_to(:source, bdd_dir, lang, '**/*.rb')].any? { |f| TESTS_PATTERN.any? { |r| r === f } } ||
|
328
|
+
JUnit.applies_to?(project) || TestNG.applies_to?(project)
|
329
|
+
end
|
330
|
+
|
331
|
+
private
|
332
|
+
def const_missing(const)
|
333
|
+
return super unless const == :REQUIRES # TODO: remove in 1.5
|
334
|
+
Buildr.application.deprecated 'Please use JtestR.dependencies/.version instead of JtestR::REQUIRES/VERSION'
|
335
|
+
dependencies
|
336
|
+
end
|
337
|
+
|
338
|
+
end
|
339
|
+
|
340
|
+
def initialize(task, options) #:nodoc:
|
341
|
+
super
|
342
|
+
[:test, :spec].each do |usage|
|
343
|
+
java_tests = task.project.path_to(:source, usage, :java)
|
344
|
+
task.compile.from java_tests if File.directory?(java_tests)
|
345
|
+
resources = task.project.path_to(:source, usage, :resources)
|
346
|
+
task.resources.from resources if File.directory?(resources)
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
def user_config
|
351
|
+
options[:config] || task.project.path_to(:source, bdd_dir, lang, 'jtestr_config.rb')
|
352
|
+
end
|
353
|
+
|
354
|
+
def tests(dependencies) #:nodoc:
|
355
|
+
dependencies |= [task.compile.target.to_s]
|
356
|
+
types = { :story => STORY_PATTERN, :rspec => RSpec::TESTS_PATTERN,
|
357
|
+
:testunit => TESTUNIT_PATTERN, :expect => EXPECT_PATTERN }
|
358
|
+
tests = types.keys.inject({}) { |h, k| h[k] = []; h }
|
359
|
+
tests[:junit] = JUnit.new(task, {}).tests(dependencies)
|
360
|
+
tests[:testng] = TestNG.new(task, {}).tests(dependencies)
|
361
|
+
Dir[task.project.path_to(:source, bdd_dir, lang, '**/*.rb')].each do |rb|
|
362
|
+
type = types.find { |k, v| Array(v).any? { |r| r === rb } }
|
363
|
+
tests[type.first] << rb if type
|
364
|
+
end
|
365
|
+
@jtestr_tests = tests
|
366
|
+
tests.values.flatten
|
367
|
+
end
|
368
|
+
|
369
|
+
def runner_config
|
370
|
+
runner = super
|
371
|
+
# JtestR 0.6.0 comes with rspec 1.3.0 (and any other jtestr dependency) included,
|
372
|
+
# so the rspec version used depends on the jtestr jar.
|
373
|
+
runner.requires.unshift 'jtestr'
|
374
|
+
runner.gems.update 'rspec' => '=1.3.0'
|
375
|
+
runner.requires.unshift 'spec'
|
376
|
+
runner.requires.unshift File.join(File.dirname(__FILE__), 'jtestr_result')
|
377
|
+
runner.rspec = ['--format', 'progress', '--format', "html:#{runner.html_report}"]
|
378
|
+
runner.format.each { |format| runner.rspec << '--format' << format } if runner.format
|
379
|
+
runner.rspec.push '--format', "Buildr::JtestR::YamlFormatter:#{runner.result}"
|
380
|
+
runner
|
381
|
+
end
|
382
|
+
|
383
|
+
def runner_content(binding)
|
384
|
+
runner_erb = File.join(File.dirname(__FILE__), 'jtestr_runner.rb.erb')
|
385
|
+
Filter::Mapper.new(:erb, binding).transform(File.read(runner_erb), runner_erb)
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
389
|
+
# JBehave is a Java BDD framework. To use in your project:
|
390
|
+
# test.using :jbehave
|
391
|
+
#
|
392
|
+
# This framework will search in your project for:
|
393
|
+
# src/spec/java/**/*Behaviour.java
|
394
|
+
#
|
395
|
+
# JMock libraries are included on runtime.
|
396
|
+
#
|
397
|
+
# Support the following options:
|
398
|
+
# * :properties -- Hash of properties to the test suite
|
399
|
+
# * :java_args -- Arguments passed to the JVM
|
400
|
+
class JBehave < TestFramework::JavaBDD
|
401
|
+
@lang = :java
|
402
|
+
@bdd_dir = :spec
|
403
|
+
|
404
|
+
VERSION = '1.0.1'
|
405
|
+
TESTS_PATTERN = [ /Behaviou?r$/ ] #:nodoc:
|
406
|
+
|
407
|
+
class << self
|
408
|
+
def version
|
409
|
+
Buildr.settings.build['jbehave'] || VERSION
|
410
|
+
end
|
411
|
+
|
412
|
+
def dependencies
|
413
|
+
unless @dependencies
|
414
|
+
super
|
415
|
+
@dependencies |= ["org.jbehave:jbehave:jar:#{version}", 'cglib:cglib-full:jar:2.0.2'] +
|
416
|
+
JMock.dependencies + JUnit.dependencies
|
417
|
+
end
|
418
|
+
@dependencies
|
419
|
+
end
|
420
|
+
|
421
|
+
def applies_to?(project) #:nodoc:
|
422
|
+
%w{
|
423
|
+
**/*Behaviour.java **/*Behavior.java
|
424
|
+
}.any? { |glob| !Dir[project.path_to(:source, bdd_dir, lang, glob)].empty? }
|
425
|
+
end
|
426
|
+
|
427
|
+
private
|
428
|
+
def const_missing(const)
|
429
|
+
return super unless const == :REQUIRES # TODO: remove in 1.5
|
430
|
+
Buildr.application.deprecated 'Please use JBehave.dependencies/.version instead of JBehave::REQUIRES/VERSION'
|
431
|
+
dependencies
|
432
|
+
end
|
433
|
+
end
|
434
|
+
|
435
|
+
def tests(dependencies) #:nodoc:
|
436
|
+
filter_classes(dependencies, :class_names => TESTS_PATTERN,
|
437
|
+
:interfaces => %w{ org.jbehave.core.behaviour.Behaviours })
|
438
|
+
end
|
439
|
+
|
440
|
+
def run(tests, dependencies) #:nodoc:
|
441
|
+
cmd_args = ['org.jbehave.core.BehaviourRunner']
|
442
|
+
cmd_options = { :properties=>options[:properties], :java_args=>options[:java_args], :classpath=>dependencies }
|
443
|
+
tests.inject([]) do |passed, test|
|
444
|
+
begin
|
445
|
+
Java::Commands.java cmd_args, test, cmd_options
|
446
|
+
passed << test
|
447
|
+
rescue
|
448
|
+
passed
|
449
|
+
end
|
450
|
+
end
|
451
|
+
end
|
452
|
+
|
453
|
+
end
|
454
|
+
|
455
|
+
end
|
456
|
+
|
457
|
+
Buildr::TestFramework << Buildr::RSpec
|
458
|
+
Buildr::TestFramework << Buildr::JtestR
|
459
|
+
Buildr::TestFramework << Buildr::JBehave
|
460
|
+
|