ittayd-buildr 1.3.4 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +62 -9
- data/NOTICE +1 -1
- data/README.rdoc +9 -21
- data/Rakefile +20 -39
- data/_buildr +1 -0
- data/{spec/java/ant.rb → _jbuildr} +11 -15
- metadata +30 -210
- data/DISCLAIMER +0 -7
- data/addon/buildr/antlr.rb +0 -65
- data/addon/buildr/cobertura.rb +0 -22
- data/addon/buildr/drb.rb +0 -281
- data/addon/buildr/emma.rb +0 -22
- data/addon/buildr/hibernate.rb +0 -142
- data/addon/buildr/javacc.rb +0 -85
- data/addon/buildr/jdepend.rb +0 -60
- data/addon/buildr/jetty.rb +0 -248
- data/addon/buildr/jibx.rb +0 -86
- data/addon/buildr/nailgun.rb +0 -221
- data/addon/buildr/openjpa.rb +0 -90
- 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 +0 -41
- 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 +0 -144
- data/addon/buildr/path.rb +0 -136
- data/addon/buildr/xmlbeans.rb +0 -93
- data/buildr.buildfile +0 -53
- data/buildr.gemspec +0 -58
- data/doc/css/default.css +0 -228
- data/doc/css/print.css +0 -100
- data/doc/css/syntax.css +0 -52
- data/doc/images/apache-incubator-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.tif +0 -0
- data/doc/pages/artifacts.textile +0 -207
- data/doc/pages/building.textile +0 -240
- data/doc/pages/contributing.textile +0 -208
- data/doc/pages/download.textile +0 -62
- data/doc/pages/extending.textile +0 -175
- data/doc/pages/getting_started.textile +0 -273
- data/doc/pages/index.textile +0 -42
- data/doc/pages/languages.textile +0 -407
- data/doc/pages/mailing_lists.textile +0 -17
- data/doc/pages/more_stuff.textile +0 -314
- data/doc/pages/packaging.textile +0 -427
- data/doc/pages/projects.textile +0 -274
- data/doc/pages/recipes.textile +0 -103
- data/doc/pages/settings_profiles.textile +0 -274
- data/doc/pages/testing.textile +0 -212
- data/doc/pages/troubleshooting.textile +0 -103
- data/doc/pages/whats_new.textile +0 -323
- data/doc/print.haml +0 -51
- data/doc/print.toc.yaml +0 -29
- data/doc/scripts/buildr-git.rb +0 -412
- data/doc/scripts/install-jruby.sh +0 -44
- data/doc/scripts/install-linux.sh +0 -64
- data/doc/scripts/install-osx.sh +0 -52
- data/doc/site.haml +0 -56
- data/doc/site.toc.yaml +0 -47
- data/etc/KEYS +0 -151
- data/etc/git-svn-authors +0 -16
- data/lib/buildr.rb +0 -33
- data/lib/buildr/core.rb +0 -29
- data/lib/buildr/core/application.rb +0 -665
- data/lib/buildr/core/build.rb +0 -311
- data/lib/buildr/core/checks.rb +0 -254
- data/lib/buildr/core/common.rb +0 -150
- data/lib/buildr/core/compile.rb +0 -590
- data/lib/buildr/core/environment.rb +0 -117
- data/lib/buildr/core/filter.rb +0 -366
- data/lib/buildr/core/generate.rb +0 -195
- data/lib/buildr/core/help.rb +0 -119
- data/lib/buildr/core/osx.rb +0 -49
- data/lib/buildr/core/progressbar.rb +0 -156
- data/lib/buildr/core/project.rb +0 -923
- data/lib/buildr/core/test.rb +0 -715
- data/lib/buildr/core/transports.rb +0 -560
- data/lib/buildr/core/util.rb +0 -294
- data/lib/buildr/groovy.rb +0 -18
- data/lib/buildr/groovy/bdd.rb +0 -106
- data/lib/buildr/groovy/compiler.rb +0 -138
- data/lib/buildr/ide.rb +0 -19
- data/lib/buildr/ide/eclipse.rb +0 -222
- data/lib/buildr/ide/idea.ipr.template +0 -300
- data/lib/buildr/ide/idea.rb +0 -190
- data/lib/buildr/ide/idea7x.ipr.template +0 -290
- data/lib/buildr/ide/idea7x.rb +0 -212
- data/lib/buildr/java.rb +0 -23
- data/lib/buildr/java/ant.rb +0 -92
- data/lib/buildr/java/bdd.rb +0 -451
- data/lib/buildr/java/cobertura.rb +0 -236
- data/lib/buildr/java/commands.rb +0 -211
- data/lib/buildr/java/compiler.rb +0 -348
- data/lib/buildr/java/deprecated.rb +0 -141
- data/lib/buildr/java/emma.rb +0 -238
- data/lib/buildr/java/jruby.rb +0 -117
- data/lib/buildr/java/jtestr_runner.rb.erb +0 -116
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +0 -119
- data/lib/buildr/java/packaging.rb +0 -717
- data/lib/buildr/java/pom.rb +0 -174
- data/lib/buildr/java/rjb.rb +0 -155
- data/lib/buildr/java/test_result.rb +0 -307
- data/lib/buildr/java/tests.rb +0 -329
- data/lib/buildr/java/version_requirement.rb +0 -172
- data/lib/buildr/packaging.rb +0 -24
- data/lib/buildr/packaging/archive.rb +0 -488
- data/lib/buildr/packaging/artifact.rb +0 -759
- data/lib/buildr/packaging/artifact_namespace.rb +0 -972
- data/lib/buildr/packaging/artifact_search.rb +0 -140
- data/lib/buildr/packaging/gems.rb +0 -102
- data/lib/buildr/packaging/package.rb +0 -233
- data/lib/buildr/packaging/tar.rb +0 -186
- data/lib/buildr/packaging/version_requirement.rb +0 -172
- data/lib/buildr/packaging/zip.rb +0 -64
- data/lib/buildr/packaging/ziptask.rb +0 -313
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/scala.rb +0 -19
- data/lib/buildr/scala/compiler.rb +0 -109
- data/lib/buildr/scala/tests.rb +0 -203
- data/rakelib/apache.rake +0 -191
- data/rakelib/changelog.rake +0 -57
- data/rakelib/doc.rake +0 -103
- data/rakelib/package.rake +0 -76
- data/rakelib/release.rake +0 -65
- data/rakelib/rspec.rake +0 -83
- data/rakelib/rubyforge.rake +0 -56
- data/rakelib/scm.rake +0 -49
- data/rakelib/setup.rake +0 -81
- data/rakelib/stage.rake +0 -48
- data/spec/addon/drb_spec.rb +0 -328
- data/spec/core/application_spec.rb +0 -419
- data/spec/core/build_spec.rb +0 -423
- data/spec/core/checks_spec.rb +0 -519
- data/spec/core/common_spec.rb +0 -670
- data/spec/core/compile_spec.rb +0 -582
- data/spec/core/generate_spec.rb +0 -33
- data/spec/core/project_spec.rb +0 -776
- data/spec/core/test_spec.rb +0 -1098
- data/spec/core/transport_spec.rb +0 -500
- data/spec/groovy/bdd_spec.rb +0 -80
- data/spec/groovy/compiler_spec.rb +0 -239
- data/spec/ide/eclipse_spec.rb +0 -311
- data/spec/java/bdd_spec.rb +0 -358
- data/spec/java/cobertura_spec.rb +0 -77
- data/spec/java/compiler_spec.rb +0 -446
- data/spec/java/emma_spec.rb +0 -120
- data/spec/java/java_spec.rb +0 -96
- data/spec/java/packaging_spec.rb +0 -1120
- data/spec/java/test_coverage_spec.rb +0 -255
- data/spec/java/tests_spec.rb +0 -471
- data/spec/packaging/archive_spec.rb +0 -503
- data/spec/packaging/artifact_namespace_spec.rb +0 -646
- data/spec/packaging/artifact_spec.rb +0 -795
- data/spec/packaging/packaging_helper.rb +0 -63
- data/spec/packaging/packaging_spec.rb +0 -589
- data/spec/sandbox.rb +0 -139
- data/spec/scala/compiler_spec.rb +0 -228
- data/spec/scala/tests_spec.rb +0 -215
- data/spec/spec_helpers.rb +0 -327
- data/spec/version_requirement_spec.rb +0 -123
data/lib/buildr/core/util.rb
DELETED
@@ -1,294 +0,0 @@
|
|
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 'rbconfig'
|
18
|
-
require 'pathname'
|
19
|
-
autoload :Tempfile, 'tempfile'
|
20
|
-
autoload :YAML, 'yaml'
|
21
|
-
autoload :REXML, 'rexml/document'
|
22
|
-
gem 'xml-simple' ; autoload :XmlSimple, 'xmlsimple'
|
23
|
-
gem 'builder' ; autoload :Builder, 'builder' # A different kind of buildr, one we use to create XML.
|
24
|
-
require 'highline/import'
|
25
|
-
|
26
|
-
|
27
|
-
module Buildr
|
28
|
-
|
29
|
-
module Util
|
30
|
-
extend self
|
31
|
-
|
32
|
-
def java_platform?
|
33
|
-
RUBY_PLATFORM =~ /java/
|
34
|
-
end
|
35
|
-
|
36
|
-
# In order to determine if we are running on a windows OS,
|
37
|
-
# prefer this function instead of using Gem.win_platform?.
|
38
|
-
#
|
39
|
-
# Gem.win_platform? only checks these RUBY_PLATFORM global,
|
40
|
-
# that in some cases like when running on JRuby is not
|
41
|
-
# succifient for our purpose:
|
42
|
-
#
|
43
|
-
# For JRuby, the value for RUBY_PLATFORM will always be 'java'
|
44
|
-
# That's why this function checks on Config::CONFIG['host_os']
|
45
|
-
def win_os?
|
46
|
-
Config::CONFIG['host_os'] =~ /windows|cygwin|bccwin|cygwin|djgpp|mingw|mswin|wince/i
|
47
|
-
end
|
48
|
-
|
49
|
-
# Runs Ruby with these command line arguments. The last argument may be a hash,
|
50
|
-
# supporting the following keys:
|
51
|
-
# :command -- Runs the specified script (e.g., :command=>'gem')
|
52
|
-
# :sudo -- Run as sudo on operating systems that require it.
|
53
|
-
# :verbose -- Override Rake's verbose flag.
|
54
|
-
def ruby(*args)
|
55
|
-
options = Hash === args.last ? args.pop : {}
|
56
|
-
cmd = []
|
57
|
-
ruby_bin = File.expand_path(Config::CONFIG['ruby_install_name'], Config::CONFIG['bindir'])
|
58
|
-
if options.delete(:sudo) && !(win_os? || Process.uid == File.stat(ruby_bin).uid)
|
59
|
-
cmd << 'sudo' << '-u' << "##{File.stat(ruby_bin).uid}"
|
60
|
-
end
|
61
|
-
cmd << ruby_bin
|
62
|
-
cmd << '-S' << options.delete(:command) if options[:command]
|
63
|
-
sh *cmd.push(*args.flatten).push(options) do |ok, status|
|
64
|
-
ok or fail "Command failed with status (#{status ? status.exitstatus : 'unknown'}): [#{cmd.join(" ")}]"
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
# Just like File.expand_path, but for windows systems it
|
69
|
-
# capitalizes the drive name and ensures backslashes are used
|
70
|
-
def normalize_path(path, *dirs)
|
71
|
-
path = File.expand_path(path, *dirs)
|
72
|
-
if win_os?
|
73
|
-
path.gsub!('/', '\\').gsub!(/^[a-zA-Z]+:/) { |s| s.upcase }
|
74
|
-
else
|
75
|
-
path
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# Return the timestamp of file, without having to create a file task
|
80
|
-
def timestamp(file)
|
81
|
-
if File.exist?(file)
|
82
|
-
File.mtime(file)
|
83
|
-
else
|
84
|
-
Rake::EARLY
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
# Return the path to the first argument, starting from the path provided by the
|
89
|
-
# second argument.
|
90
|
-
#
|
91
|
-
# For example:
|
92
|
-
# relative_path('foo/bar', 'foo')
|
93
|
-
# => 'bar'
|
94
|
-
# relative_path('foo/bar', 'baz')
|
95
|
-
# => '../foo/bar'
|
96
|
-
# relative_path('foo/bar')
|
97
|
-
# => 'foo/bar'
|
98
|
-
# relative_path('/foo/bar', 'baz')
|
99
|
-
# => '/foo/bar'
|
100
|
-
def relative_path(to, from = '.')
|
101
|
-
to = Pathname.new(to).cleanpath
|
102
|
-
return to.to_s if from.nil?
|
103
|
-
to_path = Pathname.new(File.expand_path(to.to_s, "/"))
|
104
|
-
from_path = Pathname.new(File.expand_path(from.to_s, "/"))
|
105
|
-
to_path.relative_path_from(from_path).to_s
|
106
|
-
end
|
107
|
-
|
108
|
-
# Generally speaking, it's not a good idea to operate on dot files (files starting with dot).
|
109
|
-
# These are considered invisible files (.svn, .hg, .irbrc, etc). Dir.glob/FileList ignore them
|
110
|
-
# on purpose. There are few cases where we do have to work with them (filter, zip), a better
|
111
|
-
# solution is welcome, maybe being more explicit with include. For now, this will do.
|
112
|
-
def recursive_with_dot_files(*dirs)
|
113
|
-
FileList[dirs.map { |dir| File.join(dir, '/**/{*,.*}') }].reject { |file| File.basename(file) =~ /^[.]{1,2}$/ }
|
114
|
-
end
|
115
|
-
|
116
|
-
# Utility methods for running gem commands
|
117
|
-
module Gems
|
118
|
-
extend self
|
119
|
-
|
120
|
-
# Install gems specified by each Gem::Dependency if they are missing. This method prompts the user
|
121
|
-
# for permission before installing anything.
|
122
|
-
#
|
123
|
-
# Returns the installed Gem::Dependency objects or fails if permission not granted or when buildr
|
124
|
-
# is not running interactively (on a tty)
|
125
|
-
def install(*dependencies)
|
126
|
-
raise ArgumentError, "Expected at least one argument" if dependencies.empty?
|
127
|
-
remote = dependencies.map { |dep| Gem::SourceInfoCache.search(dep).last || dep }
|
128
|
-
not_found_deps, to_install = remote.partition { |gem| gem.is_a?(Gem::Dependency) }
|
129
|
-
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?
|
130
|
-
uses = "This build requires the gems #{to_install.map(&:full_name).join(', ')}:"
|
131
|
-
fail Gem::LoadError, "#{uses} to install, run Buildr interactively." unless $stdout.isatty
|
132
|
-
unless agree("#{uses} do you want me to install them? [Y/n]", true)
|
133
|
-
fail Gem::LoadError, 'Cannot build without these gems.'
|
134
|
-
end
|
135
|
-
to_install.each do |spec|
|
136
|
-
say "Installing #{spec.full_name} ... " if verbose
|
137
|
-
command 'install', spec.name, '-v', spec.version.to_s, :verbose => false
|
138
|
-
Gem.source_index.load_gems_in Gem::SourceIndex.installed_spec_directories
|
139
|
-
end
|
140
|
-
to_install
|
141
|
-
end
|
142
|
-
|
143
|
-
# Execute a GemRunner command
|
144
|
-
def command(cmd, *args)
|
145
|
-
options = Hash === args.last ? args.pop : {}
|
146
|
-
gem_home = ENV['GEM_HOME'] || Gem.path.find { |f| File.writable?(f) }
|
147
|
-
options[:sudo] = :root unless Util.win_os? || gem_home
|
148
|
-
options[:command] = 'gem'
|
149
|
-
args << options
|
150
|
-
args.unshift '-i', gem_home if cmd == 'install' && gem_home && !args.any?{ |a| a[/-i|--install-dir/] }
|
151
|
-
Util.ruby cmd, *args
|
152
|
-
end
|
153
|
-
|
154
|
-
end # Gems
|
155
|
-
|
156
|
-
end # Util
|
157
|
-
end
|
158
|
-
|
159
|
-
|
160
|
-
if RUBY_VERSION < '1.9.0'
|
161
|
-
module Kernel #:nodoc:
|
162
|
-
# Borrowed from Ruby 1.9.
|
163
|
-
def tap
|
164
|
-
yield self if block_given?
|
165
|
-
self
|
166
|
-
end unless method_defined?('tap')
|
167
|
-
end
|
168
|
-
|
169
|
-
|
170
|
-
class Symbol #:nodoc:
|
171
|
-
# Borrowed from Ruby 1.9.
|
172
|
-
def to_proc
|
173
|
-
Proc.new{|*args| args.shift.__send__(self, *args)}
|
174
|
-
end unless method_defined?('to_proc')
|
175
|
-
end
|
176
|
-
|
177
|
-
# Also borrowed from Ruby 1.9.
|
178
|
-
class BasicObject #:nodoc:
|
179
|
-
(instance_methods - ['__send__', '__id__', '==', 'send', 'send!', 'respond_to?', 'equal?', 'object_id']).
|
180
|
-
each do |method|
|
181
|
-
undef_method method
|
182
|
-
end
|
183
|
-
|
184
|
-
def self.ancestors
|
185
|
-
[Kernel]
|
186
|
-
end
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
|
191
|
-
class OpenObject < Hash
|
192
|
-
|
193
|
-
def initialize(source=nil, &block)
|
194
|
-
@hash = Hash.new(&block)
|
195
|
-
@hash.update(source) if source
|
196
|
-
end
|
197
|
-
|
198
|
-
def [](key)
|
199
|
-
@hash[key]
|
200
|
-
end
|
201
|
-
|
202
|
-
def []=(key, value)
|
203
|
-
@hash[key] = value
|
204
|
-
end
|
205
|
-
|
206
|
-
def delete(key)
|
207
|
-
@hash.delete(key)
|
208
|
-
end
|
209
|
-
|
210
|
-
def to_hash
|
211
|
-
@hash.clone
|
212
|
-
end
|
213
|
-
|
214
|
-
def method_missing(symbol, *args)
|
215
|
-
if symbol.to_s =~ /=$/
|
216
|
-
self[symbol.to_s[0..-2].to_sym] = args.first
|
217
|
-
else
|
218
|
-
self[symbol]
|
219
|
-
end
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
|
224
|
-
class Hash
|
225
|
-
|
226
|
-
class << self
|
227
|
-
|
228
|
-
# :call-seq:
|
229
|
-
# Hash.from_java_properties(string)
|
230
|
-
#
|
231
|
-
# Returns a hash from a string in the Java properties file format. For example:
|
232
|
-
# str = 'foo=bar\nbaz=fab'
|
233
|
-
# Hash.from_properties(str)
|
234
|
-
# => { 'foo'=>'bar', 'baz'=>'fab' }.to_properties
|
235
|
-
def from_java_properties(string)
|
236
|
-
hash = {}
|
237
|
-
input_stream = Java.java.io.StringBufferInputStream.new(string)
|
238
|
-
java_properties = Java.java.util.Properties.new
|
239
|
-
java_properties.load input_stream
|
240
|
-
keys = java_properties.keySet.iterator
|
241
|
-
while keys.hasNext
|
242
|
-
# Calling key.next in JRuby returns a java.lang.String, behaving as a Ruby string and life is good.
|
243
|
-
# MRI, unfortunately, treats next() like the interface says returning an object that's not a String,
|
244
|
-
# and the Hash doesn't work the way we need it to. Unfortunately, we can call toString on MRI's object,
|
245
|
-
# but not on the JRuby one; calling to_s on the JRuby object returns what we need, but ... you guessed it.
|
246
|
-
# So this seems like the one hack to unite them both.
|
247
|
-
key = Java.java.lang.String.valueOf(keys.next)
|
248
|
-
hash[key] = java_properties.getProperty(key)
|
249
|
-
end
|
250
|
-
hash
|
251
|
-
end
|
252
|
-
|
253
|
-
end
|
254
|
-
|
255
|
-
# :call-seq:
|
256
|
-
# only(keys*) => hash
|
257
|
-
#
|
258
|
-
# Returns a new hash with only the specified keys.
|
259
|
-
#
|
260
|
-
# For example:
|
261
|
-
# { :a=>1, :b=>2, :c=>3, :d=>4 }.only(:a, :c)
|
262
|
-
# => { :a=>1, :c=>3 }
|
263
|
-
def only(*keys)
|
264
|
-
keys.inject({}) { |hash, key| has_key?(key) ? hash.merge(key=>self[key]) : hash }
|
265
|
-
end
|
266
|
-
|
267
|
-
|
268
|
-
# :call-seq:
|
269
|
-
# except(keys*) => hash
|
270
|
-
#
|
271
|
-
# Returns a new hash without the specified keys.
|
272
|
-
#
|
273
|
-
# For example:
|
274
|
-
# { :a=>1, :b=>2, :c=>3, :d=>4 }.except(:a, :c)
|
275
|
-
# => { :b=>2, :d=>4 }
|
276
|
-
def except(*keys)
|
277
|
-
(self.keys - keys).inject({}) { |hash, key| hash.merge(key=>self[key]) }
|
278
|
-
end
|
279
|
-
|
280
|
-
# :call-seq:
|
281
|
-
# to_java_properties => string
|
282
|
-
#
|
283
|
-
# Convert hash to string format used for Java properties file. For example:
|
284
|
-
# { 'foo'=>'bar', 'baz'=>'fab' }.to_properties
|
285
|
-
# => foo=bar
|
286
|
-
# baz=fab
|
287
|
-
def to_java_properties
|
288
|
-
keys.sort.map { |key|
|
289
|
-
value = self[key].gsub(/[\t\r\n\f\\]/) { |escape| "\\" + {"\t"=>"t", "\r"=>"r", "\n"=>"n", "\f"=>"f", "\\"=>"\\"}[escape] }
|
290
|
-
"#{key}=#{value}"
|
291
|
-
}.join("\n")
|
292
|
-
end
|
293
|
-
|
294
|
-
end
|
data/lib/buildr/groovy.rb
DELETED
@@ -1,18 +0,0 @@
|
|
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'
|
data/lib/buildr/groovy/bdd.rb
DELETED
@@ -1,106 +0,0 @@
|
|
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
|
-
# EasyB is a Groovy based BDD framework.
|
20
|
-
# To use in your project:
|
21
|
-
#
|
22
|
-
# test.using :easyb
|
23
|
-
#
|
24
|
-
# This framework will search in your project for:
|
25
|
-
# src/spec/groovy/**/*Story.groovy
|
26
|
-
# src/spec/groovy/**/*Behavior.groovy
|
27
|
-
#
|
28
|
-
# Support the following options:
|
29
|
-
# * :format -- Report format :txt or :xml, default is :txt
|
30
|
-
# * :properties -- Hash of properties passed to the test suite.
|
31
|
-
# * :java_args -- Arguments passed to the JVM.
|
32
|
-
class EasyB < TestFramework::JavaBDD
|
33
|
-
@lang = :groovy
|
34
|
-
@bdd_dir = :spec
|
35
|
-
|
36
|
-
VERSION = "0.7"
|
37
|
-
TESTS_PATTERN = [ /(Story|Behavior).groovy$/ ]
|
38
|
-
OPTIONS = [:format, :properties, :java_args]
|
39
|
-
|
40
|
-
class << self
|
41
|
-
def version
|
42
|
-
Buildr.settings.build['jbehave'] || VERSION
|
43
|
-
end
|
44
|
-
|
45
|
-
def dependencies
|
46
|
-
@dependencies ||= ["org.easyb:easyb:jar:#{version}",
|
47
|
-
'org.codehaus.groovy:groovy:jar:1.5.3','asm:asm:jar:2.2.3',
|
48
|
-
'commons-cli:commons-cli:jar:1.0','antlr:antlr:jar:2.7.7']
|
49
|
-
end
|
50
|
-
|
51
|
-
def applies_to?(project) #:nodoc:
|
52
|
-
%w{
|
53
|
-
**/*Behaviour.groovy **/*Behavior.groovy **/*Story.groovy
|
54
|
-
}.any? { |glob| !Dir[project.path_to(:source, bdd_dir, lang, glob)].empty? }
|
55
|
-
end
|
56
|
-
|
57
|
-
private
|
58
|
-
def const_missing(const)
|
59
|
-
return super unless const == :REQUIRES # TODO: remove in 1.5
|
60
|
-
Buildr.application.deprecated "Please use JBehave.dependencies/.version instead of JBehave::REQUIRES/VERSION"
|
61
|
-
dependencies
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def tests(dependencies) #:nodoc:
|
66
|
-
Dir[task.project.path_to(:source, bdd_dir, lang, "**/*.groovy")].
|
67
|
-
select { |name| TESTS_PATTERN.any? { |pat| pat === name } }
|
68
|
-
end
|
69
|
-
|
70
|
-
def run(tests, dependencies) #:nodoc:
|
71
|
-
options = { :format => :txt }.merge(self.options).only(*OPTIONS)
|
72
|
-
|
73
|
-
if :txt == options[:format]
|
74
|
-
easyb_format, ext = 'txtstory', '.txt'
|
75
|
-
elsif :xml == options[:format]
|
76
|
-
easyb_format, ext = 'xmlbehavior', '.xml'
|
77
|
-
else
|
78
|
-
raise "Invalid format #{options[:format]} expected one of :txt :xml"
|
79
|
-
end
|
80
|
-
|
81
|
-
cmd_args = [ 'org.disco.easyb.SpecificationRunner' ]
|
82
|
-
cmd_options = { :properties => options[:properties],
|
83
|
-
:java_args => options[:java_args],
|
84
|
-
:classpath => dependencies }
|
85
|
-
|
86
|
-
tests.inject([]) do |passed, test|
|
87
|
-
name = test.sub(/.*?groovy[\/\\]/, '').pathmap('%X')
|
88
|
-
report = File.join(task.report_to.to_s, name + ext)
|
89
|
-
mkpath report.pathmap('%d'), :verbose => false
|
90
|
-
begin
|
91
|
-
Java::Commands.java cmd_args,
|
92
|
-
"-#{easyb_format}", report,
|
93
|
-
test, cmd_options.merge(:name => name)
|
94
|
-
rescue => e
|
95
|
-
passed
|
96
|
-
else
|
97
|
-
passed << test
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
end # EasyB
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
|
-
Buildr::TestFramework << Buildr::Groovy::EasyB
|
@@ -1,138 +0,0 @@
|
|
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/groovy/compiler' 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
|