vic-buildr 1.3.1 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +90 -8
- data/{README → README.rdoc} +29 -16
- data/Rakefile +17 -19
- data/_buildr +50 -0
- data/addon/buildr/cobertura.rb +47 -44
- data/addon/buildr/emma.rb +237 -0
- data/addon/buildr/jetty.rb +1 -1
- data/addon/buildr/nailgun.rb +581 -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/addon/buildr/xmlbeans.rb +1 -1
- data/bin/buildr +9 -2
- data/buildr.buildfile +53 -0
- data/buildr.gemspec +23 -15
- data/doc/css/default.css +51 -48
- data/doc/css/print.css +60 -55
- data/doc/css/syntax.css +40 -31
- 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 -324
- data/doc/pages/contributing.textile +116 -88
- data/doc/pages/download.textile +20 -15
- data/doc/pages/extending.textile +27 -81
- data/doc/pages/getting_started.textile +47 -111
- data/doc/pages/index.textile +19 -37
- data/doc/pages/languages.textile +407 -0
- data/doc/pages/more_stuff.textile +92 -173
- data/doc/pages/packaging.textile +72 -237
- 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 +66 -157
- data/doc/print.haml +0 -1
- data/doc/print.toc.yaml +1 -0
- data/doc/scripts/buildr-git.rb +1 -1
- data/doc/scripts/install-jruby.sh +1 -1
- data/doc/scripts/install-linux.sh +4 -4
- 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 -13
- data/lib/buildr/core/application.rb +200 -95
- data/lib/buildr/core/application_cli.rb +6 -1
- 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 +14 -12
- data/lib/buildr/core/filter.rb +151 -46
- data/lib/buildr/core/generate.rb +9 -7
- data/lib/buildr/core/progressbar.rb +1 -1
- data/lib/buildr/core/project.rb +8 -7
- data/lib/buildr/core/test.rb +54 -29
- data/lib/buildr/core/transports.rb +25 -20
- data/lib/buildr/core/util.rb +80 -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 +20 -20
- data/lib/buildr/java.rb +4 -7
- data/lib/buildr/java/ant.rb +26 -5
- data/lib/buildr/java/bdd.rb +447 -0
- data/lib/buildr/java/commands.rb +8 -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 +114 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +4 -1
- 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 +277 -0
- data/lib/buildr/java/{test_frameworks.rb → tests.rb} +121 -88
- 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 +31 -41
- data/rakelib/doc.rake +2 -2
- data/rakelib/package.rake +31 -2
- data/rakelib/rspec.rake +22 -20
- data/rakelib/rubyforge.rake +1 -0
- data/rakelib/setup.rake +34 -9
- data/spec/addon/cobertura_spec.rb +77 -0
- data/spec/addon/emma_spec.rb +120 -0
- data/spec/addon/test_coverage_spec.rb +249 -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} +1 -1
- data/spec/{common_spec.rb → core/common_spec.rb} +119 -30
- data/spec/{compile_spec.rb → core/compile_spec.rb} +17 -13
- data/spec/{project_spec.rb → core/project_spec.rb} +9 -6
- data/spec/{test_spec.rb → core/test_spec.rb} +226 -32
- data/spec/{transport_spec.rb → core/transport_spec.rb} +35 -23
- 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} +50 -10
- data/spec/{archive_spec.rb → packaging/archive_spec.rb} +12 -2
- data/spec/{artifact_spec.rb → packaging/artifact_spec.rb} +10 -3
- 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 +25 -4
- data/spec/{scala_compilers_spec.rb → scala/compiler_spec.rb} +1 -1
- data/spec/scala/tests_spec.rb +215 -0
- data/spec/spec_helpers.rb +38 -17
- metadata +119 -69
- data/lib/buildr/java/bdd_frameworks.rb +0 -265
- data/lib/buildr/java/groovyc.rb +0 -137
- data/spec/build_spec.rb +0 -193
- data/spec/java_bdd_frameworks_spec.rb +0 -238
- data/spec/spec.opts +0 -6
@@ -17,6 +17,8 @@
|
|
17
17
|
require 'cgi'
|
18
18
|
require 'net/http'
|
19
19
|
require 'net/https'
|
20
|
+
# PATCH: On Windows, Net::SSH 2.0.2 attempts to load the Pageant DLLs which break on JRuby.
|
21
|
+
$LOADED_FEATURES.unshift 'net/ssh/authentication/pageant' if RUBY_PLATFORM =~ /java/
|
20
22
|
require 'net/ssh'
|
21
23
|
require 'net/sftp'
|
22
24
|
require 'uri'
|
@@ -54,6 +56,9 @@ module URI
|
|
54
56
|
class NotFoundError < RuntimeError
|
55
57
|
end
|
56
58
|
|
59
|
+
# How many bytes to read/write at once.
|
60
|
+
RW_CHUNK_SIZE = 2 ** 20 #:nodoc:
|
61
|
+
|
57
62
|
class << self
|
58
63
|
|
59
64
|
# :call-seq:
|
@@ -290,7 +295,7 @@ module URI
|
|
290
295
|
def read(options = nil, &block)
|
291
296
|
options ||= {}
|
292
297
|
connect do |http|
|
293
|
-
|
298
|
+
trace "Requesting #{self}"
|
294
299
|
headers = { 'If-Modified-Since' => CGI.rfc1123_date(options[:modified].utc) } if options[:modified]
|
295
300
|
request = Net::HTTP::Get.new(request_uri.empty? ? '/' : request_uri, headers)
|
296
301
|
request.basic_auth self.user, self.password if self.user
|
@@ -298,14 +303,14 @@ module URI
|
|
298
303
|
case response
|
299
304
|
when Net::HTTPNotModified
|
300
305
|
# No modification, nothing to do.
|
301
|
-
|
306
|
+
trace 'Not modified since last download'
|
302
307
|
return nil
|
303
308
|
when Net::HTTPRedirection
|
304
309
|
# Try to download from the new URI, handle relative redirects.
|
305
|
-
|
310
|
+
trace "Redirected to #{response['Location']}"
|
306
311
|
return (self + URI.parse(response['location'])).read(options, &block)
|
307
312
|
when Net::HTTPOK
|
308
|
-
|
313
|
+
info "Downloading #{self}"
|
309
314
|
result = nil
|
310
315
|
with_progress_bar options[:progress], path.split('/').last, response.content_length do |progress|
|
311
316
|
if block
|
@@ -336,9 +341,9 @@ module URI
|
|
336
341
|
def write_internal(options, &block) #:nodoc:
|
337
342
|
options ||= {}
|
338
343
|
connect do |http|
|
339
|
-
|
344
|
+
trace "Uploading to #{path}"
|
340
345
|
content = StringIO.new
|
341
|
-
while chunk = yield(
|
346
|
+
while chunk = yield(RW_CHUNK_SIZE)
|
342
347
|
content << chunk
|
343
348
|
end
|
344
349
|
headers = { 'Content-MD5'=>Digest::MD5.hexdigest(content.string) }
|
@@ -361,7 +366,7 @@ module URI
|
|
361
366
|
case response
|
362
367
|
when Net::HTTPRedirection
|
363
368
|
# Try to download from the new URI, handle relative redirects.
|
364
|
-
|
369
|
+
trace "Redirected to #{response['Location']}"
|
365
370
|
content.rewind
|
366
371
|
return (self + URI.parse(response['location'])).write_internal(options) { |bytes| content.read(bytes) }
|
367
372
|
when Net::HTTPSuccess
|
@@ -406,23 +411,23 @@ module URI
|
|
406
411
|
ssh_options = { :port=>port, :password=>password }.merge(options[:ssh_options] || {})
|
407
412
|
ssh_options[:password] ||= SFTP.passwords[host]
|
408
413
|
begin
|
409
|
-
|
414
|
+
trace "Connecting to #{host}"
|
410
415
|
result = nil
|
411
416
|
Net::SFTP.start(host, user, ssh_options) do |sftp|
|
412
417
|
SFTP.passwords[host] = ssh_options[:password]
|
413
|
-
|
418
|
+
trace 'connected'
|
414
419
|
|
415
420
|
with_progress_bar options[:progress] && options[:size], path.split('/'), options[:size] || 0 do |progress|
|
416
|
-
|
421
|
+
trace "Downloading to #{path}"
|
417
422
|
sftp.file.open(path, 'r') do |file|
|
418
423
|
if block
|
419
|
-
while chunk = file.read(
|
424
|
+
while chunk = file.read(RW_CHUNK_SIZE)
|
420
425
|
block.call chunk
|
421
426
|
progress << chunk
|
422
427
|
end
|
423
428
|
else
|
424
429
|
result = ''
|
425
|
-
while chunk = file.read(
|
430
|
+
while chunk = file.read(RW_CHUNK_SIZE)
|
426
431
|
result << chunk
|
427
432
|
progress << chunk
|
428
433
|
end
|
@@ -449,24 +454,24 @@ module URI
|
|
449
454
|
ssh_options = { :port=>port, :password=>password }.merge(options[:ssh_options] || {})
|
450
455
|
ssh_options[:password] ||= SFTP.passwords[host]
|
451
456
|
begin
|
452
|
-
|
457
|
+
trace "Connecting to #{host}"
|
453
458
|
Net::SFTP.start(host, user, ssh_options) do |sftp|
|
454
459
|
SFTP.passwords[host] = ssh_options[:password]
|
455
|
-
|
460
|
+
trace 'Connected'
|
456
461
|
|
457
462
|
# To create a path, we need to create all its parent. We use realpath to determine if
|
458
463
|
# the path already exists, otherwise mkdir fails.
|
459
|
-
|
460
|
-
File.dirname(path).split('/').inject('') do |base, part|
|
464
|
+
trace "Creating path #{path}"
|
465
|
+
File.dirname(path).split('/').reject(&:empty?).inject('/') do |base, part|
|
461
466
|
combined = base + part
|
462
|
-
sftp.
|
467
|
+
sftp.close(sftp.opendir!(combined)) rescue sftp.mkdir! combined, {}
|
463
468
|
"#{combined}/"
|
464
469
|
end
|
465
470
|
|
466
471
|
with_progress_bar options[:progress] && options[:size], path.split('/'), options[:size] || 0 do |progress|
|
467
|
-
|
472
|
+
trace "Uploading to #{path}"
|
468
473
|
sftp.file.open(path, 'w') do |file|
|
469
|
-
while chunk = yield(
|
474
|
+
while chunk = yield(RW_CHUNK_SIZE)
|
470
475
|
file.write chunk
|
471
476
|
progress << chunk
|
472
477
|
end
|
@@ -553,7 +558,7 @@ module URI
|
|
553
558
|
Tempfile.open File.basename(path) do |temp|
|
554
559
|
temp.binmode
|
555
560
|
with_progress_bar options[:progress] && options[:size], path.split('/'), options[:size] || 0 do |progress|
|
556
|
-
while chunk = yield(
|
561
|
+
while chunk = yield(RW_CHUNK_SIZE)
|
557
562
|
temp.write chunk
|
558
563
|
progress << chunk
|
559
564
|
end
|
data/lib/buildr/core/util.rb
CHANGED
@@ -13,8 +13,10 @@
|
|
13
13
|
# License for the specific language governing permissions and limitations under
|
14
14
|
# the License.
|
15
15
|
|
16
|
+
|
16
17
|
require 'rbconfig'
|
17
18
|
require 'pathname'
|
19
|
+
require 'builder' # A different kind of buildr, one we use to create XML.
|
18
20
|
|
19
21
|
|
20
22
|
module Buildr
|
@@ -106,36 +108,77 @@ module Buildr
|
|
106
108
|
FileList[dirs.map { |dir| File.join(dir, '/**/{*,.*}') }].reject { |file| File.basename(file) =~ /^[.]{1,2}$/ }
|
107
109
|
end
|
108
110
|
|
109
|
-
|
110
|
-
|
111
|
+
# Utility methods for running gem commands
|
112
|
+
module Gems
|
113
|
+
extend self
|
114
|
+
|
115
|
+
# Install gems specified by each Gem::Dependency if they are missing. This method prompts the user
|
116
|
+
# for permission before installing anything.
|
117
|
+
#
|
118
|
+
# Returns the installed Gem::Dependency objects or fails if permission not granted or when buildr
|
119
|
+
# is not running interactively (on a tty)
|
120
|
+
def install(*dependencies)
|
121
|
+
raise ArgumentError, "Expected at least one argument" if dependencies.empty?
|
122
|
+
remote = dependencies.map { |dep| Gem::SourceInfoCache.search(dep).last || dep }
|
123
|
+
not_found_deps, to_install = remote.partition { |gem| gem.is_a?(Gem::Dependency) }
|
124
|
+
fail Gem::LoadError, "Build requires the gems #{not_found_deps.join(', ')}, which cannot be found in local or remote repository." unless not_found_deps.empty?
|
125
|
+
uses = "This build requires the gems #{to_install.map(&:full_name).join(', ')}:"
|
126
|
+
fail Gem::LoadError, "#{uses} to install, run Buildr interactively." unless $stdout.isatty
|
127
|
+
unless agree("#{uses} do you want me to install them? [Y/n]", true)
|
128
|
+
fail Gem::LoadError, 'Cannot build without these gems.'
|
129
|
+
end
|
130
|
+
to_install.each do |spec|
|
131
|
+
say "Installing #{spec.full_name} ... " if verbose
|
132
|
+
command 'install', spec.name, '-v', spec.version.to_s, :verbose => false
|
133
|
+
Gem.source_index.load_gems_in Gem::SourceIndex.installed_spec_directories
|
134
|
+
end
|
135
|
+
to_install
|
136
|
+
end
|
111
137
|
|
138
|
+
# Execute a GemRunner command
|
139
|
+
def command(cmd, *args)
|
140
|
+
options = Hash === args.last ? args.pop : {}
|
141
|
+
gem_home = ENV['GEM_HOME'] || Gem.path.find { |f| File.writable?(f) }
|
142
|
+
options[:sudo] = :root unless Util.win_os? || gem_home
|
143
|
+
options[:command] = 'gem'
|
144
|
+
args << options
|
145
|
+
args.unshift '-i', gem_home if cmd == 'install' && gem_home && !args.any?{ |a| a[/-i|--install-dir/] }
|
146
|
+
Util.ruby cmd, *args
|
147
|
+
end
|
148
|
+
|
149
|
+
end # Gems
|
112
150
|
|
113
|
-
|
114
|
-
# Borrowed from Ruby 1.9.
|
115
|
-
def tap
|
116
|
-
yield self if block_given?
|
117
|
-
self
|
118
|
-
end unless method_defined?('tap')
|
151
|
+
end # Util
|
119
152
|
end
|
120
153
|
|
121
154
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
155
|
+
if RUBY_VERSION < '1.9.0'
|
156
|
+
module Kernel #:nodoc:
|
157
|
+
# Borrowed from Ruby 1.9.
|
158
|
+
def tap
|
159
|
+
yield self if block_given?
|
160
|
+
self
|
161
|
+
end unless method_defined?('tap')
|
162
|
+
end
|
128
163
|
|
129
164
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
165
|
+
class Symbol #:nodoc:
|
166
|
+
# Borrowed from Ruby 1.9.
|
167
|
+
def to_proc
|
168
|
+
Proc.new{|*args| args.shift.__send__(self, *args)}
|
169
|
+
end unless method_defined?('to_proc')
|
170
|
+
end
|
136
171
|
|
137
|
-
|
138
|
-
|
172
|
+
# Also borrowed from Ruby 1.9.
|
173
|
+
class BasicObject #:nodoc:
|
174
|
+
(instance_methods - ['__send__', '__id__', '==', 'send', 'send!', 'respond_to?', 'equal?', 'object_id']).
|
175
|
+
each do |method|
|
176
|
+
undef_method method
|
177
|
+
end
|
178
|
+
|
179
|
+
def self.ancestors
|
180
|
+
[Kernel]
|
181
|
+
end
|
139
182
|
end
|
140
183
|
end
|
141
184
|
|
@@ -185,10 +228,21 @@ class Hash
|
|
185
228
|
# Hash.from_properties(str)
|
186
229
|
# => { 'foo'=>'bar', 'baz'=>'fab' }.to_properties
|
187
230
|
def from_java_properties(string)
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
231
|
+
hash = {}
|
232
|
+
input_stream = Java.java.io.StringBufferInputStream.new(string)
|
233
|
+
java_properties = Java.java.util.Properties.new
|
234
|
+
java_properties.load input_stream
|
235
|
+
keys = java_properties.keySet.iterator
|
236
|
+
while keys.hasNext
|
237
|
+
# Calling key.next in JRuby returns a java.lang.String, behaving as a Ruby string and life is good.
|
238
|
+
# MRI, unfortunately, treats next() like the interface says returning an object that's not a String,
|
239
|
+
# and the Hash doesn't work the way we need it to. Unfortunately, we can call toString on MRI's object,
|
240
|
+
# but not on the JRuby one; calling to_s on the JRuby object returns what we need, but ... you guessed it.
|
241
|
+
# So this seems like the one hack to unite them both.
|
242
|
+
key = Java.java.lang.String.valueOf(keys.next)
|
243
|
+
hash[key] = java_properties.getProperty(key)
|
244
|
+
end
|
245
|
+
hash
|
192
246
|
end
|
193
247
|
|
194
248
|
end
|
@@ -0,0 +1,18 @@
|
|
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/groovy/compiler'
|
18
|
+
require 'buildr/groovy/bdd'
|
@@ -0,0 +1,105 @@
|
|
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
|
+
module Buildr::Groovy
|
17
|
+
|
18
|
+
# EasyB is a Groovy based BDD framework.
|
19
|
+
# To use in your project:
|
20
|
+
#
|
21
|
+
# test.using :easyb
|
22
|
+
#
|
23
|
+
# This framework will search in your project for:
|
24
|
+
# src/spec/groovy/**/*Story.groovy
|
25
|
+
# src/spec/groovy/**/*Behavior.groovy
|
26
|
+
#
|
27
|
+
# Support the following options:
|
28
|
+
# * :format -- Report format :txt or :xml, default is :txt
|
29
|
+
# * :properties -- Hash of properties passed to the test suite.
|
30
|
+
# * :java_args -- Arguments passed to the JVM.
|
31
|
+
class EasyB < TestFramework::JavaBDD
|
32
|
+
@lang = :groovy
|
33
|
+
@bdd_dir = :spec
|
34
|
+
|
35
|
+
VERSION = "0.7"
|
36
|
+
TESTS_PATTERN = [ /(Story|Behavior).groovy$/ ]
|
37
|
+
OPTIONS = [:format, :properties, :java_args]
|
38
|
+
|
39
|
+
class << self
|
40
|
+
def version
|
41
|
+
Buildr.settings.build['jbehave'] || VERSION
|
42
|
+
end
|
43
|
+
|
44
|
+
def dependencies
|
45
|
+
@dependencies ||= ["org.easyb:easyb:jar:#{version}",
|
46
|
+
'org.codehaus.groovy:groovy:jar:1.5.3','asm:asm:jar:2.2.3',
|
47
|
+
'commons-cli:commons-cli:jar:1.0','antlr:antlr:jar:2.7.7']
|
48
|
+
end
|
49
|
+
|
50
|
+
def applies_to?(project) #:nodoc:
|
51
|
+
%w{
|
52
|
+
**/*Behaviour.groovy **/*Behavior.groovy **/*Story.groovy
|
53
|
+
}.any? { |glob| !Dir[project.path_to(:source, bdd_dir, lang, glob)].empty? }
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
def const_missing(const)
|
58
|
+
return super unless const == :REQUIRES # TODO: remove in 1.5
|
59
|
+
Buildr.application.deprecated "Please use JBehave.dependencies/.version instead of JBehave::REQUIRES/VERSION"
|
60
|
+
dependencies
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def tests(dependencies) #:nodoc:
|
65
|
+
Dir[task.project.path_to(:source, bdd_dir, lang, "**/*.groovy")].
|
66
|
+
select { |name| TESTS_PATTERN.any? { |pat| pat === name } }
|
67
|
+
end
|
68
|
+
|
69
|
+
def run(tests, dependencies) #:nodoc:
|
70
|
+
options = { :format => :txt }.merge(self.options).only(*OPTIONS)
|
71
|
+
|
72
|
+
if :txt == options[:format]
|
73
|
+
easyb_format, ext = 'txtstory', '.txt'
|
74
|
+
elsif :xml == options[:format]
|
75
|
+
easyb_format, ext = 'xmlbehavior', '.xml'
|
76
|
+
else
|
77
|
+
raise "Invalid format #{options[:format]} expected one of :txt :xml"
|
78
|
+
end
|
79
|
+
|
80
|
+
cmd_args = [ 'org.disco.easyb.SpecificationRunner' ]
|
81
|
+
cmd_options = { :properties => options[:properties],
|
82
|
+
:java_args => options[:java_args],
|
83
|
+
:classpath => dependencies }
|
84
|
+
|
85
|
+
tests.inject([]) do |passed, test|
|
86
|
+
name = test.sub(/.*?groovy[\/\\]/, '').pathmap('%X')
|
87
|
+
report = File.join(task.report_to.to_s, name + ext)
|
88
|
+
mkpath report.pathmap('%d'), :verbose => false
|
89
|
+
begin
|
90
|
+
Java::Commands.java cmd_args,
|
91
|
+
"-#{easyb_format}", report,
|
92
|
+
test, cmd_options.merge(:name => name)
|
93
|
+
rescue => e
|
94
|
+
passed
|
95
|
+
else
|
96
|
+
passed << test
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end # EasyB
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
Buildr::TestFramework << Buildr::Groovy::EasyB
|
@@ -0,0 +1,138 @@
|
|
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
|
+
module Buildr::Groovy
|
18
|
+
|
19
|
+
# Groovyc compiler:
|
20
|
+
# compile.using(:groovyc)
|
21
|
+
#
|
22
|
+
# You need to require 'buildr/java/groovyc' if you need to use this compiler.
|
23
|
+
#
|
24
|
+
# Used by default if .groovy files are found in the src/main/groovy directory (or src/test/groovy)
|
25
|
+
# and sets the target directory to target/classes (or target/test/classes).
|
26
|
+
#
|
27
|
+
# Groovyc is a joint compiler, this means that when selected for a project, this compiler is used
|
28
|
+
# to compile both groovy and java sources. It's recommended that Groovy sources are placed in the
|
29
|
+
# src/main/groovy directory, even though this compiler also looks in src/main/java
|
30
|
+
#
|
31
|
+
# Groovyc accepts the following options:
|
32
|
+
#
|
33
|
+
# * :encoding -- Encoding of source files
|
34
|
+
# * :verbose -- Asks the compiler for verbose output, true when running in verbose mode.
|
35
|
+
# * :fork -- Whether to execute groovyc using a spawned instance of the JVM; defaults to no
|
36
|
+
# * :memoryInitialSize -- The initial size of the memory for the underlying VM, if using fork mode; ignored otherwise.
|
37
|
+
# Defaults to the standard VM memory setting. (Examples: 83886080, 81920k, or 80m)
|
38
|
+
# * :memoryMaximumSize -- The maximum size of the memory for the underlying VM, if using fork mode; ignored otherwise.
|
39
|
+
# Defaults to the standard VM memory setting. (Examples: 83886080, 81920k, or 80m)
|
40
|
+
# * :listfiles -- Indicates whether the source files to be compiled will be listed; defaults to no
|
41
|
+
# * :stacktrace -- If true each compile error message will contain a stacktrace
|
42
|
+
# * :warnings -- Issue warnings when compiling. True when running in verbose mode.
|
43
|
+
# * :debug -- Generates bytecode with debugging information. Set from the debug
|
44
|
+
# environment variable/global option.
|
45
|
+
# * :deprecation -- If true, shows deprecation messages. False by default.
|
46
|
+
# * :optimise -- Generates faster bytecode by applying optimisations to the program.
|
47
|
+
# * :source -- Source code compatibility.
|
48
|
+
# * :target -- Bytecode compatibility.
|
49
|
+
# * :javac -- Hash of options passed to the ant javac task
|
50
|
+
#
|
51
|
+
class Groovyc < Compiler::Base
|
52
|
+
|
53
|
+
# The groovyc compiler jars are added to classpath at load time,
|
54
|
+
# if you want to customize artifact versions, you must set them on the
|
55
|
+
#
|
56
|
+
# artifact_ns['Buildr::Compiler::Groovyc'].groovy = '1.5.4'
|
57
|
+
#
|
58
|
+
# namespace before this file is required.
|
59
|
+
REQUIRES = ArtifactNamespace.for(self) do |ns|
|
60
|
+
ns.groovy! 'org.codehaus.groovy:groovy:jar:>=1.5.3'
|
61
|
+
ns.commons_cli! 'commons-cli:commons-cli:jar:>=1.0'
|
62
|
+
ns.asm! 'asm:asm:jar:>=2.2'
|
63
|
+
ns.antlr! 'antlr:antlr:jar:>=2.7.7'
|
64
|
+
end
|
65
|
+
|
66
|
+
ANT_TASK = 'org.codehaus.groovy.ant.Groovyc'
|
67
|
+
GROOVYC_OPTIONS = [:encoding, :verbose, :fork, :memoryInitialSize, :memoryMaximumSize, :listfiles, :stacktrace]
|
68
|
+
JAVAC_OPTIONS = [:optimise, :warnings, :debug, :deprecation, :source, :target, :javac]
|
69
|
+
OPTIONS = GROOVYC_OPTIONS + JAVAC_OPTIONS
|
70
|
+
|
71
|
+
class << self
|
72
|
+
def dependencies #:nodoc:
|
73
|
+
REQUIRES.artifacts
|
74
|
+
end
|
75
|
+
|
76
|
+
def applies_to?(project, task) #:nodoc:
|
77
|
+
paths = task.sources + [sources].flatten.map { |src| Array(project.path_to(:source, task.usage, src.to_sym)) }
|
78
|
+
paths.flatten!
|
79
|
+
# Just select if we find .groovy files
|
80
|
+
paths.any? { |path| !Dir["#{path}/**/*.groovy"].empty? }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
Java.classpath << dependencies
|
85
|
+
|
86
|
+
specify :language => :groovy, :sources => [:groovy, :java], :source_ext => [:groovy, :java],
|
87
|
+
:target => 'classes', :target_ext => 'class', :packaging => :jar
|
88
|
+
|
89
|
+
def initialize(project, options) #:nodoc:
|
90
|
+
super
|
91
|
+
options[:debug] = Buildr.options.debug if options[:debug].nil?
|
92
|
+
options[:deprecation] ||= false
|
93
|
+
options[:optimise] ||= false
|
94
|
+
options[:verbose] ||= Buildr.application.options.trace if options[:verbose].nil?
|
95
|
+
options[:warnings] = verbose if options[:warnings].nil?
|
96
|
+
options[:javac] = OpenObject.new if options[:javac].nil?
|
97
|
+
end
|
98
|
+
|
99
|
+
# http://groovy.codehaus.org/The+groovyc+Ant+Task
|
100
|
+
def compile(sources, target, dependencies) #:nodoc:
|
101
|
+
return if Buildr.application.options.dryrun
|
102
|
+
Buildr.ant 'groovyc' do |ant|
|
103
|
+
classpath = dependencies | self.class.dependencies.map(&:to_s)
|
104
|
+
ant.taskdef :name => 'groovyc', :classname => ANT_TASK, :classpath => classpath.join(File::PATH_SEPARATOR)
|
105
|
+
ant.groovyc groovyc_options(sources, target) do
|
106
|
+
sources.each { |src| ant.src :path => src }
|
107
|
+
ant.classpath do
|
108
|
+
classpath.each { |dep| ant.pathelement :path => dep }
|
109
|
+
end
|
110
|
+
ant.javac(javac_options)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
private
|
116
|
+
def groovyc_options(sources, target)
|
117
|
+
check_options options, OPTIONS
|
118
|
+
groovyc_options = options.to_hash.only(*GROOVYC_OPTIONS)
|
119
|
+
groovyc_options[:destdir] = File.expand_path(target)
|
120
|
+
groovyc_options
|
121
|
+
end
|
122
|
+
|
123
|
+
def javac_options
|
124
|
+
check_options options, OPTIONS
|
125
|
+
javac_options = options.to_hash.only(*JAVAC_OPTIONS)
|
126
|
+
javac_options[:optimize] = (javac_options.delete(:optimise) || false)
|
127
|
+
javac_options[:nowarn] = (javac_options.delete(:warnings) || verbose).to_s !~ /^(true|yes|on)$/i
|
128
|
+
other = javac_options.delete(:javac) || {}
|
129
|
+
javac_options.merge!(other)
|
130
|
+
javac_options
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
# Groovy compiler comes first, ahead of Javac, this allows it to pick
|
137
|
+
# projects that mix Groovy and Java code by spotting Groovy code first.
|
138
|
+
Buildr::Compiler.compilers.unshift Buildr::Groovy::Groovyc
|