buildr 1.3.5-x86-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +998 -0
- data/LICENSE +176 -0
- data/NOTICE +26 -0
- data/README.rdoc +134 -0
- data/Rakefile +45 -0
- data/_buildr +29 -0
- data/_jbuildr +29 -0
- data/addon/buildr/antlr.rb +65 -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 +142 -0
- data/addon/buildr/javacc.rb +85 -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 +90 -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/xmlbeans.rb +93 -0
- data/bin/buildr +19 -0
- data/buildr.buildfile +58 -0
- data/buildr.gemspec +65 -0
- data/doc/_config.yml +1 -0
- data/doc/_layouts/default.html +88 -0
- data/doc/_layouts/preface.html +22 -0
- data/doc/artifacts.textile +211 -0
- data/doc/building.textile +244 -0
- data/doc/contributing.textile +252 -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 +79 -0
- data/doc/extending.textile +186 -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 +69 -0
- data/doc/installing.textile +266 -0
- data/doc/languages.textile +459 -0
- data/doc/mailing_lists.textile +25 -0
- data/doc/more_stuff.textile +457 -0
- data/doc/packaging.textile +430 -0
- data/doc/preface.textile +54 -0
- data/doc/projects.textile +271 -0
- data/doc/quick_start.textile +210 -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 +72 -0
- data/doc/scripts/install-osx.sh +52 -0
- data/doc/settings_profiles.textile +280 -0
- data/doc/testing.textile +222 -0
- data/etc/KEYS +151 -0
- data/lib/buildr.rb +36 -0
- data/lib/buildr/core.rb +35 -0
- data/lib/buildr/core/application.rb +656 -0
- data/lib/buildr/core/build.rb +452 -0
- data/lib/buildr/core/checks.rb +254 -0
- data/lib/buildr/core/common.rb +150 -0
- data/lib/buildr/core/compile.rb +608 -0
- data/lib/buildr/core/environment.rb +129 -0
- data/lib/buildr/core/filter.rb +362 -0
- data/lib/buildr/core/generate.rb +195 -0
- data/lib/buildr/core/help.rb +119 -0
- data/lib/buildr/core/osx.rb +46 -0
- data/lib/buildr/core/progressbar.rb +156 -0
- data/lib/buildr/core/project.rb +866 -0
- data/lib/buildr/core/shell.rb +198 -0
- data/lib/buildr/core/test.rb +723 -0
- data/lib/buildr/core/transports.rb +559 -0
- data/lib/buildr/core/util.rb +449 -0
- data/lib/buildr/groovy.rb +19 -0
- data/lib/buildr/groovy/bdd.rb +106 -0
- data/lib/buildr/groovy/compiler.rb +138 -0
- data/lib/buildr/groovy/shell.rb +48 -0
- data/lib/buildr/ide.rb +19 -0
- data/lib/buildr/ide/eclipse.rb +334 -0
- data/lib/buildr/ide/eclipse/java.rb +53 -0
- data/lib/buildr/ide/eclipse/plugin.rb +68 -0
- data/lib/buildr/ide/eclipse/scala.rb +66 -0
- data/lib/buildr/ide/idea.ipr.template +300 -0
- data/lib/buildr/ide/idea.rb +190 -0
- data/lib/buildr/ide/idea7x.ipr.template +290 -0
- data/lib/buildr/ide/idea7x.rb +212 -0
- data/lib/buildr/java.rb +23 -0
- data/lib/buildr/java/ant.rb +94 -0
- data/lib/buildr/java/bdd.rb +459 -0
- data/lib/buildr/java/cobertura.rb +274 -0
- data/lib/buildr/java/commands.rb +213 -0
- data/lib/buildr/java/compiler.rb +349 -0
- data/lib/buildr/java/deprecated.rb +141 -0
- data/lib/buildr/java/emma.rb +244 -0
- data/lib/buildr/java/jruby.rb +117 -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 +137 -0
- data/lib/buildr/java/packaging.rb +716 -0
- data/lib/buildr/java/pom.rb +174 -0
- data/lib/buildr/java/rjb.rb +155 -0
- data/lib/buildr/java/test_result.rb +353 -0
- data/lib/buildr/java/tests.rb +333 -0
- data/lib/buildr/java/version_requirement.rb +172 -0
- data/lib/buildr/packaging.rb +24 -0
- data/lib/buildr/packaging/archive.rb +488 -0
- data/lib/buildr/packaging/artifact.rb +749 -0
- data/lib/buildr/packaging/artifact_namespace.rb +972 -0
- data/lib/buildr/packaging/artifact_search.rb +140 -0
- data/lib/buildr/packaging/gems.rb +102 -0
- data/lib/buildr/packaging/package.rb +238 -0
- data/lib/buildr/packaging/tar.rb +186 -0
- data/lib/buildr/packaging/version_requirement.rb +172 -0
- data/lib/buildr/packaging/zip.rb +73 -0
- data/lib/buildr/packaging/ziptask.rb +316 -0
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/scala.rb +25 -0
- data/lib/buildr/scala/bdd.rb +109 -0
- data/lib/buildr/scala/compiler.rb +195 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +35 -0
- data/lib/buildr/scala/shell.rb +55 -0
- data/lib/buildr/scala/tests.rb +157 -0
- data/lib/buildr/shell.rb +180 -0
- data/rakelib/checks.rake +57 -0
- data/rakelib/doc.rake +92 -0
- data/rakelib/jekylltask.rb +120 -0
- data/rakelib/package.rake +73 -0
- data/rakelib/release.rake +149 -0
- data/rakelib/rspec.rake +73 -0
- data/rakelib/setup.rake +54 -0
- data/rakelib/stage.rake +213 -0
- data/rakelib/stage.rake~ +213 -0
- data/spec/addon/drb_spec.rb +328 -0
- data/spec/core/application_spec.rb +502 -0
- data/spec/core/build_spec.rb +677 -0
- data/spec/core/checks_spec.rb +519 -0
- data/spec/core/common_spec.rb +670 -0
- data/spec/core/compile_spec.rb +583 -0
- data/spec/core/extension_spec.rb +93 -0
- data/spec/core/generate_spec.rb +33 -0
- data/spec/core/project_spec.rb +762 -0
- data/spec/core/test_spec.rb +1098 -0
- data/spec/core/transport_spec.rb +537 -0
- data/spec/core/util_spec.rb +67 -0
- data/spec/groovy/bdd_spec.rb +80 -0
- data/spec/groovy/compiler_spec.rb +240 -0
- data/spec/ide/eclipse_spec.rb +501 -0
- data/spec/ide/idea7x_spec.rb +84 -0
- data/spec/java/ant_spec.rb +33 -0
- data/spec/java/bdd_spec.rb +382 -0
- data/spec/java/cobertura_spec.rb +85 -0
- data/spec/java/compiler_spec.rb +446 -0
- data/spec/java/emma_spec.rb +119 -0
- data/spec/java/java_spec.rb +124 -0
- data/spec/java/packaging_spec.rb +1134 -0
- data/spec/java/test_coverage_helper.rb +257 -0
- data/spec/java/tests_spec.rb +493 -0
- data/spec/packaging/archive_spec.rb +527 -0
- data/spec/packaging/artifact_namespace_spec.rb +654 -0
- data/spec/packaging/artifact_spec.rb +795 -0
- data/spec/packaging/packaging_helper.rb +63 -0
- data/spec/packaging/packaging_spec.rb +684 -0
- data/spec/sandbox.rb +142 -0
- data/spec/scala/bdd_spec.rb +119 -0
- data/spec/scala/compiler_spec.rb +284 -0
- data/spec/scala/scala.rb +38 -0
- data/spec/scala/tests_spec.rb +261 -0
- data/spec/spec_helpers.rb +340 -0
- data/spec/version_requirement_spec.rb +129 -0
- metadata +383 -0
@@ -0,0 +1,244 @@
|
|
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'
|
18
|
+
|
19
|
+
|
20
|
+
module Buildr
|
21
|
+
|
22
|
+
# Provides the <code>emma:html</code> and <code>emma:xml</code> tasks.
|
23
|
+
# Require explicitly using <code>require "buildr/emma"</code>.
|
24
|
+
#
|
25
|
+
# You can generate emma reports for a single project
|
26
|
+
# using the project name as prefix:
|
27
|
+
#
|
28
|
+
# project_name:emma:html
|
29
|
+
#
|
30
|
+
# You can also specify which classes to include/exclude from instrumentation by
|
31
|
+
# passing a class name regexp to the <code>emma.include</code> or
|
32
|
+
# <code>emma.exclude</code> methods.
|
33
|
+
#
|
34
|
+
# define 'someModule' do
|
35
|
+
# emma.include 'some.package.*'
|
36
|
+
# emma.exclude 'some.foo.util.SimpleUtil'
|
37
|
+
# end
|
38
|
+
module Emma
|
39
|
+
|
40
|
+
VERSION = '2.0.5312'
|
41
|
+
|
42
|
+
class << self
|
43
|
+
|
44
|
+
def version
|
45
|
+
Buildr.settings.build['emma'] || VERSION
|
46
|
+
end
|
47
|
+
|
48
|
+
def dependencies
|
49
|
+
@dependencies ||= ["emma:emma_ant:jar:#{version}", "emma:emma:jar:#{version}"]
|
50
|
+
end
|
51
|
+
|
52
|
+
def report_to format=nil
|
53
|
+
File.expand_path('reports/emma')
|
54
|
+
end
|
55
|
+
|
56
|
+
def data_file()
|
57
|
+
File.join(report_to, 'coverage.es')
|
58
|
+
end
|
59
|
+
|
60
|
+
def ant
|
61
|
+
|
62
|
+
Buildr.ant 'emma' do |ant|
|
63
|
+
ant.taskdef :resource=>'emma_ant.properties',
|
64
|
+
:classpath=>Buildr.artifacts(dependencies).each(&:invoke).map(&:to_s).join(File::PATH_SEPARATOR)
|
65
|
+
ant.emma :verbosity=>(Buildr.application.options.trace ? 'verbose' : 'warning') do
|
66
|
+
yield ant
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
class EmmaConfig # :nodoc:
|
73
|
+
|
74
|
+
def initialize(project)
|
75
|
+
@project = project
|
76
|
+
end
|
77
|
+
|
78
|
+
attr_reader :project
|
79
|
+
private :project
|
80
|
+
|
81
|
+
attr_writer :metadata_file, :coverage_file, :instrumented_dir, :report_dir
|
82
|
+
|
83
|
+
def coverage_file
|
84
|
+
@coverage_file ||= File.join(report_dir, 'coverage.ec')
|
85
|
+
end
|
86
|
+
|
87
|
+
def metadata_file
|
88
|
+
@metadata_file ||= File.join(report_dir, 'coverage.em')
|
89
|
+
end
|
90
|
+
|
91
|
+
def instrumented_dir
|
92
|
+
@instrumented_dir ||= project.path_to(:target, :instrumented, :classes)
|
93
|
+
end
|
94
|
+
|
95
|
+
def report_dir
|
96
|
+
@report_dir ||= project.path_to(:reports, :emma)
|
97
|
+
end
|
98
|
+
|
99
|
+
def report_to format
|
100
|
+
report_dir
|
101
|
+
end
|
102
|
+
|
103
|
+
# :call-seq:
|
104
|
+
# project.emma.include(*classPatterns)
|
105
|
+
#
|
106
|
+
def include(*classPatterns)
|
107
|
+
includes.push(*classPatterns)
|
108
|
+
self
|
109
|
+
end
|
110
|
+
|
111
|
+
def includes
|
112
|
+
@includeClasses ||= []
|
113
|
+
end
|
114
|
+
|
115
|
+
# :call-seq:
|
116
|
+
# project.emma.exclude(*classPatterns)
|
117
|
+
#
|
118
|
+
def exclude(*classPatterns)
|
119
|
+
excludes.push(*classPatterns)
|
120
|
+
self
|
121
|
+
end
|
122
|
+
|
123
|
+
def excludes
|
124
|
+
@excludeClasses ||= []
|
125
|
+
end
|
126
|
+
|
127
|
+
def sources
|
128
|
+
project.compile.sources
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
module EmmaExtension # :nodoc:
|
133
|
+
include Buildr::Extension
|
134
|
+
|
135
|
+
def emma
|
136
|
+
@emma_config ||= EmmaConfig.new(self)
|
137
|
+
end
|
138
|
+
|
139
|
+
after_define do |project|
|
140
|
+
emma = project.emma
|
141
|
+
|
142
|
+
namespace 'emma' do
|
143
|
+
unless project.compile.target.nil?
|
144
|
+
# Instrumented bytecode goes in a different directory. This task creates before running the test
|
145
|
+
# cases and monitors for changes in the generate bytecode.
|
146
|
+
instrumented = project.file(emma.instrumented_dir => project.compile.target) do |task|
|
147
|
+
unless project.compile.sources.empty?
|
148
|
+
info "Instrumenting classes with emma metadata file #{emma.metadata_file}"
|
149
|
+
Emma.ant do |ant|
|
150
|
+
ant.instr :instrpath=>project.compile.target.to_s, :destdir=>task.to_s, :metadatafile=>emma.metadata_file do
|
151
|
+
ant.filter :includes=>emma.includes.join(', ') unless emma.includes.empty?
|
152
|
+
ant.filter :excludes=>emma.excludes.join(', ') unless emma.excludes.empty?
|
153
|
+
end
|
154
|
+
end
|
155
|
+
touch task.to_s
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
task 'instrument' => instrumented
|
160
|
+
|
161
|
+
# We now have two target directories with bytecode.
|
162
|
+
project.test.dependencies.unshift emma.instrumented_dir
|
163
|
+
project.test.with Emma.dependencies
|
164
|
+
project.test.options[:properties]["emma.coverage.out.file"] = emma.coverage_file
|
165
|
+
|
166
|
+
[:xml, :html].each do |format|
|
167
|
+
task format => ['instrument', 'test'] do
|
168
|
+
missing_required_files = [emma.metadata_file, emma.coverage_file].reject { |f| File.exist?(f) }
|
169
|
+
if missing_required_files.empty?
|
170
|
+
info "Creating test coverage reports in #{emma.report_dir}"
|
171
|
+
mkdir_p emma.report_dir
|
172
|
+
Emma.ant do |ant|
|
173
|
+
ant.report do
|
174
|
+
ant.infileset :file=>emma.metadata_file
|
175
|
+
ant.infileset :file=>emma.coverage_file
|
176
|
+
ant.send format, :outfile=>File.join(emma.report_to(format),"coverage.#{format}")
|
177
|
+
ant.sourcepath do
|
178
|
+
emma.sources.flatten.each do |src|
|
179
|
+
ant.dirset(:dir=>src.to_s) if File.exist?(src.to_s)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
else
|
185
|
+
info "No test coverage report for #{project}. Missing: #{missing_required_files.join(', ')}"
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
project.clean do
|
193
|
+
rm_rf [emma.report_dir, emma.coverage_file, emma.metadata_file, emma.instrumented_dir]
|
194
|
+
end
|
195
|
+
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|
199
|
+
|
200
|
+
class Buildr::Project
|
201
|
+
include EmmaExtension
|
202
|
+
end
|
203
|
+
|
204
|
+
namespace "emma" do
|
205
|
+
|
206
|
+
Project.local_task('instrument') { |name| "Instrumenting #{name}" }
|
207
|
+
|
208
|
+
[:xml, :html].each do |format|
|
209
|
+
desc "Run the test cases and produce code coverage reports in #{format}"
|
210
|
+
task format => ['instrument', 'test'] do
|
211
|
+
info "Creating test coverage reports in #{format}"
|
212
|
+
mkdir_p report_to(format)
|
213
|
+
Emma.ant do |ant|
|
214
|
+
ant.merge :outfile=>data_file do
|
215
|
+
Buildr.projects.each do |project|
|
216
|
+
[project.emma.metadata_file, project.emma.coverage_file].each do |data_file|
|
217
|
+
ant.fileset :file=>data_file if File.exist?(data_file)
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
ant.report do
|
222
|
+
ant.infileset :file=>data_file
|
223
|
+
ant.send format, :outfile=>File.join(report_to(format), "coverage.#{format}")
|
224
|
+
ant.sourcepath do
|
225
|
+
Buildr.projects.map(&:emma).map(&:sources).flatten.map(&:to_s).each do |src|
|
226
|
+
ant.dirset :dir=>src if File.exist?(src)
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
task :clean do
|
235
|
+
rm_rf [report_to, data_file]
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
task :clean do
|
240
|
+
task('emma:clean').invoke if Dir.pwd == Rake.application.original_dir
|
241
|
+
end
|
242
|
+
|
243
|
+
end
|
244
|
+
end
|
@@ -0,0 +1,117 @@
|
|
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 'java'
|
18
|
+
require 'jruby'
|
19
|
+
|
20
|
+
|
21
|
+
# Buildr runs along side a JVM, using either RJB or JRuby. The Java module allows
|
22
|
+
# you to access Java classes and create Java objects.
|
23
|
+
#
|
24
|
+
# Java classes are accessed as static methods on the Java module, for example:
|
25
|
+
# str = Java.java.lang.String.new('hai!')
|
26
|
+
# str.toUpperCase
|
27
|
+
# => 'HAI!'
|
28
|
+
# Java.java.lang.String.isInstance(str)
|
29
|
+
# => true
|
30
|
+
# Java.com.sun.tools.javac.Main.compile(args)
|
31
|
+
#
|
32
|
+
# The classpath attribute allows Buildr to add JARs and directories to the classpath,
|
33
|
+
# for example, we use it to load Ant and various Ant tasks, code generators, test
|
34
|
+
# frameworks, and so forth.
|
35
|
+
#
|
36
|
+
# When using an artifact specification, Buildr will automatically download and
|
37
|
+
# install the artifact before adding it to the classpath.
|
38
|
+
#
|
39
|
+
# For example, Ant is loaded as follows:
|
40
|
+
# Java.classpath << 'org.apache.ant:ant:jar:1.7.0'
|
41
|
+
#
|
42
|
+
# Artifacts can only be downloaded after the Buildfile has loaded, giving it
|
43
|
+
# a chance to specify which remote repositories to use, so adding to classpath
|
44
|
+
# does not by itself load any libraries. You must call Java.load before accessing
|
45
|
+
# any Java classes to give Buildr a chance to load the libraries specified in the
|
46
|
+
# classpath.
|
47
|
+
#
|
48
|
+
# When building an extension, make sure to follow these rules:
|
49
|
+
# 1. Add to the classpath when the extension is loaded (i.e. in module or class
|
50
|
+
# definition), so the first call to Java.load anywhere in the code will include
|
51
|
+
# the libraries you specify.
|
52
|
+
# 2. Call Java.load once before accessing any Java classes, allowing Buildr to
|
53
|
+
# set up the classpath.
|
54
|
+
# 3. Only call Java.load when invoked, otherwise you may end up loading the JVM
|
55
|
+
# with a partial classpath, or before all remote repositories are listed.
|
56
|
+
# 4. Check on a clean build with empty local repository.
|
57
|
+
module Java
|
58
|
+
|
59
|
+
# Since we already have a JVM loaded, we can use it to guess where JAVA_HOME is.
|
60
|
+
# We set JAVA_HOME early so we can use it without calling Java.load first.
|
61
|
+
ENV['JAVA_HOME'] ||= java.lang.System.getProperty("java.home")
|
62
|
+
|
63
|
+
class << self
|
64
|
+
|
65
|
+
# Returns the classpath, an array listing directories, JAR files and
|
66
|
+
# artifacts. Use when loading the extension to add any additional
|
67
|
+
# libraries used by that extension.
|
68
|
+
#
|
69
|
+
# For example, Ant is loaded as follows:
|
70
|
+
# Java.classpath << 'org.apache.ant:ant:jar:1.7.0'
|
71
|
+
def classpath
|
72
|
+
@classpath ||= []
|
73
|
+
end
|
74
|
+
|
75
|
+
# Most platforms requires tools.jar to be on the classpath, tools.jar contains the
|
76
|
+
# Java compiler (OS X and AIX are two exceptions we know about, may be more).
|
77
|
+
# Guess where tools.jar is from JAVA_HOME, which hopefully points to the JDK,
|
78
|
+
# but maybe the JRE. Return nil if not found.
|
79
|
+
def tools_jar #:nodoc:
|
80
|
+
@tools_jar ||= ['lib/tools.jar', '../lib/tools.jar'].map { |path| File.expand_path(path, ENV['JAVA_HOME']) }.
|
81
|
+
find { |path| File.exist?(path) }
|
82
|
+
end
|
83
|
+
|
84
|
+
# Loads the JVM and all the libraries listed on the classpath. Call this
|
85
|
+
# method before accessing any Java class, but only call it from methods
|
86
|
+
# used in the build, giving the Buildfile a chance to load all extensions
|
87
|
+
# that append to the classpath and specify which remote repositories to use.
|
88
|
+
def load
|
89
|
+
return self if @loaded
|
90
|
+
|
91
|
+
# Adding jars to the jruby's $CLASSPATH should be the correct thing, however it
|
92
|
+
# seems like some tools require their jars on system class loader (javadoc, junit, etc)
|
93
|
+
# cp.each { |path| $CLASSPATH << path }
|
94
|
+
|
95
|
+
# Use system ClassLoader to add classpath
|
96
|
+
sysloader = java.lang.ClassLoader.getSystemClassLoader
|
97
|
+
add_url_method = java.lang.Class.forName('java.net.URLClassLoader').
|
98
|
+
getDeclaredMethod('addURL', [java.net.URL.java_class].to_java(java.lang.Class))
|
99
|
+
add_url_method.setAccessible(true)
|
100
|
+
add_path = lambda { |path| add_url_method.invoke(sysloader, [java.io.File.new(path).toURI.toURL].to_java(java.net.URL)) }
|
101
|
+
|
102
|
+
# Most platforms requires tools.jar to be on the classpath.
|
103
|
+
add_path[tools_jar] if tools_jar
|
104
|
+
|
105
|
+
classpath.map! { |path| Proc === path ? path.call : path }
|
106
|
+
Buildr.artifacts(classpath).map(&:to_s).each do |path|
|
107
|
+
file(path).invoke
|
108
|
+
add_path[path]
|
109
|
+
end
|
110
|
+
|
111
|
+
@loaded = true
|
112
|
+
self
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
@@ -0,0 +1,116 @@
|
|
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
|
+
# | \ / _ \ | \| |/ _ \_ _| | __| \_ _|_ _| |_ _| || |_ _/ __|
|
18
|
+
# | |) | (_) | | .` | (_) || | | _|| |) | | | | | | | __ || |\__ \
|
19
|
+
# |___/ \___/ |_|\_|\___/ |_| |___|___/___| |_| |_| |_||_|___|___/
|
20
|
+
#
|
21
|
+
# ___ ___ _ ___
|
22
|
+
# | __|_ _| | | __| CHANGES TO THIS FILE WILL BE LOST
|
23
|
+
# | _| | || |__| _| AUTO-GENERATED BY BUILDR on <%= Time.now %>
|
24
|
+
# |_| |___|____|___| PREFER TO EDIT JtestR CONFIGURATION FILE:
|
25
|
+
#
|
26
|
+
# <%= user_config %>
|
27
|
+
|
28
|
+
begin
|
29
|
+
|
30
|
+
<%= jruby_gem %>
|
31
|
+
<%= dependencies.map(&:to_s).inspect %>.each { |dep| $CLASSPATH << dep }
|
32
|
+
<%= runner.gems.inspect %>.each { |ary| JRuby.gem(*ary.flatten) }
|
33
|
+
<%= runner.requires.inspect %>.each { |rb| Kernel.require rb }
|
34
|
+
|
35
|
+
jtestr = JtestR::TestRunner.new
|
36
|
+
|
37
|
+
class << jtestr
|
38
|
+
def config(&block)
|
39
|
+
@config_blocks ||= []
|
40
|
+
@config_blocks << block if block
|
41
|
+
@config_blocks
|
42
|
+
end
|
43
|
+
|
44
|
+
def load_configuration
|
45
|
+
super
|
46
|
+
config.each { |block| @configuration.instance_eval(&block) }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
jtestr.config do
|
51
|
+
classpath [] # already loaded
|
52
|
+
add_common_classpath false
|
53
|
+
|
54
|
+
<% ts = ( @jtestr_tests[:junit] & tests ).map { |c| 'Java.' + c } %>
|
55
|
+
junit [<%= ts.join(', ') %>]
|
56
|
+
|
57
|
+
<% ts = ( @jtestr_tests[:testng] & tests ).map { |c| 'Java.' + c } %>
|
58
|
+
testng [<%= ts.join(', ') %>]
|
59
|
+
|
60
|
+
<% ts = @jtestr_tests[:testunit] & tests %>
|
61
|
+
test_unit <%= ts.inspect %>
|
62
|
+
|
63
|
+
<% ts = @jtestr_tests[:story] & tests %>
|
64
|
+
story <%= ts.inspect %>
|
65
|
+
|
66
|
+
<% ts = @jtestr_tests[:rspec] & tests %>
|
67
|
+
rspec <%= ts.inspect %>
|
68
|
+
|
69
|
+
<% ts = @jtestr_tests[:expect] & tests %>
|
70
|
+
expectations <%= ts.inspect %>
|
71
|
+
|
72
|
+
ignore __FILE__
|
73
|
+
|
74
|
+
if File.file?(<%= user_config.inspect %>)
|
75
|
+
ignore <%= user_config.inspect %>
|
76
|
+
load <%= user_config.inspect %>
|
77
|
+
end
|
78
|
+
end # config
|
79
|
+
|
80
|
+
fake_out = StringIO.new
|
81
|
+
|
82
|
+
<% if runner.output == false %>
|
83
|
+
output = fake_out
|
84
|
+
<% elsif runner.output.kind_of?(String) %>
|
85
|
+
output = File.open(<%= result.output.inspect %>, 'w')
|
86
|
+
<% else %>
|
87
|
+
output = STDOUT
|
88
|
+
<% end %>
|
89
|
+
|
90
|
+
|
91
|
+
args = [ '<%= spec_dir %>', # the directory to search for jtestr files
|
92
|
+
JtestR::SimpleLogger::ERR, # log level
|
93
|
+
JtestR::GenericResultHandler::QUIET, #output level
|
94
|
+
fake_out, # output STDOUT
|
95
|
+
[], # groups to run
|
96
|
+
Buildr::TestFramework::TestResult::RSpecResultHandler, # result handler
|
97
|
+
[] # classpath
|
98
|
+
]
|
99
|
+
|
100
|
+
argv = <%= runner.rspec.inspect %> || []
|
101
|
+
argv.push *<%= tests.inspect %>
|
102
|
+
Buildr::TestFramework::TestResult::RSpecResultHandler.init(argv, output, output)
|
103
|
+
|
104
|
+
jtestr.run *args
|
105
|
+
|
106
|
+
rescue => e
|
107
|
+
Buildr::TestFramework::TestResult::Error.dump_yaml('<%= runner.result %>', e) rescue \
|
108
|
+
puts "-[--- ERROR ---]-", e.class, e.message, *e.backtrace
|
109
|
+
end
|
110
|
+
|
111
|
+
exit 0 # let buildr find the erros from the result yaml
|
112
|
+
|
113
|
+
# Local Variables:
|
114
|
+
# mode: ruby
|
115
|
+
# End:
|
116
|
+
|